Some days ago I came across Williams' describe<http://planet.racket-lang.org/display.ss?package=describe.plt&owner=williams>collection from PLaneT. That's pretty awesome. And coincidentally came this problem<http://projecteuler.net/index.php?section=problems&id=17>from Project Euler.
Then I wrote two solutions, and I was wondering which one of them have the best style, according to Racket's philosophy. #lang racket (require (planet williams/describe/describe)) (define N 1000) ;; Solution 1 (apply + (build-list N (compose string-length integer->string add1))) ;; Solution 2 (for/fold ([sum 0]) ([i (in-range 1 (add1 N))]) (+ sum ((compose string-length integer->string) i))) For me solution 1 is compact, however it allocates the list without need (which gives out of memory error for large N). Solution 2 is more memory efficient, but more verbose. BTW what's the recommended way to check "per-function" memory usage? There's an unanswered question about memory profiling<http://groups.google.com/group/racket-users/browse_thread/thread/d48ce09209a5aea4>in the mailing list, and I could find my way out searching PLaneT, the docs and the mailing list archive. []'s Rodolfo Carvalho
_________________________________________________ For list-related administrative tasks: http://lists.racket-lang.org/listinfo/users