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)) > > works but is slow because it regen

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] Another PLaneTs crypto lib usage question?...

2012-04-28 Thread Doug Williams
I have forked the crypto package to perform these actions for my own code and to fix some other problems with post 1.0.0 versions of OpenSSL. I submitted a bug report that at least removes the errors when we go to later OpenSSL versions, but haven't seen any response. I don't have the throughput to

Re: [racket] idiomatic and fast

2012-04-28 Thread J. Ian Johnson
(whoops, should reply all) I have a macro that does for/fold behavior on some arguments and for/lists on the other. It's fairly handy. Here's my solution with that macro: (let-values ([(_ result) (for/fold/lists ([s 0]) (result) ([i (in-range 1 21)]) (v

[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

[racket] Another PLaneTs crypto lib usage question?...

2012-04-28 Thread Rüdiger Asche
Hi there, I'm working with the crypto lib from PLaneT. It actually works well, so far, thanks for the wrappers (it's a Scheme interface to OpenSSL). My question is, how do I turn off padding, i.e. what do I have to pass (and where) as an additional parameter to e.g. (define dummy (encrypt ciph

Re: [racket] Quick on-screen documentation

2012-04-28 Thread Robby Findler
Fix pushed. Thanks! Robby On Sat, Apr 28, 2012 at 4:24 AM, Laurent wrote: > > > On Fri, Apr 27, 2012 at 21:54, Laurent wrote: >> >> >> >> On Fri, Apr 27, 2012 at 21:08, Deren Dohoda >> wrote: >>> >>> Sorry, supposed to be to all: >>> >>> WinXP, DrRacket 5.2 >>> Edit: Show Active Keybindings: >

[racket] Note for packagers

2012-04-28 Thread Eli Barzilay
If anyone is maintaining a third-party package and wants to know when we start testing a release candidate, tell me and I'll add you to a list of people that are notified when we start to test for a new release. -- ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:

Re: [racket] Quick on-screen documentation

2012-04-28 Thread Laurent
On Fri, Apr 27, 2012 at 21:54, Laurent wrote: > > > On Fri, Apr 27, 2012 at 21:08, Deren Dohoda wrote: > >> Sorry, supposed to be to all: >> >> WinXP, DrRacket 5.2 >> Edit: Show Active Keybindings: >> >> string: expects argument of type ; given f1 >> > > Indeed. I'm not sure, but this one might b