
CAR and CDR - sabalaba
http://en.wikipedia.org/wiki/Car_and_cdr
======
RBerenguel
I always forgot which was which until I actually forced me to use them for a
while (and "while" was too long). The only cool thing of the names is that you
can get a cryptic sticker "My other car is a cdr" that no-one will understand
but will make you jiggle each morning

~~~
phoboslab
I feel the same way about many *nix commands. A while ago I thought it was
neat to have TLAs[1] for everything, but now I just think it's bad "API"
design.

Why is it ls instead of list? chmod instead of permissions? grep instead of
search? mv, cp, rm instead of move, copy, remove? Is it really so much work to
type a few more characters to justify this?

Programming langue APIs (or rather their libraries) have come a long way since
the C days in that regard, but OS wise we're still stuck with these cryptic
names.

[1] [http://en.wikipedia.org/wiki/Three-
letter_acronym](http://en.wikipedia.org/wiki/Three-letter_acronym)

~~~
RBerenguel
I don't mind that much unix commands, in general (with their names, not with
their usage, I hate using grep and find.)

I hate chmod, too, because I can't remember exactly what permissions are what
(number-wise.) My fault, not his. But I'd love it to be named "grant" and have
a neater language. Like grant user/group/whatever read,write,execute (rwx are
actually okayish...) filename. I know chmod is more or less like this. But I
don't stand it. It's like combinatoric problems, something deep inside of me
refuses to accept doing it :)

I guess you know what grep stands for, don't you? It's a "legacy" command from
an early version of ed, g/re/p as in "global search" a "re"gex "p"rinting
results. It could be named re (for regex, search implicit) or res (I like
this.) Anyway, I use ag (the silver searcher) for text/code search, though.
Less letters, easier to use (I keep forgetting if I need -r, -e and all that,
ag makes it somewhat easier.)

As for mv, cp, rm, if all 2-letter acronyms were that easy to remember! Did
you use extensively DOS? Most commands where far too verbose, I cringe if
thinking about having to write copy to copy. Cp is just a smash with the left
hand and another with the right hand and off you go. Minimise errors, 2
strokes. Actually now I wonder why in _nix we have clear and not cls (or just
cl)

As a matter of names... Plan9 uses _nix names, and since Plan9 tried to do
things "differently" almost just for the sake of it, either they didn't think
about it or thought it was a bad idea.

~~~
jenrzzz
You can use symbolic modes in chmod too if you can't remember the octal
representation. For example, you could set 0755 with "u=rwx,go=rx."

------
csmuk
Still prefer _first_ and _rest_. At least that has meaning outside the first
use of car and cdr.

~~~
mercurial
I'll take head/tail over first/rest, but first/rest is not too bad.

~~~
lgarron
I'm a fan first/rest because of Mathematica. It has four functions that all
end in "st", which means I can always recall the one I need:

First, Rest, Most, Last

(Results on Range[4], respectively: 1, {2, 3, 4}, {1, 2, 3}, 4.)

~~~
draegtun
Rebol comes with _first_ & _last_ but not the others.

    
    
      >> a: [1 2 3 4]
      == [1 2 3 4]
    
      >> first a
      == 1
    
      >> last a
      == 4
    

This is how you could add _rest_ & _most_ :

    
    
      >> rest: func [s] [next s] 
      >> most: func [s] [copy/part s back tail s]
    
      >> rest a
      == [2 3 4]
    
      >> most a                                  
      == [1 2 3]
    

Rebol unifies all this under what it calls a _series_ \-
[http://www.rebol.com/docs/core23/rebolcore-6.html](http://www.rebol.com/docs/core23/rebolcore-6.html)

------
elrzn
It's a pity they're not standard in many other languages. I'm not a fan of
having to type first/rest or playing around with syntax soup and I really miss
caddadadaddaaaaaring around.

sub car { $_[0] } sub cdr { shift; @_ } # every utils module ever

~~~
draegtun
Plonk that into an autobox module (like perl5i and/or autobox::Core) and
enjoying even more caddadadaddaaaaaring around!

For eg:

    
    
      use perl5i::2;
    
      sub autobox::Core::ARRAY::car { $_[0]->[0] }
    
      sub autobox::Core::ARRAY::cdr {
          my $last = $#{$_[0]};
          wantarray ? @{$_[0]}[1 .. $last] : [@{$_[0]}[1 .. $last]];
      }
    

then...

    
    
      my @a = 1..4;
    
      @a->car;             # 1
      @a->cdr->cdr->car;   # 3
      @a->cdr;             # 2, 3, 4
    
      my @x = @a->cdr;
      @x->cdr;             # 3, 4
    

Some refs: [https://metacpan.org/pod/perl5i](https://metacpan.org/pod/perl5i)
|
[https://metacpan.org/pod/autobox::Core](https://metacpan.org/pod/autobox::Core)

------
joeygibson
I first learned Lisp so long ago that car and cdr are still ingrained in my
head. first and last feel somehow wrong, to me.

------
kang
quote used to mark data as opposed to code can be tricky while using CDR & CAR
: [http://stackoverflow.com/questions/18697105/cdadr-on-
nested-...](http://stackoverflow.com/questions/18697105/cdadr-on-nested-data-
list-in-lisp)

------
Syssiphus
:* <3 u LISP

------
derleth
I like them because they _don 't_ guide thought: They're abstract names for
abstract concepts. They don't impose any interpretation on the ideas, they
simply present them for what they are. Having to break down a less-useful
conceptual model is even more difficult than building a more-useful one.

