Re: [racket] Problem with hline in

2012-05-26 Thread Robby Findler
Matthew pointed out that that's how record-dc% already works! So now the example you write below works properly. Sorry for my confusion. Robby On Sat, May 26, 2012 at 8:14 PM, Robby Findler wrote: > That could probably be added to record-dc% (which the repl uses). > > Robby > > On Sat, May 26,

Re: [racket] Second display monitor issue

2012-05-26 Thread Matthew Flatt
EnumDisplayMonitors() is the way I see to get an HMONITOR, which is needed for GetMonitorInfo. Is there another way? At Sat, 26 May 2012 15:03:50 -0600, Kieron Hardy wrote: > Thanks Matthew for the fix - it seems to work fine - and wow done so > quickly too! > > Is there a reason you have Windows

Re: [racket] Problem with hline in

2012-05-26 Thread Robby Findler
That could probably be added to record-dc% (which the repl uses). Robby On Sat, May 26, 2012 at 2:58 PM, Neil Toronto wrote: > On 05/26/2012 08:17 AM, Robby Findler wrote: >> >> On Sat, May 26, 2012 at 10:09 AM, Jens Axel Søgaard >>  wrote: >>> >>> 2012/5/26 Robby Findler: As for crop

Re: [racket] Looping with look-behind and look-forward

2012-05-26 Thread Harry Spier
Thank you Matthias for the pattern, its exactly what I needed. And thank you Jens for the trick of appending a dummy element to the list so you don't lose the last item in the list. I.e. (define (f1 lst) (define-values (result-list dummy1 dummy2) (for/fold ([result-list '()][prior '()] [current (

Re: [racket] Issue with "cannot instantiate `racket/gui/base' a second time in the same process"

2012-05-26 Thread Kieron Hardy
Thanks for the info Matthew. Is it way too simplistic to think that DrRacket could pre-require a full set of the platform-specific GUI components for the platform that DrRacket is running on so that when a program needs them they are already available? I must say that it seems rather icky that one

[racket] Method + URL based dispatch

2012-05-26 Thread Jordan Schatz
I would like to dispatch requests based on a combination of URL and HTTP method. For example a GET request to /path-to-resource would be dispatched to one function, and a POST request to /path-to-resource would be dispatched to another function. The built in dispatch http://docs.racket-lang.org/we

Re: [racket] Second display monitor issue

2012-05-26 Thread Kieron Hardy
Thanks Matthew for the fix - it seems to work fine - and wow done so quickly too! Is there a reason you have Windows enumerate the display monitors (with EnumDisplayMonitors) and then ask Windows for details for each of those monitors (with GetMonitorInfoW)? I am thinking that a more direct approa

Re: [racket] Looping with look-behind and look-forward

2012-05-26 Thread Jens Axel Søgaard
Here is an alternative (not as efficient as MF's version). It uses that parallel for-loops stop when one of the sequences are empty. #lang racket (define (running-average-of-3-alternative l) (for ([x (in-list (append l '(dummy)))] [y (in-list (cdr l))] [z (in-list (cddr l))])

[racket] Modifying how "interaction" renders results

