You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 4079 Reporter: Christophe Assigned to:@gasche Status: closed (set by @xavierleroy on 2015-12-11T18:19:47Z) Resolution: fixed Priority: normal Severity: minor Version: 3.09.2 Target version: 4.00.2+dev Category: standard library Monitored by:@mmottl
Bug description
Queue.copy is not tail recursive. Hence, large queue can not be safely duplicated.
This would be very simple to make it tail-recursive. I propose here a solution ;
let copy q =
if q.length = 0 then
create()
else
let tail = q.tail in
let rec tail' = {
content = tail.content;
next = tail'
} in
let rec copy prev cell =
if cell != tail
then let res = {
content = cell.content;
next = tail'
} in prev.next <- res;
copy res cell.next in
copy tail' tail.next;
{
length = q.length;
tail = tail'
}
The text was updated successfully, but these errors were encountered:
Original bug ID: 4079
Reporter: Christophe
Assigned to: @gasche
Status: closed (set by @xavierleroy on 2015-12-11T18:19:47Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.09.2
Target version: 4.00.2+dev
Category: standard library
Monitored by: @mmottl
Bug description
Queue.copy is not tail recursive. Hence, large queue can not be safely duplicated.
This would be very simple to make it tail-recursive. I propose here a solution ;
let copy q =
if q.length = 0 then
create()
else
let tail = q.tail in
The text was updated successfully, but these errors were encountered: