Page 1 of 1

cons

Posted: Fri Dec 19, 2003 9:39 pm
by eddier
Would it be hard to make (cons take multiple arguments?

Example

(cons 'a 'b 'c) => (a b c)

Eddie

Posted: Fri Dec 19, 2003 9:47 pm
by HPW
Why not?

(list 'a 'b 'c)

Posted: Fri Dec 19, 2003 9:49 pm
by Sammo
In newLISP, isn't 'list' basically the same as 'cons' but allowing an arbitray number of args? Is so, can you (setq mycons list) and then (mycons 'a 'b 'c), or perhaps use (constant cons list) in the appropriate context to reassign 'cons'?

Posted: Sat Dec 20, 2003 12:04 am
by Lutz
I agree with Sam: 'cons' with multiple args for 'cons' is like using 'list' , also
'cons' is also a lot like 'push' becuase it can take a list as the second argument:

(set 'lst '(b c))

(cons 'a lst) => (a b c)

(push 'a lst) => 'a

lst => (a b c)

the difference beeing, that push is non-destructive and returns the new list, while push has the side effect of changing the list.

If it where for me, I would just dump 'cons', because I think having 'list' and 'push', you got all you ever need, but ... there are many traditional LISPers who wouldn't want to 'lisp' without it. Personally, I think, I never have used it.

Lutz

Posted: Mon Dec 22, 2003 2:20 pm
by eddier
Your right! I wasn't thinking functionally (at all) Friday.

dunce Eddie

Posted: Mon Dec 22, 2003 2:44 pm
by HPW
>there are many traditional LISPers who wouldn't want to 'lisp' without it.

Yes, the alisp people are such people.
When it does not hurt, let it as it is.

Posted: Mon Dec 22, 2003 5:37 pm
by Lutz
Yes 'cons' stays. The advantage of most of the traditional LISP functions is, that they can be implemented with very little code, so it doesn't save much, when they are thrown out.

Lutz