Skip to content

Commit f44f011

Browse files
authored
Merge pull request #115 from LiamGoodacre/fix/snoc
Reimplement snoc with foldr
2 parents feb2f8f + 7a08cd9 commit f44f011

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Data/List.purs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,9 +192,9 @@ length = foldl (\acc _ -> acc + 1) 0
192192

193193
-- | Append an element to the end of a list, creating a new list.
194194
-- |
195-
-- | Running time: `O(2n)`
195+
-- | Running time: `O(n)`
196196
snoc :: forall a. List a -> a -> List a
197-
snoc xs x = reverse (x : reverse xs)
197+
snoc xs x = foldr (:) (x : Nil) xs
198198

199199
-- | Insert an element into a sorted list.
200200
-- |

0 commit comments

Comments
 (0)