tests/Haskell/7.hs
2024-07-22 19:39:19 +02:00

27 lines
402 B
Haskell

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