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
I've run into problems with the count function, which lifts 'a parsers to be 'a list parsers, stack overflowing. This is because the current implementation uses a recursive build-up of lifting cons to parsers in a non-tail-recursive fashion:
letcountnp=if n <0then fail "count: n < 0"elseletrec loop=function|0 -> return []|n -> lift2 cons p (loop (n -1))
in
loop n
A naiive fix that I have is the following, which changes the above count to be tail-recursive:
(* A tail-recursive implementation of "count" *)letcount_trnp=if n <0then fail "count: n < 0"elseletrec loopacc=function|0 -> acc
|n -> loop (lift2 cons p acc) (n -1)
in
loop (return []) n
The text was updated successfully, but these errors were encountered:
I've run into problems with the
count
function, which lifts'a
parsers to be'a list
parsers, stack overflowing. This is because the current implementation uses a recursive build-up of liftingcons
to parsers in a non-tail-recursive fashion:A naiive fix that I have is the following, which changes the above
count
to be tail-recursive:The text was updated successfully, but these errors were encountered: