Created
June 13, 2018 15:46
-
-
Save kyledinh/b1929064e909e6450ad97e00c91f25c8 to your computer and use it in GitHub Desktop.
Elm on the command line
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
module IsEven exposing (output) | |
import List | |
getFirstArg : List String -> String | |
getFirstArg list = | |
case List.head list of | |
Nothing -> | |
"0" | |
Just val -> | |
val | |
isEven : Int -> Bool | |
isEven num = | |
num % 2 == 0 | |
output : List String -> String | |
output args = | |
getFirstArg args | |
|> String.toInt | |
|> Result.withDefault 0 | |
|> isEven | |
|> toString | |
{-- run-elm IsEven.elm 23 --} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment