Re: How to test for literal

2011-01-09 Thread Ken Wesson
On Sun, Jan 9, 2011 at 9:23 AM, Stuart Halloway wrote: > Additional corner cases to consider: > > * nil Tricky one. It's clearly atomic in the usual sense; at the same time it can stand in for an empty coll in many cases. I'd call it atomic. > * arrays Nonatomic. Is there an #(instance? X %) te

Re: How to test for literal

2011-01-09 Thread Stuart Halloway
>> Basically, I want the clojure equivalent of a clisp atom. >> In clisp, atom is true for everything that is not a cons cell. >> The closest match I found is creating a macro that returns true for >> everything that is not a list: >> clisp: >> >> (atom 1) => true >> (atom '(1 2 3)) => false >>

Re: How to test for literal

2011-01-08 Thread Ken Wesson
On Sat, Jan 8, 2011 at 9:15 PM, Andreas Kostler wrote: > Basically, I want the clojure equivalent of a clisp atom. > In clisp, atom is true for everything that is not a cons cell. > The closest match I found is creating a macro that returns true for > everything that is not a list: > clisp: > > (

Re: How to test for literal

2011-01-08 Thread Andreas Kostler
Basically, I want the clojure equivalent of a clisp atom. In clisp, atom is true for everything that is not a cons cell. The closest match I found is creating a macro that returns true for everything that is not a list: clisp: (atom 1) => true (atom '(1 2 3)) => false I hope that makes things

Re: How to test for literal

2011-01-08 Thread Ken Wesson
On Sat, Jan 8, 2011 at 7:25 PM, Andreas Kostler wrote: > Ken, > Thanks for your reply. Is that about what you mean? > > (defmacro literal? [form] >  (list 'if `(not (list? ~form)) true false)) Sort of, but that isn't quite going to work. It will expand to (if (clojure.core/not (clojure.core/list

Re: How to test for literal

2011-01-08 Thread Andreas Kostler
Ken, Thanks for your reply. Is that about what you mean? (defmacro literal? [form] (list 'if `(not (list? ~form)) true false)) Andreas On 09/01/2011, at 8:59 AM, Ken Wesson wrote: > On Sat, Jan 8, 2011 at 6:49 PM, Andreas Kostler > wrote: >> Hello again, >> How do I test for a literal? The

Re: How to test for literal

2011-01-08 Thread Ken Wesson
On Sat, Jan 8, 2011 at 6:49 PM, Andreas Kostler wrote: > Hello again, > How do I test for a literal? There are predicates for symbols and > keywoards etc: > symbol?, keyword? > Is there an equivalent for literals...like literal? Not at runtime. At macroexpansion time you can use list? and that's