Common Lisp style loops in Clojure
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
README Vaguely less trivial example. Sep 7, 2009
cl-loop.clj Using atom instead of var, within collectors. Sep 10, 2009
lessons.markdown More lessons Sep 8, 2009


[Excuse me while I get the hang of this Github thing.]

v0.1 ALPHA. The API may change at any time.

 *   cl-loop
 *   Copyright (c) Tayssir John Gabbour. All rights reserved.
 *   The use and distribution terms for this software are covered by the
 *   Eclipse Public License 1.0 (
 *   which can be found in the file epl-v10.html at the root of this distribution.
 *   By using this software in any fashion, you are agreeing to be bound by
 *    the terms of this license.
 *   You must not remove this notice, or any other, from this software.

Simple examples:

(cl-loop for x [1 2 3]
         collect x)
=> [1 2 3]

(cl-loop for [k v] {:a 1, :b 2}
         set v2 (inc v)
         concat [k v2])
=> [:a 2 :b 3]

Wilder examples:

(cl-loop for letters     [:a :b :c :d :e :f]
         for whole-nums  (iterate inc 1)
         set mults-of-10 (* 10 whole-nums)
         (if (odd? whole-nums)
           (if (odd? whole-nums)
             [collect letters]
             [collect mults-of-10])
           (if true
             (if (even? whole-nums)
               [collect mults-of-10]
               [collect letters]))))
=> [:a 20 :c 40 :e 60]