evens? is not a macro, therefore when you do (evens? (println “one”)), the 
println will be evaluated first, and its return value, nil, gets passed into 
the evens function. 


20 Σεπ 2018, 5:44 μμ, ο χρήστης «Stephen Feyrer <stephen.fey...@gmail.com>» 
έγραψε:

> Hi,
> 
> I have just been playing around with this idea and I got something.
> 
> user=> (def some-numbers ‘(2 4 6 8))  #This is my value to test later.
> #’user/some-numbers
> user=> (def evens? (partial (when (apply = (map even? some-numbers)))))
> #’user/evens?
> user=> (evens? (println “one”))
> one
> NullPointerException   user/eval239 (NO_SOURCE_FILE:74)
> user=> 
> 
> What is my mistake?
> 
> Thanks.
> 
> 
>> On 12 December 2017 at 07:52, Stephen Feyrer <stephen.fey...@gmail.com> 
>> wrote:
>> Hi Tim,
>> 
>> Thank you.
>> 
>> 
>> --
>> Kind regards
>> 
>> Stephen.
>> 
>>> On 11 December 2017 at 23:58, Timothy Baldridge <tbaldri...@gmail.com> 
>>> wrote:
>>> I talked a bit about this in my video on Boolean Blindness: 
>>> https://www.youtube.com/watch?v=K1LaaJMscCc
>>> 
>>> Might be worth a watch. 
>>> 
>>>> On Mon, Dec 11, 2017 at 4:56 PM, Stephen Feyrer <stephen.fey...@gmail.com> 
>>>> wrote:
>>>> Hi there,
>>>> 
>>>> I have been trying to shake this thought for a while now.  Essentially, my 
>>>> thought was if you can return a function why not decision component of an 
>>>> IF, WHEN or SOME statement?  That would give you a re-usable named choice.
>>>> 
>>>> Then you could write:
>>>> 
>>>> (celebration: do-something do-something-else)
>>>> 
>>>> 
>>>> This would be equivalent to writing:
>>>> 
>>>> (def success [apples bananas pears])
>>>> 
>>>> (defn celebration: [x y] (if (empty? success) x y))
>>>> 
>>>> (celebration: (do-something do-something-else))
>>>> 
>>>> 
>>>> I'm reasonably certain of the foolishness of this thought but 
>>>> occasionally, I have doubts.
>>>> 
>>>> Maybe I'm barking up the wrong tree or possibly I've seen something like 
>>>> this before and forgotten about it.  Perhaps, this is just taking things 
>>>> too far...  Either way, it's deferring the choice until it's needed.  In 
>>>> the right hands it could make for more readable code.
>>>> 
>>>> For completeness sake, to define the first form above you'd use:
>>>> 
>>>> (defc celebration: (if (empty? success)))
>>>> 
>>>> 
>>>> A more usable example might look like:
>>>> 
>>>> (def nums [1 2 3 4 5 6 7 8])
>>>> 
>>>> (defc even-nums: (some (even? nums)))
>>>> 
>>>> I guess this makes the real question, is it a good thing to be able to 
>>>> defer choice like this?
>>>> 
>>>> 
>>>> Btw, defc would be like def-choice but other options might be deft - 
>>>> def-test or defp - def-predicate.
>>>> 
>>>> 
>>>> --
>>>> Kind regards
>>>> 
>>>> Stephen
>>>> -- 
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Clojure" group.
>>>> To post to this group, send email to clojure@googlegroups.com
>>>> Note that posts from new members are moderated - please be patient with 
>>>> your first post.
>>>> To unsubscribe from this group, send email to
>>>> clojure+unsubscr...@googlegroups.com
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/clojure?hl=en
>>>> --- 
>>>> You received this message because you are subscribed to the Google Groups 
>>>> "Clojure" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>>> email to clojure+unsubscr...@googlegroups.com.
>>>> For more options, visit https://groups.google.com/d/optout.
>>> 
>>> 
>>> 
>>> -- 
>>> “One of the main causes of the fall of the Roman Empire was that–lacking 
>>> zero–they had no way to indicate successful termination of their C 
>>> programs.”
>>> (Robert Firth)
>>> -- 
>>> You received this message because you are subscribed to the Google
>>> Groups "Clojure" group.
>>> To post to this group, send email to clojure@googlegroups.com
>>> Note that posts from new members are moderated - please be patient with 
>>> your first post.
>>> To unsubscribe from this group, send email to
>>> clojure+unsubscr...@googlegroups.com
>>> For more options, visit this group at
>>> http://groups.google.com/group/clojure?hl=en
>>> --- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Clojure" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to clojure+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to