Skip to content

Instantly share code, notes, and snippets.

@ElvishJerricco
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save ElvishJerricco/a4241a406743f599f1b5 to your computer and use it in GitHub Desktop.

Select an option

Save ElvishJerricco/a4241a406743f599f1b5 to your computer and use it in GitHub Desktop.
index :: l <: [a] - ([]) -> i <: { n <- Int | n < length l; n >= 0 } -> { -- notice the shortcutting,
-- using the l type as an argument to length instead
-- of having to bind l to a name as a foreach.
case (l, i) of -- similar shortcutting
(x:xs, 0) = x
(x:xs, n) = index xs (n - 1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment