Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- focusListAt :: Int -> [a] -> Maybe (ListZipper a)
- focusListAt = go []
- where
- go _ _ [] = Nothing
- go acc 0 (hd : tl) = Just (acc, hd, tl)
- go acc n (hd : tl) = go (hd : acc) (n - 1) tl
- OCaml
- let focuscell celllist n =
- let rec loop acc n l =
- match l,n with
- | hd :: tl,n when n > 0 -> loop (hd :: acc) (n - 1) tl
- | [],_ -> None
- | hd :: tl,0 -> Some (acc, hd, tl)
- in loop [] 0 celllist
- ;;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement