tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
|
|
@ -0,0 +1,5 @@
|
|||
data Tree a = Empty | Node a (Tree a) (Tree a)
|
||||
|
||||
mapTree :: (a -> b) -> Tree a -> Tree b
|
||||
mapTree f Empty = Empty
|
||||
mapTree f (Node x l r) = Node (f x) (mapTree f l) (mapTree f r)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
instance Functor Tree where
|
||||
fmap f Empty = Empty
|
||||
fmap f (Node x l r) = Node (f x) (fmap f l) (fmap f r)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
add1Everywhere :: (Functor f, Num a) => f a -> f a
|
||||
add1Everywhere nums = fmap (\x -> x + 1) nums
|
||||
Loading…
Add table
Add a link
Reference in a new issue