diff options
Diffstat (limited to 'gen/src/list.erl')
-rw-r--r-- | gen/src/list.erl | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/gen/src/list.erl b/gen/src/list.erl index 36fb42d..85df70e 100644 --- a/gen/src/list.erl +++ b/gen/src/list.erl @@ -1,7 +1,7 @@ -module(list). -compile(no_auto_import). --export([length/1, reverse/1, is_empty/1, contains/2, head/1, tail/1, filter/2, map/2, index_map/2, traverse/2, drop/2, take/2, new/0, append/2, flatten/1, fold/3, fold_right/3, find/2, all/2, any/2, zip/2, intersperse/2, at/2, unique/1, sort/1]). +-export([length/1, reverse/1, is_empty/1, contains/2, head/1, tail/1, filter/2, map/2, index_map/2, traverse/2, drop/2, take/2, new/0, append/2, flatten/1, fold/3, fold_right/3, find/2, all/2, any/2, zip/2, intersperse/2, at/2, unique/1, sort/1, range/2]). length(A) -> erlang:length(A). @@ -298,3 +298,15 @@ sort(List) -> BList = drop(List, SplitLength), merge_sort(sort(AList), sort(BList)) end. + +range(Start, Stop) -> + case int:compare(Start, Stop) of + eq -> + []; + + gt -> + [Start | range(Start - 1, Stop)]; + + lt -> + [Start | range(Start + 1, Stop)] + end. |