Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-15 Thread Tassilo Horn
"Jim - FooBar();" writes: >>> Yes. A correct version is >>> >>> (defn in? [coll e] >>>(some (partial = e) coll)) >> >> If just wrapping 'some' I think this is easier to read >> >> (defn in? [coll e] >> (some #{e} coll)) >> >> thanks for your time :-) > > sorry...you mea

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-15 Thread Jim - FooBar();
On 15/06/12 10:47, Jim - FooBar(); wrote: On 15/06/12 07:27, Tassilo Horn wrote: "Jim - FooBar();" writes: nice catch and point taken... however the exact same thing would happen if this was a function...it's just wrong ! Yes. A correct version is (defn in? [coll e] (some (par

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-15 Thread Jim - FooBar();
On 15/06/12 07:27, Tassilo Horn wrote: "Jim - FooBar();" writes: nice catch and point taken... however the exact same thing would happen if this was a function...it's just wrong ! Yes. A correct version is (defn in? [coll e] (some (partial = e) coll)) Bye, Tassilo If just w

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread Tassilo Horn
"Jim - FooBar();" writes: > nice catch and point taken... > > however the exact same thing would happen if this was a > function...it's just wrong ! Yes. A correct version is (defn in? [coll e] (some (partial = e) coll)) Bye, Tassilo -- You received this message because you are su

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread Stuart Halloway
(doc boolean) Cheers, Stu Stuart Halloway Clojure/core http://clojure.com > >> (defmacro in? > >> "Returns true if colle contains elm, false otherwise." > >> [colle elm] > >> `(if (some #{~elm} ~colle) true false)) > > Yes. Should not be a macro. (There is no reason for it to be a macro). >

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread Jim - FooBar();
nice catch and point taken... however the exact same thing would happen if this was a function...it's just wrong ! Jim On 14/06/12 19:32, Tassilo Horn wrote: "Jim - FooBar();" writes: (defmacro in? "Returns true if colle contains elm, false otherwise." [colle elm] `(if (some #{~elm}

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread Tassilo Horn
"Jim - FooBar();" writes: > (defmacro in? > "Returns true if colle contains elm, false otherwise." > [colle elm] > `(if (some #{~elm} ~colle) true false)) Except for the complains that this doesn't need to be a macro (which I agree with), it is also wrong. user> (in? [nil false] nil)

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread Jim - FooBar();
I have a functionize macro if I ever want to do that with a macro but I think we are getting off topic here... all I'm saying is that if I want to keep a loop very tight and want to perform a couple of checks inline, why clutter the body of the loop with 'if's or 'some's or whatever...you want

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread nicolas.o...@gmail.com
> > >> why add the extra overhead of potentially boxing/unboxing x in such a > simple case? Its not like the macro is getting out of control...Its a one > liner... > > Because functions are first class and not macros. Ex: (map to-bool l) -- You received this message because you are subscribed to

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread Jim - FooBar();
On 14/06/12 18:20, nicolas.o...@gmail.com wrote: (defn to-bool [x] (if x true false)) and use it when necessary. why add the extra overhead of potentially boxing/unboxing x in such a simple case? Its not like the macro is getting out of control...Its a one liner... Jim -- You received t

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread nicolas.o...@gmail.com
On Thu, Jun 14, 2012 at 6:19 PM, Jim - FooBar(); wrote: > I don't see why not if you really really need to return true/false... > Because it can be written as a function. Macro are only for things that cannot be easily written as functions. (And then it should be backed by functions that are usa

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread nicolas.o...@gmail.com
>> (defmacro in? >> "Returns true if colle contains elm, false otherwise." >> [colle elm] >> `(if (some #{~elm} ~colle) true false)) Yes. Should not be a macro. (There is no reason for it to be a macro). On top of that, it is not very often useful to convert nil to false as clojure understands n

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread Jim - FooBar();
I don't see why not if you really really need to return true/false... Of course as Tassilo said nil is falsey so it is unlikely that you would ever need to do that... Jim On 14/06/12 18:16, David Nolen wrote: Definitely something that should not written as a macro :) David On Thu, Jun 14, 2

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread David Nolen
Definitely something that should not written as a macro :) David On Thu, Jun 14, 2012 at 1:14 PM, Jim - FooBar(); wrote: > you can always make your own with a little macro but if you just started > learning today you may want to stick with some... > > I, like you, wanted a version that returns

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread Jim - FooBar();
you can always make your own with a little macro but if you just started learning today you may want to stick with some... I, like you, wanted a version that returns true or false a couple of months ago.. here it is: (defmacro in? "Returns true if colle contains elm, false otherwise." [coll

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread Jacobo Polavieja
Thank you both! I had the epiphany now and realized it is what you both stated. But you had already answered! So quick :). I think I've tried too run too much and have read through too fast. All morning setting up Clojure and learning Clojure. It's fun but my brain may now need some rest... Th

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread Tassilo Horn
Jacobo Polavieja writes: Hi Jacobo, > (not-every? #(instance? String %) stooges) ; -> false > (some #(instance? Number %) stooges) ; -> nil > > Is there a reason why (some) doesn't return false also? `some` is no predicate (else it would have a ? appended). It simply returns the first truthy (

Re: Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread David Nolen
not-every? is a predicate (note the ?) some is not. On Thu, Jun 14, 2012 at 11:31 AM, Jacobo Polavieja < jacobopolavi...@gmail.com> wrote: > Hi! > > I've just started learning Clojure today. I've started reading "Clojure - > Functional Programming for the JVM" ( > http://java.ociweb.com/mark/clo

Is there a reason why 'some' returns "nil" instead o "false"?

2012-06-14 Thread Jacobo Polavieja
Hi! I've just started learning Clojure today. I've started reading "Clojure - Functional Programming for the JVM" ( http://java.ociweb.com/mark/clojure/article.html ). Anyway, on the collections part ( http://java.ociweb.com/mark/cloj