Skip to content

A peer-to-peer stack for code collaboration

457 B
Raw Blame
{:module 'prelude/list
 :doc "Functions for creating lists. See also `prelude/seq`."
 :exports '[nil range]}


(import prelude/basic :unqualified)
(import prelude/bool :unqualified)

(def nil "The empty list." (list))


(def-rec range
  "Returns a list with all integers from `from` to `to`, inclusive."
  (fn [from to]
    (if (eq? from to)
        (list to)
        (cons from (range (+ 1 from) to)))))

(:test "range"
  [ (range 1 5) ==> (1 2 3 4 5) ]
)