At first glance I don't see a clean to make this completely higher-
order, but here's a shorter (albeit a little messy) version:
(loop [a a0]
(let [[a b c d e] (reduce #(conj %1 (%2 (last %1))) [a] [f1 f2 f3
f4])
g (f5 c)
h (-> e f2 f5)]
(if (or (f6? b) (<= g h))
e
(recur (f7 d b)))))
On Dec 15, 11:00 am, samppi <[email protected]> wrote:
> I'm trying to rewrite a loop to use higher-level functions instead.
> For pure functions f1, f2, f3, f4, f5, f6?, and f7, and a Clojure
> object a0, how can one rewrite the following loop to use map, reduce,
> etc.?
>
> (loop [a a0]
> (let [b (f1 a)
> c (f2 b)
> d (f3 c)
> e (f4 d)
> g (f5 c)
> h (-> e f2 f5)]
> (if (or (f6? b) (<= g h))
> e
> (recur (f7 d b)))))
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en