2012-05-26 Thread Jens Axel Søgaard
While documenting a matrix library, I have used the nice feature that picts returned by the evaluation are inserted into the resulting documentation: @interaction[#:eval matrix-eval (current-print (let ([print (current-print)]) (λ (v)

Re: [racket] Looping with look-behind and look-forward

2012-05-26 Thread Ashok Bakthavathsalam
The line (displayln (/ (+ prior current next))) needs to be changed to (displayln (/ (+ prior current next) 3)) Thanks, On Sat, May 26, 2012 at 9:20 PM, Matthias Felleisen wrote: > > Do you mean that if you operated on a list it would look like this: > > #lang racket > > (define (running-averag

Re: [racket] Problem with hline in

2012-05-26 Thread Neil Toronto
On 05/26/2012 08:17 AM, Robby Findler wrote: On Sat, May 26, 2012 at 10:09 AM, Jens Axel Søgaard wrote: 2012/5/26 Robby Findler: As for cropping, the DrRacket REPL is the thing that does the cropping (and, in some cases, it may not be cropping, actually, but two different parts of the window

Re: [racket] Problem with hline in

2012-05-26 Thread Robby Findler
Oh, now that I re-read that code I see a bug: it needs to set the pen back. So the last line of the procedure passed to dc should be: (send dc set-pen pen) Robby On Sat, May 26, 2012 at 11:03 AM, Jens Axel Søgaard wrote: > 2012/5/26 Robby Findler : >> Oh, in that case, you could do this: >> >

Re: [racket] Problem with hline in

2012-05-26 Thread Jens Axel Søgaard
2012/5/26 Robby Findler : > Oh, in that case, you could do this: > > (hc-append (blank 1 0) (hline (- w 1) 1)) Thanks! > If you don't want the rounded edges, you'd have to do something like this: > > (define (fraction p q) >  (define w (max (pict-width p) (pict-width q))) >  (vc-append p (vc-appe

Re: [racket] Looping with look-behind and look-forward

2012-05-26 Thread Matthias Felleisen
Do you mean that if you operated on a list it would look like this: #lang racket (define (running-average-of-3 l2) (define-values (_1 _2) (for/fold ((current (second l2)) (prior (first l2))) ((next (rest (rest l2 (displayln (/ (+ prior current next))) (values next current

Re: [racket] Problem with hline in

2012-05-26 Thread Robby Findler
Oh, in that case, you could do this: (hc-append (blank 1 0) (hline (- w 1) 1)) If you don't want the rounded edges, you'd have to do something like this: (define (fraction p q) (define w (max (pict-width p) (pict-width q))) (vc-append p (vc-append (blank 0 2) (butt-hline w)) q)) (require ra

Re: [racket] Problem with hline in

2012-05-26 Thread Jens Axel Søgaard
Hi Robby, > So maybe the easiest thing is to drop down to use 'dc' to draw the > precise lines you want. > > If you spell that out here, I can probably give you some guidance on > how to do it? The hline is used to make a fraction. When I scaled the fraction, I noticed the division bar was asymme

Re: [racket] Problem with hline in

2012-05-26 Thread Robby Findler
On Sat, May 26, 2012 at 10:09 AM, Jens Axel Søgaard wrote: > 2012/5/26 Robby Findler : >> It is possible something is wrong with hline and/or its interaction >> with scaling, I'm not sure. But this adds enough space: >> >> #lang racket >> (require slideshow/pict) >> (hc-append (blank 15 0) >>    

Re: [racket] Problem with hline in

2012-05-26 Thread Jens Axel Søgaard
2012/5/26 Robby Findler : > It is possible something is wrong with hline and/or its interaction > with scaling, I'm not sure. But this adds enough space: > > #lang racket > (require slideshow/pict) > (hc-append (blank 15 0) >           (vc-append (scale (hline 30 1) 30) >                      (blan

Re: [racket] complex sort or how to sort lines

2012-05-26 Thread Matthias Felleisen
On May 26, 2012, at 10:32 AM, Don Green wrote: > (with-output-to-file file > #:exists 'replace > (lambda () >(for ((ch content)) (display ch ;< ;; --- test > (check-equal? (with-output-to-string > (lambda () > (for ((ln (answer file))) >

Re: [racket] Problem with hline in

2012-05-26 Thread Robby Findler
It is possible something is wrong with hline and/or its interaction with scaling, I'm not sure. But this adds enough space: #lang racket (require slideshow/pict) (hc-append (blank 15 0) (vc-append (scale (hline 30 1) 30) (blank 0 15)) (blank 15 0)) I wo

Re: [racket] Problem with hline in

2012-05-26 Thread Jens Axel Søgaard
2012/5/26 Robby Findler : > I think this is the result of cropping to the boundary box and the end > of the line is cropped on the left, but not the right (in the > attachment; in the program, it gets cropped along the bottom too). That's odd. The documentation on hline says the line is centered i

Re: [racket] Second display monitor issue

2012-05-26 Thread Matthew Flatt
Thanks! I've pushed a change that should solve the problem; let me know if it still doesn't work. At Sat, 26 May 2012 05:45:52 -0600, Kieron Hardy wrote: > So it seems that for some reason (Older Dell laptop, ATI video, Windows 7 > using generic drivers) the Windows system call to return the list

Re: [racket] Problem with hline in

2012-05-26 Thread Robby Findler
I think this is the result of cropping to the boundary box and the end of the line is cropped on the left, but not the right (in the attachment; in the program, it gets cropped along the bottom too). This looks right: #lang racket (require slideshow) (slide (scale (hline 30 1) 15)) So if you're

[racket] Problem with hline in

2012-05-26 Thread Jens Axel Søgaard
Hi All, Experimenting with slideshow/pict I noticed that the lines produced by hline doesn't begin and end the same way. > (require slideshow/pict) > (scale (hline 30 1) 15) The start of the line is rectangular where as the end is rounded. See attached image. Should I change the

Re: [racket] Issue with "cannot instantiate `racket/gui/base' a second time in the same process"

2012-05-26 Thread Matthew Flatt
This is essentially a limitation of `racket/gui'. Platform-specific GUI back-ends are `dynamic-require'd by `racket/gui', so when `racket/gui' is attached to the program namespace by DrRacket, the platform-specific back-end modules aren't similarly attached. Since they're not attached, DrRacket tri

Re: [racket] Rationale behind missing string-trim

2012-05-26 Thread Chad Albers
Thanks Eli! -- Chad Albers On Thu, May 24, 2012 at 2:19 PM, Eli Barzilay wrote: > About two weeks ago, Chad Albers wrote: >> Thanks Eli.  I'm happy you recognize the issue. >> >> I did write my own string-trim-both function using Racket's regexp as >> follows: >> >>   (define (string-trim-both

Re: [racket] Second display monitor issue

2012-05-26 Thread Kieron Hardy
So it seems that for some reason (Older Dell laptop, ATI video, Windows 7 using generic drivers) the Windows system call to return the list of monitors is returning them to Racket in a different order (primary display monitor last) than expected (primary display monitor first). The code for get-al

[racket] Issue with "cannot instantiate `racket/gui/base' a second time in the same process"

2012-05-26 Thread Kieron Hardy
Hi all, In debugging my second display monitor issue I'm trying to make a little test utility from the Racket source. I've copied a snippet (pasted below) from \collects\mred\private\wx\win32\frame.rkt into a new file in the same directory as frame.rkt. Although it will compile (with raco make)