Skip to content
This repository has been archived by the owner on May 15, 2019. It is now read-only.

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

Merged
merged 1 commit into from Sep 20, 2011

Conversation

josharnold52
Copy link
Contributor

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants