Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

The LISP

Name: Anonymous 2010-10-12 9:18

Why is the function car not called first-of?

Why is the function cdr not called last-of?

Because.... post a comment with the answer, faggot.

Name: Anonymous 2010-10-12 9:25

you obviously haven't read your SICP today.

Name: Anonymous 2010-10-12 9:33

think of the as register names.  car, cbr, ccr, cdr

Name: Anonymous 2010-10-12 9:35

>>3
No. Think of them as the contents of register names.

Name: Anonymous 2010-10-12 9:39

car isn't first and cdr isn't last.

In Common Lisp, you have synonyms for car and cdr called first and rest.

car and cdr are just accessors (readable and writable, although this is CL specific) for the 2 fields of the cons structure. Chains of conses make lists (proper or improper). The end of a proper list is marked by a NIL (or also known as '(), the empty list), such that the cdr (cdr points to the /rest/ of the list, while car points to the current/top element of the list) of the last cons in the list is NIL. When you're using chains of conses as lists (and for all intents and purposes, you don't need to use car/cdr to access them at all - there are more specific functions for operating on lists), it might make sense to use first/rest synonyms instead of car/cdr, so that you would be more clear that you're working on lists and not on plain conses (which are nothing more than pairs of 2 values, and can be used as such, for representing all kinds of data which fit the bill).

Name: Anonymous 2010-10-12 9:40

Better names for these would be head and tail which would be derived from the metaphor of a snake: a snake is made up of a head and the rest of body being its tail.

Name: Anonymous 2010-10-12 10:07

>>6
No, you're just an idiot.

Name: Anonymous 2010-10-12 10:11

>>6
I get it! Snakes have no internal organs, so they are just a head attached to a tail.

Name: Anonymous 2010-10-12 10:12

>>5

Fair enough, thank you!

Name: Anonymous 2010-10-12 11:02

>>9
Does this look like experts-fucking-exchange to you?

Name: Anonymous 2010-10-12 11:19

Syntax error: found 'fucking', expected 'gender':
experts-fucking-exchange
        ^------------------ here.

Name: Anonymous 2010-10-12 11:28

>>6
Yeah, because (head a-pair) & (tail a-pair) makes a lot of sense.

Name: Anonymous 2010-10-12 11:45

>>12
Then "pair" is a misnomer. It should be called "snake".

Name: Anonymous 2010-10-12 11:51

NOTHING MAY SHOW VISIBLE SIGNS OF ITS HISTORY.

Name: Anonymous 2010-10-12 12:14

>>10
I always read that site as expert sexchange.

Name: Anonymous 2010-10-12 12:17

>>15
That's the joke in >>11. Also, they added a - in because everyone read it like that.

Name: Anonymous 2010-10-12 12:22

That's such a piece of shit website.

Name: Anonymous 2010-10-12 13:32

Out of curiosity, I found that this website actually does exist. http://expert-sexchange.com/

Name: Anonymous 2010-10-12 14:42

>>18
It's a lot better than the real one.

Name: Anonymous 2010-10-12 15:16

I was thinking, what's stopping a cons cell having an arbitrary number of cells? Apart from space and complexity, of course.

Name: Anonymous 2010-10-12 15:46

>>20
Its definition.

Name: Anonymous 2010-10-12 15:51

>>20
Just make your own structure that has as many fields as you like containing anything you want. If they had more fields, they'd be something else, and that would come with extra complexity and more code that needs to be written to accomodate that (for example, you could make a doubly linked list using a 3 field structure).

Name: Anonymous 2010-10-12 16:13

>>21
Well, yeah.
>>22
Anyway I was thinking some more and with an arbitrary number of cells, it just becomes arrays of arrays. A cons cell is as simple as possible and no simpler.
You could write a doubly-linked list with two conses per value, substituting cadr for previous and cddr for next.

Name: Anonymous 2010-10-12 16:25

>>20
vector

Name: Anonymous 2010-10-12 17:28

>>20
Lisps have had these in the past.

Name: Anonymous 2010-10-12 19:00

I'd like a three-way cons. The third value could be called z.

Name: Anonymous 2010-10-12 20:54

>>26
My other czar?

Name: Anonymous 2010-10-12 21:38

>>27
got overthrown

Name: Anonymous 2010-10-13 0:43

>>26
QUANTUM COMPUTING DETECTED

Name: Anonymous 2010-10-13 10:16

>>26
Generalize that shit, good sir, and you have my axe.

Or a vector.

Name: Anonymous 2010-10-13 11:57

To write less. Do you like Java? Me neither.

Name: Anonymous 2010-10-13 15:05

>>1
Because a cons cell is not really a list with first and last elements. west and east would have been better names.

Name: Anonymous 2010-10-13 18:22

>>32
cadr, cdar, caddr, and friends
weeast, eawest, weeaeast, etc...

Name: Anonymous 2010-10-13 18:24

>>32
Wouldn't it be a little awkward if the orientation of your computer changed program semantics?

Name: Anonymous 2010-10-13 18:36

>>34
All real programmers program facing Mecca.

Name: Anonymous 2010-10-13 18:38

>>35
but the position of Mecca is relative the programmer's location

Name: Anonymous 2010-10-13 18:59

>>35
Hello, Fouad Teniou.

Name: Anonymous 2010-10-13 21:09

>>37
*F.O.A.D. Teniou

Name: Anonymous 2010-10-13 21:11

>>38
No.

Name: Anonymous 2010-10-13 21:37

>>39
FOAD.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List