Added 'Haskell/7.hs'
This commit is contained in:
26
Haskell/7.hs
Normal file
26
Haskell/7.hs
Normal file
@ -0,0 +1,26 @@
|
||||
sum' :: [Int] -> Int
|
||||
sum' [] = 0
|
||||
sum' (x:xs) = x + sum' xs
|
||||
|
||||
last' :: [Int] -> Int
|
||||
last' [] = undefined
|
||||
last' [x] = x
|
||||
last' (x:xs) = last' xs
|
||||
|
||||
and' :: [Bool] -> Bool
|
||||
and' [] = True
|
||||
and' (x:xs) = x && and' xs
|
||||
|
||||
-- repeat' ::
|
||||
repeat' a = [a, a..]
|
||||
|
||||
--replicate' x [y] =
|
||||
-- if x > 0
|
||||
-- then []
|
||||
-- else undefined
|
||||
|
||||
insert' y [] = [y]
|
||||
insert' y (x:xs) =
|
||||
if y < x
|
||||
then y : x : xs
|
||||
else x : insert' y xs
|
Reference in New Issue
Block a user