"nicolas.o...@gmail.com" <nicolas.o...@gmail.com> writes: Hi Nicolas,
> What is the meaning of :while in a for? > I understand :when, and also that :while jumps more element when the > condition is not met, Yes. With :when every combination is checked, whereas with :while, the remaining combinations are skipped if it is falsy. > but where does it jump to exactly? Good question. I think it skips the preceeding binding form. At least, that's what I can infer from some examples. (for [x [1 2 3] y [1 2 3] :while (<= x y) z [1 2 3]] [x y z]) ;=> ([1 1 1] [1 1 2] [1 1 3] ; [1 2 1] [1 2 2] [1 2 3] ; [1 3 1] [1 3 2] [1 3 3]) So when we hit [2 1 _] which is false, the 2 and 3 for y are skippd. Thus the next binding is [3 1 _] which is false again. And there are no more. (for [x [1 2 3] y [1 2 3] z [1 2 3] :while (<= x y)] [x y z]) ;=> ([1 1 1] [1 1 2] [1 1 3] ; [1 2 1] [1 2 2] [1 2 3] ; [1 3 1] [1 3 2] [1 3 3] ; [2 2 1] [2 2 2] [2 2 3] ; [2 3 1] [2 3 2] [2 3 3] ; [3 3 1] [3 3 2] [3 3 3]) Here, as soon as we hit [2 1 1] which is false, the remainders of z are skipped leading to [2 2 1] which is true again. Next we hit [3 1 1] which is false, so we skip to [3 2 1] which is false again, so we skip to [3 3 1] which is true again. HTH, Tassilo -- 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