Skip to content

Instantly share code, notes, and snippets.

@kyledinh
Created June 13, 2018 15:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kyledinh/b1929064e909e6450ad97e00c91f25c8 to your computer and use it in GitHub Desktop.
Save kyledinh/b1929064e909e6450ad97e00c91f25c8 to your computer and use it in GitHub Desktop.
Elm on the command line
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