Re: [racket] idiomatic and fast

2012-04-29 Thread Robby Findler
My own $0.02: I prefer to take the high road, assume the best, and ROFL (literally). On Sun, Apr 29, 2012 at 5:35 PM, Neil Van Dyke wrote: > Matthias Felleisen wrote at 04/29/2012 05:50 PM: > >> Are you saying that this was NOT an April fool's joke? Argh. >> > > > With Microsoft, I can't always t

Re: [racket] idiomatic and fast

2012-04-29 Thread Neil Van Dyke
Matthias Felleisen wrote at 04/29/2012 05:50 PM: Are you saying that this was NOT an April fool's joke? Argh. With Microsoft, I can't always tell. With this MS thing recognizing dubious achievements, and posting those honors on one's Facebook and such, it could be some fun/lame thing, or

Re: [racket] idiomatic and fast

2012-04-29 Thread Matthias Felleisen
Are you saying that this was NOT an April fool's joke? Argh. On Apr 29, 2012, at 4:13 PM, Neil Van Dyke wrote: > Matthias Felleisen wrote at 04/29/2012 12:43 PM: >> Gamifying a PL for real -- as opposed to the April fool's joke about VS that >> wear going around -- would indeed be a fun and in

Re: [racket] idiomatic and fast

2012-04-29 Thread Neil Van Dyke
Matthias Felleisen wrote at 04/29/2012 12:43 PM: Gamifying a PL for real -- as opposed to the April fool's joke about VS that wear going around -- would indeed be a fun and interesting project -- Matthias Google found this: http://www.gamasutra.com/view/news/39717/Microsoft_gamifies_Visua

Re: [racket] idiomatic and fast

2012-04-29 Thread Matthias Felleisen
On Apr 28, 2012, at 5:11 PM, Neil Van Dyke wrote: > Some student should try making a video-game-like leveling and unlocking > system for DrRacket. This would be for people who are learning Racket > without working through HtDP: they have a big language and don't know which > features are best

Re: [racket] idiomatic and fast

2012-04-28 Thread Joe Gilray
Wow, thanks for all the creative solutions! After many years of programming, I'm still so floored by what a creative and artistic endeavor it is... and like all artistic endeavors, over time one develops a certain taste and style. Certain solutions really appeal over others. Thanks again, learni

Re: [racket] idiomatic and fast

2012-04-28 Thread Galler
;and without having to discard first two elements-> (build-list 21 (compose (λ (x) (/ (* x (+ x 1)) 2)) add1)) Racket Users list: http://lists.racket-lang.org/users

Re: [racket] idiomatic and fast

2012-04-28 Thread Galler
(build-list 22 (λ (x) (/ (* x (- x 1)) 2))) Discard the first two values from the list. R./ Zack Racket Users list: http://lists.racket-lang.org/users

Re: [racket] idiomatic and fast

2012-04-28 Thread Jordan Johnson
> From: Joe Gilray > To: Racket mailing list > Subject: [racket] idiomatic and fast > > I'm trying to come up with the most idiomatic way to generate triangle > numbers that is also fast: > > (for/list ([i (in-range 2 22)]) (for/sum ([j (in-range i)]) j)) >

Re: [racket] idiomatic and fast

2012-04-28 Thread Michael W
Here's a solution based on for/fold that hasn't been suggested yet. Runs in O(n) time. (let-values ([(results last-sum) (for/fold ([sofar '()] [value 1]) ([i (in-range 2 22)]) (values (cons value sofar)

Re: [racket] idiomatic and fast

2012-04-28 Thread Chris Stephenson
On 28/04/12 22:54, Joe Gilray wrote: > > (for/list ([i (in-range 2 22)]) (for/sum ([j (in-range i)]) j)) > > works but is slow because it regenerates the sums each time > > (define s 0) (for/list ([i (in-range 1 21)]) (set! s (+ s i)) s) > > is fast, but ugly. > > How do I keep the sum in an idioma

Re: [racket] idiomatic and fast

2012-04-28 Thread Deren Dohoda
I don't know if I could ever be a resource on "most idiomatic", especially since I basically never use any of the for/et ceteras but this feels reminiscent of "The Little Schemer" to me (except for the internal define instead of letrec): (define (make-triangles to-n) (define (next-triangle last-

Re: [racket] idiomatic and fast

2012-04-28 Thread Neil Van Dyke
My opinion is to start by *not* using "for"-something forms. I'd suggest starting with named-"let" or recursive named procedures, and going from there. I think you'll find yourself wanting "set!" less once you kick "for"-something to the curb. I think that "for"-something forms are for peopl

Re: [racket] idiomatic and fast

2012-04-28 Thread J. Ian Johnson
cket mailing list" Sent: Saturday, April 28, 2012 3:54:31 PM GMT -05:00 US/Canada Eastern Subject: [racket] idiomatic and fast Hi, I'm trying to come up with the most idiomatic way to generate triangle numbers that is also fast: (for/list ([i (in-range 2 22)]) (for/sum ([j (in-ra

[racket] idiomatic and fast

2012-04-28 Thread Joe Gilray
Hi, I'm trying to come up with the most idiomatic way to generate triangle numbers that is also fast: (for/list ([i (in-range 2 22)]) (for/sum ([j (in-range i)]) j)) works but is slow because it regenerates the sums each time (define s 0) (for/list ([i (in-range 1 21)]) (set! s (+ s i)) s) is