This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addAuthor a (Book b as) = Book b ((createAuthor a [b]):as) | |
addBook b (Author a bs) = Author a ((createBook b [a]):bs) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clarke = createAuthor "Arthur C. Clarke" ["Garden of Rama"] | |
lee = createAuthor "Gentry Lee" ["Garden of Rama"] | |
gardenAuthorsAccordingToClarke = map name $ authors $ head $ books clarke | |
-- ["Arthur C. Clarke"] | |
gardenAuthorsAccordingToLee = map name $ authors $ head $ books lee | |
-- ["Gentry Lee"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fac n = foldr (*) 1 $ take n $ [1..] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infixl 9 ==> | |
f ==> g = g $ f |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fac n = [1..] ==> take n ==> foldr (*) 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Library | |
(Author, | |
Book, | |
AuthorIndex, | |
BookIndex, | |
Catalogued, | |
Catalog, | |
addAuthor, | |
addBook, | |
associate, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
infixl 9 ==> | |
f ==> g = g $ f | |
lee = Author "Gentry Lee" | |
clarke = Author "Arthur C. Clarke" | |
heinlein= Author "Robert Heinlein" | |
rama = Book "Garden of Rama" | |
catalog = | |
Catalog Map.empty Map.empty ==> | |
associate lee rama ==> |