Advertisement
Guest User

Untitled

a guest
Jan 13th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. focusListAt :: Int -> [a] -> Maybe (ListZipper a)
  2. focusListAt = go []
  3. where
  4. go _ _ [] = Nothing
  5. go acc 0 (hd : tl) = Just (acc, hd, tl)
  6. go acc n (hd : tl) = go (hd : acc) (n - 1) tl
  7.  
  8. OCaml
  9.  
  10. let focuscell celllist n =
  11. let rec loop acc n l =
  12. match l,n with
  13. | hd :: tl,n when n > 0 -> loop (hd :: acc) (n - 1) tl
  14. | [],_ -> None
  15. | hd :: tl,0 -> Some (acc, hd, tl)
  16. in loop [] 0 celllist
  17. ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement