Group Admins

  • Profile picture of Karim
  • Profile picture of Jean

OpenMusic

Public Group active 1 week, 3 days ago

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

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

Author 2 Subscribed Users |
Profile photo of MariaRose
MariaRose

Dear OM Users

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

Thanks :)

Best L

October 31, 2017 at 02:43 #24184
Profile photo of Karim
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

Best
K

October 31, 2017 at 03:17 #24185
Profile photo of MariaRose
MariaRose

Dear Karim,

thanks very much for this clear very nice detailed description!

Best
L

October 31, 2017 at 06:16 #24186

You must be logged in to reply to this topic.

Log in now