I’m studying clojure but not quite clear on the difference between the :while and :when test:
=> (for [x [1 2 3] y [1 2 3] :while (= (mod x y) 0)] [x y])
([1 1] [2 1] [2 2] [3 1])
=> (for [x [1 2 3] y [1 2 3] :when (= (mod x y) 0)] [x y])
([1 1] [2 1] [2 2] [3 1] [3 3])
Can anybody help by elaborating on them ?
:wheniterates over the bindings, but only evaluates the body of the loop when the condition is true.:whileiterates over the bindings and evaluates the body until the condition is false: