brenden's list function

This commit is contained in:
Stephen Diehl
2016-04-13 16:39:47 -04:00
parent ef52c8d507
commit cbaa117b8a
+6
View File
@@ -5,6 +5,7 @@ module List (
head, head,
ordNub, ordNub,
sortOn, sortOn,
list,
) where ) where
import Data.List (sortBy) import Data.List (sortBy)
@@ -30,3 +31,8 @@ ordNub l = go Set.empty l
if x `Set.member` s if x `Set.member` s
then go s xs then go s xs
else x : go (Set.insert x s) xs else x : go (Set.insert x s) xs
list :: [b] -> (a -> b) -> [a] -> [b]
list def f xs = case xs of
[] -> def
_ -> fmap f xs