Where is the tail position in my Clojure loop?

后端 未结 2 1547
梦如初夏
梦如初夏 2021-01-23 20:33

Clojure is saying that I can\'t call recur from a non-tail-position.

Is this not the tail position?

What is the tail position in my loop th

2条回答
  •  孤独总比滥情好
    2021-01-23 21:10

    for does not do what you think it does; it is not an imperative loop. It is a list comprehension, or sequence-generator. Therefore, there is not a return or iterate call at its end, so you cannot place recur there.

    It would seem you probably do not need either loop or recur in this expression at all; the for is all you need to build a sequence, but it's not clear to me exactly what sequence you wish to build.

提交回复
热议问题