Last active
December 25, 2015 03:09
-
-
Save thomwiggers/6907727 to your computer and use it in GitHub Desktop.
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
foldr :: (a b -> b) b [a] | |
foldr op e [] = e | |
foldr op e (x:xs) = op x (foldr op e xs) | |
foldr op 0 [1,2] = op 1 (foldr op 0 [2]) | |
= op 1 (op 2 (foldr op 0 [])) | |
= op 1 (op 2 0) | |
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
Start = fiets a b | |
fiets = max -- max is een functie die van twee argumenten de grootste pakt | |
--Herschrijfschema: | |
Start = fiets a b | |
= max a b | |
--Nu met argumenten voor fiets: | |
fiets a b = max | |
Start = fiets a b | |
= max |
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
VoorbeeldMetIf :: Bool -> String | |
VoorbeeldMetIf voorwaarde = if voorwaarde "AlsVoorwaardeTrueWordtDitUitgevoerd" "AlsVoorwaardeFalsewordtDitUitgevoerd" | |
-- met (haskell-stijl) commentaar erbij voor de duidelijkheid | |
VoorbeeldMetIf voorwaarde = if voorwaarde {- then -} "AlsVoorwaardeTrueWordtDitUitgevoerd" {- else -} "AlsVoorwaardeFalsewordtDitUitgevoerd" |
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
takeWhile` :: (a -> Bool) -> [a] -> [a] | |
takeWhile` predicaat lijst = foldr (functie die iets met 'predicaat' doet) 'basecase' lijst |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment