You can use recur to build a hierarchy. What do you mean by you can't
use it as it is not the last statement?

I have used recur in all sorts of places in the fn, without noticing
any restrictions, and built hierarchies.

I am no expert so I may have been conforming to the restrictions
accidentally, but the only thing I have ever had to be conscious of is
wrapping my arguments into a vector when recursing a function with &
arity.

On Jun 13, 11:35 am, Oleg <oleg.richa...@gmail.com> wrote:
> Hello Guys!
>
> Here is the task:
>
> Assume that we have function called `fetch-from-source`, which used to
> fetch vector of maps from the data source. I want to make iteration on
> every fetched row (element of vector) and ask `fetch-from-source`
> again to add 'children' key to that row. And so on, until given
> depth.
>
> So i want to use map function on collection from some function `expand-
> groups`, which will call the same function `expand-groups` on every
> collection element to assign children on it. Keep in mind, that the
> map function is not last in my function, because i have to append one
> more row to mapped collection.
>
> Currently i'm just calling function, but there is a danger of
> StackOverflow. I can't use recur, because it's not last statement. As
> i can understand recur is good to build long sequences, but in my case
> i'm building hierarchy.
>
> What do you think guys? Is there are clojure-rish way to solve that
> problem?
>
> Cheers, Oleg

-- 
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

Reply via email to