3 ms·
I was introduced to Scheme as part of a course in the tradition of SICP. Hmm. I'm not sure how much using "pair, first, second" instead of "cons, car, cdr" wou
by rgoulter 5y ago
I was introduced to Scheme as part of a course in the tradition of SICP.
Hmm. I'm not sure how much using "pair, first, second" instead of "cons, car, cdr" would clarify things. The nature of "a list is either nil, or a cons of an item and a list" is entirely different from e.g. how you interact with Python lists. I'm not sure "a list is either nil, or a pair of an item and a list" is that much clearer.
But also, with that algebraic definition of a list, it often didn't require using car/cdr directly. During the SICP course, you find that you can solve the given exercises by either writing functions which use car/cdr, or by using the higher-order map/filter/flatten/fold. Or e.g. in Haskell, a list can be pattern-matched to x:xs.