| I've always been frustrated by the conundrum of how to indent calls with non-syms in function position. (def recstring (test s (o start 0))
((afn (i)
(and (< i (len s))
(or (test i)
(self (+ i 1)))))
start))
This works, but it's unsatisfactory. It takes a tad more effort to make sense of the dangling start. But there was never a better way. Now I think I have the answer: clojure's pipe operator! (mac -> (x f)
`(,f ,x))
arc> (-> 3 [* _ 2])
6
As a bonus, it chains beautifully with wart's infix: list.1 -> cons? -> car
=> 1
Anyway, with pipe we now have the option of putting the long, hard-to-read form at the end: (def recstring (test s (o start 0))
(-> start
(afn (i)
(and (< i (len s))
(or (test i)
(self (+ i 1)))))))
Still to do: make it varargs along both dimensions (xs and fs). |