blob: b93f84ce5eccbc77589cf5c17365ac15c9b20439 (
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
26
27
28
29
|
... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
(.require
[library
[lux (.except)]]
[//
["[0]" order (.only Order)]])
(type .public (Enum e)
(Interface
(is (Order e) order)
(is (-> e e) succ)
(is (-> e e) pred)))
(def .public (range enum from to)
(All (_ a) (-> (Enum a) a a (List a)))
(let [(open "/#[0]") enum]
(loop (again [end to
output (`` (is (List (,, (type_of from)))
{.#End}))])
(cond (/#< end from)
(again (/#pred end) {.#Item end output})
(/#< from end)
(again (/#succ end) {.#Item end output})
... (= end from)
{.#Item end output}))))
|