Stefan Monnier writes:
>> (define (map f l)
>> (if (pair? l)
>> (cons (f (car l))
>> (map f (cdr l)))
>> '()))
>>
>> whereas we used to have to write code like this in order to support long
>> lists without overflowing the stack:
>>
>> (define (map f l)
>>
Hi Mark!
Do you have any advice to optimize it without disable GC temperaly? Or the
only way is to change a better GC?
2017年6月10日 12:28,"Mark H Weaver" 写道:
> Stefan Monnier writes:
>
> >> (define (map f l)
> >> (if (pair? l)
> >> (cons (f (car l))
> >> (map f (cdr l))
Nala Ginrut writes:
> Do you have any advice to optimize it without disable GC temperaly?
Temporarily disabling the GC would merely postpone reclamation work that
needs to be done eventually, and at the risk of allocating a potentially
huge amount of garbage while the GC is disabled, in the worst
> (define (map f l)
> (if (pair? l)
> (cons (f (car l))
> (map f (cdr l)))
> '()))
>
> whereas we used to have to write code like this in order to support long
> lists without overflowing the stack:
>
> (define (map f l)
> (let loop ((l l) (out '()))
>