Written by
Aaron Bell
on
on
Working example of Clojure's new `iteration` function
My example:
(def example-data {:a {:next-token :b
:val "A"}
:b {:next-token :c
:val "B"}
:c {:next-token :d
:val "C"}
:d {:val "D"}}) ; No token, so `iteration` will end.
(vec (iteration
(fn [token]
(get example-data token))
:initk :a
:kf :next-token
:vf :val))
I find this simpler and self-evident in how it’s used vs. the AWS example and the .readLine
test example given so far. Even though there’s other examples in the tests for iteration
, the .readLine
example is the simplest.