repeated :: Int -> [Int] -> Int
repeated y [] = 0
repeated y (x:xs)
| y == x = 1+(repeated y xs)
| otherwise = repeated y xs
Haskell中使用contador 1+funcion
concat' :: [[a]] -> [a]
concat' (x:xs)
| length xs == 0 = x
| otherwise = x ++ (concat' xs)
(x:xs) 既可以表示一个数组,又可以表示数组的嵌套
扩充知识点:
(😃 a -> a -> [a]
(++) [a] -> [a] -> [a]
countProperty :: (a -> Bool) -> (Tree a) -> Int
countProperty f Void = 0
countProperty f (Branch x i d)
| f x = 1+countProperty f i + countProperty f d
| otherwise = countProperty f i + countProperty f d
不需要 f x == True