1

Is there a clojure function that can be called in a loop with feeding it with the result of the previous call?

Pseudo-code might be look like this:

currentValue = firstValue;
while (endNotYetReached(currentValue)) {
  currentValue = myFunction(currentValue);
}

Thank you for every answer!

1 Answer 1

5

You can use iterate, which returns an infinite lazy sequence, from which you can take, drop, etc:

=> (take 3 (iterate inc 5))
(5 6 7)
Sign up to request clarification or add additional context in comments.

1 Comment

That's what I searched for. Thank you very much!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.