Last active
November 2, 2019 18:03
-
-
Save fredcy/5746b0af5ddb3f23f27470f41c883f86 to your computer and use it in GitHub Desktop.
Cartesian product of two lists in Elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Html exposing (text) | |
main = | |
text <| toString <| cartesian ["a", "b", "c"] [1..5] | |
cartesian : List a -> List b -> List (a,b) | |
cartesian xs ys = | |
List.concatMap | |
( \x -> List.map ( \y -> (x, y) ) ys ) | |
xs | |
cartesianExtra xs ys = | |
List.Extra.lift2 (,) xs ys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment