Hi,
On 29 Okt., 12:11, andrei <[email protected]> wrote:
> > You could just bind another local variable in the loop form:
> > (loop [ps pairs
> > ret {}
> > ffps (ffirst ps)]
> > (cond (empty? ps) ret
> > (some-test ffps) (recur (rest ps) (add-to-result ret ffps) (ffirst
> > (rest ps)))
> > :true (recur (rest ps) (do-sth-else ret ffps) (ffirst (rest ps)))) )
>
> In this case you have to pass one more parameter to each loop
> iteration, and since you actually don't need this param, that breaks
> loop's semantics.
There's nothing stoping you to put a let in a loop.
(loop [ps (seq pairs)
ret {}]
(let [ffps (ffirst ps)]
(cond
(not ps) ret
(some-test ffps) (recur (next ps) (add-to-result ret ffps))
:else (recur (next ps) (do-sth-else ret ffps)))))
Sincerely
Meikel
--
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