list comprehension haskell
list = [1, 2, 3, 4]
evens = [x | x <- list, even x] -- [2, 4]
mul3List = [3*x | x <- list] -- [3, 6, 9, 12]
odds = [3*x | x <- mul3List, odd (3*x)] -- [3, 9]
allCombinations = [(y, x) | x <- list, y <- list] -- [(1, 1), (1, 2) ...
Are there any code examples left?
New code examples in category Haskell
-
Haskell 2022-03-17 03:30:14 string to list haskell
-
Haskell 2022-03-03 09:10:01 list length haskell
-
Haskell 2022-02-27 13:00:37 haskell return false if list empty
-
Haskell 2022-02-24 20:15:24 fibnocci code in haskell language
-
Haskell 2022-02-10 08:55:04 can't do a reify in the IO monad
-
Haskell 2022-01-31 01:20:20 remove nth element from list haskell
-
Haskell 2022-01-29 09:16:12 haskell max function
-
Haskell 2022-01-27 19:51:21 haskell merge lists
-
Haskell 2021-11-15 17:39:17 cabal package from GitHub