[plt-scheme] Beginner Question

From: vishal sodani (vishalsodani at gmail.com)
Date: Mon Oct 5 01:56:34 EDT 2009

thanks for the clarification.understood!

On Mon, Oct 5, 2009 at 1:56 AM, Carl Eastlund <carl.eastlund at gmail.com> wrote:
> On Sun, Oct 4, 2009 at 1:34 AM, vishy <vishalsodani at gmail.com> wrote:
>> Why (cons (list 1 2) (list 5 3)), produces
>> ((1,2) 5 3) and not ((1,2),(5, 3)) thats is a list of 2 elements .
>>
>> thanks
>
> Vishy,
>
> The cons procedure adds an element to a list.  If you run (cons 1
> (list 2 3)), you add the element 1 to (list 2 3) and get (list 1 2 3).
>  If you run (cons (list 1 2) (list 5 3)), you add (list 1 2) as an
> element, and get (list (list 1 2) 5 3)).  If your intent is to join
> the elements of two lists, the appropriate function is append.
> Running (append (list 1 2) (list 5 3)) will give you (list 1 2 5 3).
> Both methods of combination, cons and append, have their uses, so be
> careful to always choose the one you mean.
>
> --Carl
>



-- 
http://vishalsodani.wordpress.com


Posted on the users mailing list.