Created
October 2, 2015 00:43
-
-
Save motokiee/0d788fc29fa6f9dcb1c5 to your computer and use it in GitHub Desktop.
けさのHaskellの勉強はここまで #CodePiece
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
replicate' :: Int -> a -> [a] | |
replicate' n x | |
| n <= 0 = [] | |
| otherwise = x : (replicate' (n-1) x) | |
maximum' :: (Ord a) => [a] -> a | |
maximum' xs = case xs of [] -> error "maximum of empty list" | |
[x] -> x | |
(x:xs) -> max x (maximum' xs) | |
take' :: Int -> [a] -> [a] | |
take' n _ | |
| n <= 0 = [] | |
take' _ [] = [] | |
take' n (x:xs) = x : take' (n-1) xs | |
reverse' :: [a] -> [a] | |
reverse' [] = [] | |
reverse' (x:xs) = reverse' xs ++ [x] | |
repeat' :: a -> [a] | |
repeat' x = [x] ++ repeat' x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment