[racket] A question about code-style (and memory usage)

From: Rodolfo Carvalho (rhcarvalho at gmail.com)
Date: Mon Jul 25 03:57:31 EDT 2011

On Sun, Jul 24, 2011 at 09:44, Stephan Houben <stephanh at planet.nl> wrote:

> Hi Rodolfo,

Hi Stephan,

Thanks for your considerations.

> I think solution 2 is generally preferred, and
> solution 1 would be considered a slight abuse of apply.

Why is that an abuse? Is it an abuse just in this specific case, or in
I thought of (apply + a-list) as a way of expressing something like (sum
a-list), being "sum" an hypothetical function that takes a list and return
the sum of its elements.

> On the other hand, I find that summing comes up sufficiently
> often to deserve its own compact syntax, so I propose:
> ;; Solution 3
> (require (planet "mathsymbols.rkt" ("stephanh" "mathsymbols.plt" 1 0)))
> (Σ ([i (in-range 1 (add1 N))])
>       (string-length (integer->string i)))

I like it. It looks neat and runs reasonably fast (and I imagine the memory
usage is on pair with the other solutions, except for #1).

I've added this to my script, now with 6 different implementations, line
after line more messy :|
(that's throw-away code anyway...)

For now it's my preferred solution considering aesthetics, semantics and

Rodolfo Carvalho
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20110725/c9b4e86f/attachment.html>

Posted on the users mailing list.