July 25, 2015
Test
Placeholder
Clojure:
(defmacro success->
"When (success? expr) is truthy, threads it into the first form (via ->),
and when (success? that result) is truthy, through the next etc"
[expr & forms]
(let [g (gensym)
pstep (fn [step] `(if (success? ~g) (-> ~g ~step) ~g))]
`(let [~g ~expr
~@(interleave (repeat g) (map pstep forms))]
~g)))
and some Elm:
prod l =
case l of
[] -> 1
h::t -> h * (prod t)