Closed Janiczek closed 1 year ago
I'm guessing this should use front and rear once each instead of using front twice https://github.com/amenzwa/pfd/blob/main/src/Queue/LfrQueue.elm#L34
Martin, Okasaki's Standard ML implementation for left-right queue (which he calls BatchedQueue) on p.43 is fun snoc ((f, r), x) = checkf (f, x::r)
, which I mistranslated into Elm as enq x ( f, r ) = checkF ( f, x :: f )
. The correct translation is enq x ( f, r ) = checkF ( f, x :: r )
. I just fixed this bug, and updated the test case, too.
Thank you so much for finding this bug.
I'm not sure this is expected (are you not allowed to enqueue the same item twice?)
Minimal example:
Trying it out in
elm-repl
:The test that found this: