This works just fine, and as you would expect from Common Lisp:

user=> (cons 1 '())
(1)

Clojure does not have improper lists as Scheme and Common Lisp allow.  You 
can't have a cons pair of arbitrary pairs of things, but you can create vectors 
of 2 arbitrary things if you want such a pair.

There aren't cons cells in Clojure.  There are lists, and while some are 
implemented via things that look a lot like cons pairs under the covers, some 
are not (e.g. chunked sequences are implemented differently, I think).  They 
still act like ordered sequences using the functions available to access them, 
and most of the time there isn't much reason to care how it is implemented 
under the covers.

There is no mutation on the lists, either.  That is a much bigger difference 
from Common Lisp and Scheme to Clojure.  Most Clojure data structures are 
immutable.  No (setf (car my-list) ...).  No setf.  Instead you make new data 
structures that are like existing ones, but with changes to them (like a new 
first/last element, or a new key/value pair in a map).

Andy

On Oct 17, 2012, at 11:16 AM, Curtis wrote:

> Cons seems to be strange
> 
> How do i use Cons with an atom to make a list?
> 
> (cons 1 1) 
> 
> 
> On Tuesday, October 16, 2012 5:08:26 PM UTC-7, Baishampayan Ghose wrote:
> `car` is called `first` here and `cdr` could mean either `rest` or 
> `next` depending on what you mean/need. 
> 
> And oh, `cons` is not exactly the same one from Common Lisp, etc. 
> 
> Regards, 
> BG 
> 
> On Tue, Oct 16, 2012 at 3:40 PM, Curtis <cur...@ram9.cc> wrote: 
> > Hello - I was familar with lisp years ago and am very new to clojure. 
> > 
> > I am having a hard time understanding how to find 'car' and 'cdr'. 
> > 
> > The nice thing about these functions is they always seem to be a part of 
> > lisp. 
> > 
> > I would like to use the little lisper to teach lisp to my co-workers so 
> > that 
> > we can adopt Clojure. 
> > 
> > How can i import cdr or car? 
> > 
> > I know i can write these manually  or alias them to 'first' and 'rest' - 
> > are 
> > they a part of the language? 
> > 
> > Cons appears to be around. 
> > 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@googlegroups.com 
> > Note that posts from new members are moderated - please be patient with 
> > your 
> > first post. 
> > To unsubscribe from this group, send email to 
> > clojure+u...@googlegroups.com 
> > For more options, visit this group at 
> > http://groups.google.com/group/clojure?hl=en 
> 
> 
> 
> -- 
> Baishampayan Ghose 
> b.ghose at gmail.com 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to