4 ms·
car and cdr must have something going for them that first and rest don't, or else people would have abandoned them decades ago. The author mentions one point in
by gruseom 16y ago
car and cdr must have something going for them that first and rest don't, or else people would have abandoned them decades ago. The author mentions one point in their favor: generality. I'd add another two: brevity, and symmetry.
It's also worth noting that the primary disadvantage of car and cdr, their arbitrariness, fades as one becomes familiar with the language.
- kunjaan 16y ago>car and cdr must have something going for them In most implementations , I can do (cadar (list (list 1 2 3))) -> 2 vs (first (rest (first (list (list 1 2 3))))) -> 2 I find the car and cdrs in Racket very very convenient. Reference: http://docs.racket-lang.org/reference/pairs.html?q=pair%20accessor#(part._.Pair_.Accessor_.Shorthands) http://docs.racket-lang.org/reference/pairs.html?q=pair%20ac...