Skip to content

Commit

Permalink
Fix num bug in QueueList - fixes #4722 (#4727)
Browse files Browse the repository at this point in the history
  • Loading branch information
forki authored and KevinRansom committed Apr 19, 2018
1 parent 41b9f61 commit 4cfdb41
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/fsharp/QueueList.fs
Expand Up @@ -34,7 +34,11 @@ type internal QueueList<'T>(firstElementsIn:'T list, lastElementsRevIn: 'T list,

/// This operation is O(1), unless a push happens, which is rare.
member x.AppendOne(y) = QueueList(firstElements, y :: lastElementsRev, numLastElements+1)
member x.Append(ys:seq<_>) = QueueList(firstElements, (List.rev (Seq.toList ys) @ lastElementsRev), numLastElements+1)
member x.Append(ys:seq<_>) =
let newElements = Seq.toList ys
let newLength = List.length newElements
let lastElementsRevIn = List.rev newElements @ lastElementsRev
QueueList(firstElements, lastElementsRevIn, numLastElementsIn + newLength)

/// This operation is O(n) anyway, so executing ToList() here is OK
interface IEnumerable<'T> with
Expand Down

0 comments on commit 4cfdb41

Please sign in to comment.