• Profile picture of Karim
  • Profile picture of Jean


Groupe Public active 18 hours et 23 minutes ago

User group for OpenMusic and computer-aided composition. Visit the Forum for discussions.

[Basic Beginner, Beginner Question- Car/first? ]

Auteur 2 Utilisateurs souscrits |
Profile photo of MariaRose

Dear OM Users

I am sorry for asking something very basic .. whats the difference between first and car?

Thanks :)

Best L

Octobre 31, 2017 à 02:43 #24184
Profile photo of Karim

Dear L,

Both are the same concerning the resulting evaluation. They will return the first elmt of a list. However, car historically is more basic. The first more important expression in lisp are car and cdr.
car -> first of the list
cdr -> the rest of the list

It is because when you read lisp code, the first elemt of a list is either an expression (function, method or macro) and the rest are elemt as arguments,

YOu can also use nth which is really cool…

(nth 0 ‘(1 2 3 4)) => 1

(nth 2 ‘(1 2 3 4)) => 3
same thing as :

(third ‘(1 2 3 4)) => 3


Octobre 31, 2017 à 03:17 #24185
Profile photo of MariaRose

Dear Karim,

thanks very much for this clear very nice detailed description!


Octobre 31, 2017 à 06:16 #24186

Vous devez être connecté pour répondre à ce sujet.

Log in now