--1 f1 x xs = x : takeWhile (/=x) xs -- f1 :: Eq a => a -> [a] -> [a] f2 g h (x:xs) = [h y | y <- xs, y < g x] -- f2 :: Ord a => (a -> a) -> (a -> b) -> [a] -> [b] f3 [] ys = ys f3 xs ys = xs : ys -- f3 :: [a] -> [[a]] -> [[a]] --2 bloques :: Int -> [a] -> [[a]] bloques n [] = [] bloques n xs = take n xs : bloques n (drop n xs) bloques' n [] = [] bloques' n xs = b1 : bloques' n resto where (b1,resto) = (take n xs, drop n xs) bloques'' n [] = [] bloques'' n xs = b1 : bloques'' n resto where (b1,resto) = splitAt n xs --3 infix :/ data Racional = Int :/ Int deriving Show irred :: Racional -> Racional irred (x :/ y) = (x `div` m) :/ (y `div` m) where m = mcd x y mcd::Int -> Int -> Int mcd x 0 = x mcd x y = mcd y (mod x y) --4 -- (tail . head . zipWith (++) [[1,2],[3]]) [[4],[5,6]] => [2,4] --5 numCeros:: [Int] -> Int numCeros = length . (filter (==0)) --6 crec xs = (and . map (uncurry (<))) (zip xs (tail xs))