<div class="gmail_quote">On Sun, Jul 24, 2011 at 09:44, Stephan Houben <span dir="ltr"><<a href="mailto:stephanh@planet.nl">stephanh@planet.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi Rodolfo,<br></blockquote><div><br></div><div><br></div><div>Hi Stephan,</div><div><br></div><div>Thanks for your considerations.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
I think solution 2 is generally preferred, and<br>
solution 1 would be considered a slight abuse of apply.<br></blockquote><div><br></div><div><br></div><div>Why is that an abuse? Is it an abuse just in this specific case, or in general?</div><div>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.</div>
<div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
On the other hand, I find that summing comes up sufficiently<br>
often to deserve its own compact syntax, so I propose:<br>
<br>
;; Solution 3<br>
(require (planet "mathsymbols.rkt" ("stephanh" "mathsymbols.plt" 1 0)))<br>
<br>
(Ó ([i (in-range 1 (add1 N))])<br>
(string-length (integer->string i)))<br></blockquote><div><br></div><div><br></div><div>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).</div>
<div><br></div><div>I've added this to my script, now with 6 different implementations, line after line more messy :|</div><div>(that's throw-away code anyway...)</div><div><br></div><div>For now it's my preferred solution considering aesthetics, semantics and performance.</div>
<div>Thanks.</div><div><br></div><div></div></div><br><div>Rodolfo Carvalho</div>