codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
doubleMe x = x + x doubleUs x y = doubleMe x + doubleMe y doubleSmallNumber x = if x > 100 then x else x*2 boomBangs xs = [ if x < 10 then "BOOM!" else "BANG!" | x <- xs, odd x] bmiTell :: (RealFloat a) => a -> a -> String bmiTell weight height | bmi <= skinny = "Underweight" | bmi <= normal = "Normal" | bmi <= fat = "Fat" | otherwise = "Whale" where bmi = weight / height ^ 2 skinny = 18.5 normal = 25.0 fat = 30.0 initials :: String -> String -> String initials (f:_) (l:_) = [f] ++ ". " ++ [l] ++ "." calcBmis :: (RealFloat a) => [(a, a)] -> [a] calcBmis xs = [ w / h ^ 2 | (w, h) <- xs] maximum' :: (Ord a) => [a] -> a maximum' [] = error "비교할 항목이 없습니다" maximum' [x] = x maximum' (x:xs) = max x (maximum' xs) {-maximum' [x,y] = if x > y then x else y-} {-maximum' (x:xs) = if x > y then x else y-} {-where y = maximum' xs-} take' :: (Ord b, bum b) => b -> [a] -> [a] {-take' n xs-} {-| xs == [] = []-} {-| n <= 0 = []-} {-| otherwise = head xs:take (n-1) (tail xs)-}
Private
[
?
]
Run code
Submit