Zipper.slice returns incorrect result if Zipper contains equal elements #45

merged 1 commit into from Sep 20, 2011

2 participants


Zipper#slice and DeepZipper#slice currently assume that no two elements are equal, which isn't always true. This pull request fixes the problem by creating a Zipper.flatMapWithIndex and basing slice off of that. Conveniently, DeepZipper already had such a method and only required a small change to slice.

Note that the take, drop, and splitAt methods all use slice internally and exhibit the same behavior.

scala> val x = <a><b /><b /></a>.convert \ *
x: com.codecommit.antixml.Zipper[com.codecommit.antixml.Node] = <b/><b/>

scala> x.take(1)
res0: com.codecommit.antixml.Zipper[com.codecommit.antixml.Node] = 

scala> x.take(2)
res1: com.codecommit.antixml.Zipper[com.codecommit.antixml.Node] = <b/><b/>
@djspiewak djspiewak merged commit 9495953 into djspiewak:master Sep 20, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment