In OCaml, I want to write a function that returns the element at a given index of a list. For example [4;5;6] 0 -> 4
, [4;5;6] 1 -> 5
. I know how to do this recursively, but can anyone show how to do this problem using fold_left
or fold_right
? Thank you so much!
↧
Access the element at a list with index
↧