cons

Started by eddier, December 19, 2003, 01:39:10 PM

Previous topic - Next topic

eddier

Would it be hard to make (cons take multiple arguments?



Example



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



Eddie

HPW

#1
Why not?



(list 'a 'b 'c)
Hans-Peter

Sammo

#2
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'?

Lutz

#3
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

eddier

#4
Your right! I wasn't thinking functionally (at all) Friday.



dunce Eddie

HPW

#5
>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.
Hans-Peter

Lutz

#6
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