blob: 1b86ebc1d6ad934c04e11e4b226a4c0e55a05658 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
(.module:
[library
[lux "*"]]
[//
["[0]" order {"+" [Order]}]])
(type: .public (Enum e)
(Interface
(: (Order e) &order)
(: (-> e e) succ)
(: (-> e e) pred)))
(def: .public (range enum from to)
(All (_ a) (-> (Enum a) a a (List a)))
(let [(^open "[0]") enum]
(loop [end to
output {.#End}]
(cond (< end from)
(recur (pred end) {.#Item end output})
(< from end)
(recur (succ end) {.#Item end output})
... (= end from)
{.#Item end output}))))
|