Skip to content

Commit 02a0802

Browse files
committed
Fix inconsistent behavior of range function
1 parent 666ff59 commit 02a0802

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Data/List.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ infix 8 ..
135135

136136
-- | Create a list containing a range of integers, including both endpoints.
137137
range :: Int -> Int -> List Int
138-
range start end | start == end = Nil
138+
range start end | start == end = singleton start
139139
| otherwise = go end start (if start > end then 1 else -1) Nil
140140
where
141141
go s e step tail | s == e = (Cons s tail)

src/Data/List/Lazy.purs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ singleton a = cons a nil
159159

160160
-- | Create a list containing a range of integers, including both endpoints.
161161
range :: Int -> Int -> List Int
162-
range start end | start == end = nil
162+
range start end | start == end = singleton start
163163
| otherwise = go end start (if start > end then 1 else -1) nil
164164
where
165165
go s e step tail | s == e = (cons s tail)

0 commit comments

Comments
 (0)