[racket] (Practical) Limits of Apply?
Well, the following program
#lang racket
(for ((log-length (in-range 23)))
(let ((length (expt 2 log-length)))
(printf "Applying append to list of ~a singletons~%" length)
(time (apply append (for/list ((i (in-range length))) (list i))))))
Runs fine for me---the final stage reports
Applying append to list of 4194304 singletons
cpu time: 3270 real time: 3276 gc time: 2739
Going to 2^24 takes at least 1.1 GB of memory on my machine, and I was forced to kill the process due to swapping (I have several other active processes running). So, I guess the answer to my question is: "there is no limit on apply that takes effect before basic memory limits". Hopefully others will find this useful as well.
Will
On Aug 24, 2010, at 12:36 PM, Robby Findler wrote:
> Try it out and see. I believe that the below is considered a common
> idiom and that Matthew has probably done some work to make it work
> well, but the contribution of a stress test is always welcome.
>
> Robby
>
> On Tue, Aug 24, 2010 at 12:31 PM, Will M. Farr <wmfarr at gmail.com> wrote:
>> Hello all,
>>
>> I recently encountered some library code of the form
>>
>> (apply append list-of-lists)
>>
>> where list-of-lists could be essentially arbitrarily long (i.e. list-of-lists came from clients of the library, and therefore could be anything). I didn't try to break it, but it made me a little nervous---I know that other Schemes have limits on the number of arguments that can come through apply. In practice, should I be worried about using apply on, say, 1M-element argument lists?
>>
>> Thanks,
>> Will
>> _________________________________________________
>> For list-related administrative tasks:
>> http://lists.racket-lang.org/listinfo/users
>>