On May 10, 3:19 pm, Jack Moffitt <[email protected]> wrote:
> > (when-let [s (seq coll)]
> > (let [run (cons (first s) (take-while #(not= value (f %)) (next
> > s)))]
> > (cons run (partition-when f value (seq (drop (count run) s))))
> > )
> > )
> > )
> > )
> ...
> > What test?
>
> (seq coll) is the test here. when-let (and if-let, etc) bind only when
> the right hand side is truthy.
>
> (when-let [x true]
> (println "this prints"))
>
> (when-let [x false]
> (println "this does not print"))
>
> It's a common shortcut for:
>
> (let [x (something-something)]
> (when x
> ....))
>
Not quite true in the general case, though. Consider
(let [x 1]
(if-let [x foo]
x ;; should be foo
x)) ;; should be 1
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en