Hello guys! I noticed that Guttag uses lists in many cases where - seemingly - tuples would work as well. When I write code I'm trying to avoid mutable data objects whenever it's possible but I was just wondering if there's any particular reason why lists may be preferable in general? (Maybe something about memory requirements? )
MIT 6.00 Intro Computer Science (OCW)
Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga.
Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus.
Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
lists in general are more easier to work and handle......you can easily refer to an element, pop out a element from list , add elements , overwrite elements(replace with new ones) etc.
certainly all these features are not available in tuples and lists have an advantage where we need to constantly modify the stored data be it add elements or refer to them.
as regarding memory requirements someone else may better answer it
Not the answer you are looking for? Search for more explanations.
It seems like a tuple would be an array(n-tuple)? I've heard the term in discrete and calc and such.
From above it says tuples cannot modify the data within(stacks,queues,etc) but Arrays can... Arrays aren't a list I don't believe.
A list takes up more bytes than a tuple, and a tuple is immutable. That would seem to argue for using tuples unless you need to be able to append or assign values to elements. I find lists easier to work with.
not sure why prof. Guttag uses list over tuples but the following link gives some info about their differences and uses.
hope it helps
Lists vs Tuples is very much about what you need them for,
If you want a variable that you do not want to accidentally change use a tuple for constants,
(For style, constants variable names are written in uppercase i.e. EARTH_RADIUS = 6 378.1)
If you want to change / add to / remove from you need mutability, a list would be better.