-- Exercise 23-- Relative Difficulty: 7-- | Move the focus to the given absolute position in the zipper. Traverse the zipper only to the extent required.---- >>> nth 1 (ListZipper [3,2,1] 4 [5,6,7])-- [1]⋙2⋘[3,4,5,6,7]---- >>> nth 5 (ListZipper [3,2,1] 4 [5,6,7])-- [1,2,3,4,5]⋙6⋘[7]---- >>> nth 8 (ListZipper [3,2,1] 4 [5,6,7])-- ∅nth ::ListZipper' f =>Int-> f a-> MaybeListZipper anth =error "todo"My current approach is:
nth n lz = case toMaybeListZipper lz of IsZ (ListZipper l _ _) -> moveRightN (n - (length l)) lz IsNotZ -> IsNotZ
But this does not give you minimal traversing. Anyone able to give me some clues as to how to approach this problem?
I can tell you this much. This function is quite difficult. These is a handy function nearby iirc.
--
You received this message because you are subscribed to the Google Groups "haskell-exercises" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-exerci...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.