diff options
author | Eduardo Julian | 2015-09-06 01:03:19 -0400 |
---|---|---|
committer | Eduardo Julian | 2015-09-06 01:03:19 -0400 |
commit | 455018ec68f2c127db489048351bc48f3982fe23 (patch) | |
tree | eeedcea7b210e4c12ccdedf4fec448e23686aabc /source/lux/control/enum.lux | |
parent | 9acccd0847d6bb28e706223439eb44e5a3fe9aff (diff) |
- Expanded the standard library.
- Fixed some minor bugs.
- Added the updated code for the parser (forgot to add it to a previous commit).
Diffstat (limited to 'source/lux/control/enum.lux')
-rw-r--r-- | source/lux/control/enum.lux | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/source/lux/control/enum.lux b/source/lux/control/enum.lux new file mode 100644 index 000000000..34910c837 --- /dev/null +++ b/source/lux/control/enum.lux @@ -0,0 +1,25 @@ +## Copyright (c) Eduardo Julian. All rights reserved. +## 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 http://mozilla.org/MPL/2.0/. + +(;import lux + (lux/control ord)) + +## [Signatures] +(defsig #export (Enum e) + (: (Ord e) _ord) + (: (-> e e) succ) + (: (-> e e) pre)) + +## [Functions] +(def #export (range' <= succ from to) + (All [a] (-> (-> a a Bool) (-> a a) a a (List a))) + (if (<= from to) + (#;Cons from (range' <= succ (succ from) to)) + #;Nil)) + +(def #export (range enum from to) + (All [a] (-> (Enum a) a a (List a))) + (using enum + (range' <= succ from to))) |