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.