What is the difference between :while and :when in clojure?

后端 未结 3 591
闹比i
闹比i 2021-02-07 08:34

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          


        
3条回答
  •  忘了有多久
    2021-02-07 08:59

    :when prevents any inner 'for' bindings or its body expression from being evaluated for that one iteration, acting like the 'filter' function.

    :while halts this binding from proceeding any more, acting more like 'take-while'

提交回复
热议问题