[racket] Racket Mongrel2 adapter source release

2012-04-17 Thread Chad Albers
Hi, To teach myself Racket scheme (which I now Iove), I wrote an adapter to the mongrel2 webserver. I just open-sourced the code on github. Once I add unit testing and scribble documentation, I might try have it accepted into planet racket, if anyone thinks it would be of interest. http://git

Re: [racket] making Racket code more idiomatic

2012-04-17 Thread Cristian Esquivias
Hi Joe, Thanks for the tip on on values in for*/fold. That should be added to docs. I took a stab at converting your example into something more functional. I'm too new to Racket to claim it's idiomatic. I mostly went in and tried to remove what I considered iterative idioms; things like do, let

Re: [racket] Plot: plot-new-window never happens?

2012-04-17 Thread Robby Findler
Oh, right you are. I misunderstood what was going on. Sorry for the noise. Robby On Tue, Apr 17, 2012 at 4:27 PM, Deren Dohoda wrote: > It was convenient to have something that bypassed the whole gui issue. Since > it really is a gui issue, I am not too offended that my own laziness got in > my

Re: [racket] Plot: plot-new-window never happens?

2012-04-17 Thread Deren Dohoda
It was convenient to have something that bypassed the whole gui issue. Since it really is a gui issue, I am not too offended that my own laziness got in my way. That said, it seemed to me that the use of the new window was a convenience added for just this kind of use, otherwise I would be using a

Re: [racket] making Racket code more idiomatic

2012-04-17 Thread Joe Gilray
Cristian, One more thing, since for*/fold in your code only takes one accumulator, you don't need "values" at all. Makes the code even shorter! -Joe On Tue, Apr 17, 2012 at 12:54 PM, Joe Gilray wrote: > Hi Guys. > > Thanks for the education on for/fold and for*/fold. > > Cristian, your soluti

Re: [racket] making Racket code more idiomatic

2012-04-17 Thread Joe Gilray
Hi Guys. Thanks for the education on for/fold and for*/fold. Cristian, your solution is very elegant, thanks, but unfortunately it does generate all the numbers so is relatively slow and won't scale too well with a and b. -Joe On Tue, Apr 17, 2012 at 11:01 AM, Cristian Esquivias < cristian.esqu

Re: [racket] Plot: plot-new-window never happens?

2012-04-17 Thread Robby Findler
FWIW, I think we'd want somehow, in the library, to show plot windows in a way that doesn't do any special threading/eventspace stuff, or else the opposite confusion can happen. How about, for this situation, having a function called 'show-plot!' that takes a plot and puts it into a window in a se

Re: [racket] Plot: plot-new-window never happens?

2012-04-17 Thread Matthew Flatt
You could give each frame in its own eventspace. At Tue, 17 Apr 2012 11:45:20 -0600, Neil Toronto wrote: > Would it be possible to change plot so that its windows always behave > like this? Could I make it not require cooperation from the program that > calls `plot-frame'? > > This is going to

Re: [racket] making Racket code more idiomatic

2012-04-17 Thread Cristian Esquivias
I used Project Euler to try out new languages as well. Here was my attempt at Problem 29 for reference. (define (prob29 a b) (set-count (for*/fold ([nums (set)]) ([i (in-range 2 (add1 a))] [j (in-range 2 (add1 b))]) (values (set-add nums (expt i j)) - Cristian On

Re: [racket] Plot: plot-new-window never happens?

2012-04-17 Thread Neil Toronto
Would it be possible to change plot so that its windows always behave like this? Could I make it not require cooperation from the program that calls `plot-frame'? This is going to come up every time someone wants to pop up plot windows in a non-GUI, interactive loop. Neil ⊥ On 04/17/2012 10

Re: [racket] Plot: plot-new-window never happens?

2012-04-17 Thread Deren Dohoda
That's extremely helpful, thank you. Deren On Tue, Apr 17, 2012 at 12:48 PM, Matthew Flatt wrote: > All GUI activity like window drawing happens only in the main thread of > an eventspace. Your program also starts out in the main thread. So, > yes, drawing has to wait until your loop completes.

Re: [racket] making Racket code more idiomatic

2012-04-17 Thread Matthew Flatt
Blindly refactoring the code, I'd use `for/fold' and add a `lst' accumulator to `loop': (define (euler29c) ; calculate 99^2 - duplicates (- (sqr 99) (for/sum ([d '(2 3 5 6 7 10)]) (let loop ([lst '()] [exp 1]) (if (> (expt d exp) 100) (- (length lst) (length

Re: [racket] Plot: plot-new-window never happens?

2012-04-17 Thread Matthew Flatt
All GUI activity like window drawing happens only in the main thread of an eventspace. Your program also starts out in the main thread. So, yes, drawing has to wait until your loop completes. One solution is to put your loop in a separate thread. The example below creates a thread and passes it to

[racket] making Racket code more idiomatic

2012-04-17 Thread Joe Gilray
Hi, To continue our conversation about creating idiomatic Racket code, here is some code I wrote last night to solve projecteuler.net problem #29: (define (euler29a) ; calculate 99^2 - duplicates (- (sqr 99) (for/sum ([d '(2 3 5 6 7 10)]) (let ([lst '()]) (l

[racket] Plot: plot-new-window never happens?

2012-04-17 Thread Deren Dohoda
I was messing around with a spline utility last night and was using the plot-new-window? setting to get a plot. The goal was to share an exe with a coworker who doesn't have Racket. Just a command-line app but to get the plot to display I needed a window and this seemed awesome. The problem is I co

Re: [racket] extra exercises

2012-04-17 Thread Roelof Wobben
Op 17-4-2012 1:31, Stephen Bloch schreef: On Apr 16, 2012, at 5:18 PM, Neil Van Dyke wrote: ... if one is still looking for additional beginner programming exercises, I think that one not-totally-bad option is to start picking standard algorithms and data structures one can learn about by sea