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

LISP: A dynamic car

Name: Anonymous 2012-01-30 20:27

I have a complex list of lists and want something to check the second element of every list of the list in the loop, any supported features like this?

Name: Anonymous 2012-01-31 20:49

>>35
A dot is used to denote an improper list in most Lisps:
(cons 'a 'b) -> (A . B)

In this case, it binds the first 2 elements of the list to first and relation, then it binds the cdr (rest[of the list]) to rest. When a list is used within the place of some variable binding in LOOP, what actually happens is that a destructuring-bind is used instead to bind multiple variables, thus this lets you loop over lists of lists and do a destructuring-bind of the elements of each inner list. After doing that it just pushes each relation into the hashtable... push is basically a modify macro for cons - it sets the generic place that was indicated (some place in the hashtable), with the value it had before and a new value cons'd on top of it. Like:
(push place value) is like writing (setf place (cons value place)), where place is a generic place and all the expansion and necessary fluff is handled transparently for you.

If you didn't understand my explanation, just look up what you don't understand in the Hyperspec (HTML/hypertext version of the ANSI CL standard), it's pretty comprehensive (although, you shouldn't really learn Lisp using only it(it'll be too much effort), like most people shouldn't learn some new language by only reading the reference).

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