Serie: haskell
haskell
14 líneas
· Actualizado 2026-02-03
exercise_4.hs
haskell/Week_6_Lab/exercise_4.hs
-- Define the myAny function
myAny :: (a -> Bool) -> [a] -> Bool
myAny _ [] = False -- Base case: empty list returns False
myAny f (x:xs)
| f x = True -- If the function evaluates to True for any element, return True
| otherwise = myAny f xs -- Otherwise, check the rest of the list
-- Define the myAll function
myAll :: (a -> Bool) -> [a] -> Bool
myAll _ [] = True -- Base case: empty list returns True
myAll f (x:xs)
| f x = myAll f xs -- If the function evaluates to True for the current element, check the rest
| otherwise = False -- If any element fails the condition, return False
Artículos relacionados
haskell
haskell
Actualizado 2026-02-03
Adding.hs
Adding.hs — haskell source code from the haskell learning materials (haskell/Adding.hs).
Leer artículo →
haskell
haskell
Actualizado 2026-02-03
Area.hs
Area.hs — haskell source code from the haskell learning materials (haskell/Area.hs).
Leer artículo →
haskell
haskell
Actualizado 2026-02-03
Chess.hs
Chess.hs — haskell source code from the haskell learning materials (haskell/Chess.hs).
Leer artículo →
haskell
haskell
Actualizado 2026-02-03
ChessGraphics.hs
ChessGraphics.hs — haskell source code from the haskell learning materials (haskell/ChessGraphics.hs).
Leer artículo →
haskell
haskell
Actualizado 2026-02-03
Examples.hs
Examples.hs — haskell source code from the haskell learning materials (haskell/Examples.hs).
Leer artículo →
haskell
haskell
Actualizado 2026-02-03
Fibonacci.hs
Fibonacci.hs — haskell source code from the haskell learning materials (haskell/Fibonacci.hs).
Leer artículo →