Last active
July 18, 2017 13:54
-
-
Save tai2/225f66abbbbe9069f7e9102594ed02c6 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Hello exposing (..) | |
import Html exposing (text) | |
import List exposing (take, drop, head) | |
indexOf : a -> List a -> Int | |
indexOf target list = | |
let | |
f target n list = | |
case head (drop n list) of | |
Just h -> | |
if h == target then | |
n | |
else | |
f target (n + 1) list | |
Nothing -> | |
-1 | |
in | |
f target 0 list | |
main = | |
let | |
i = | |
indexOf "c" [ "a", "b", "c" ] | |
in | |
text (toString i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment