Guest User

Untitled

a guest
May 5th, 2020
6
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let { List, ? } = import! std.list
  2.  
  3. let lindex idx list : Int -> List a -> a =
  4. match list with
  5. | Nil -> error "list idx out of bounds"
  6. | Cons head tail ->
  7. if idx == 0
  8. then head
  9. else lindex (idx - 1) tail
  10.  
  11. {
  12. lindex,
  13. }
RAW Paste Data