diff --git a/src/Data/List.purs b/src/Data/List.purs index a4eb084..c7f147d 100644 --- a/src/Data/List.purs +++ b/src/Data/List.purs @@ -135,7 +135,7 @@ infix 8 .. -- | Create a list containing a range of integers, including both endpoints. range :: Int -> Int -> List Int -range start end | start == end = Nil +range start end | start == end = singleton start | otherwise = go end start (if start > end then 1 else -1) Nil where go s e step tail | s == e = (Cons s tail) diff --git a/src/Data/List/Lazy.purs b/src/Data/List/Lazy.purs index f78904d..a1c55e3 100644 --- a/src/Data/List/Lazy.purs +++ b/src/Data/List/Lazy.purs @@ -159,7 +159,7 @@ singleton a = cons a nil -- | Create a list containing a range of integers, including both endpoints. range :: Int -> Int -> List Int -range start end | start == end = nil +range start end | start == end = singleton start | otherwise = go end start (if start > end then 1 else -1) nil where go s e step tail | s == e = (cons s tail)