Re: [racket-users] raco test: 0 tests run, 1 test passed

2017-03-02 Thread Alex Harsanyi
On Friday, March 3, 2017 at 7:18:27 AM UTC+8, schuster wrote: > The problem is that a test-case expression runs a test immediately; it does > not return a test object to be run later. In your case, the test runs while > my-test-case is being defined, then no test at all actually runs > (my-test-

Re: [racket-users] raco test: 0 tests run, 1 test passed

2017-03-02 Thread Jonathan Schuster
The problem is that a test-case expression runs a test immediately; it does not return a test object to be run later. In your case, the test runs while my-test-case is being defined, then no test at all actually runs (my-test-case is just #). A test-suite expression, however, *does* construct a te

Re: [racket-users] change 'random' contract to allow zero in first position?

2017-03-02 Thread Daniel Prager
While we're at it, please allow negative arguments too, to allow for cases such as (random -100 100) Dan -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racke

Re: [racket-users] change 'random' contract to allow zero in first position?

2017-03-02 Thread Jay McCarthy
I think that the contract is overly specific on the 2 argument case. But on the 1 argument case, I don't think 0 makes sense: "When called with an integer argument k, returns a random exact integer in the range 0 to k-1."[k <- 0] =_v "When called with an integer argument 0, returns a random exact

[racket-users] change 'random' contract to allow zero in first position?

2017-03-02 Thread 'John Clements' via Racket Users
I have a bunch of students this quarter that are writing code like this: (- (random 1 9) 1) Why? because they tried writing (random 0 8) and got a contract error, to wit: random: contract violation expected: (integer-in 1 4294967087) given: 0 > I’m assuming that this contract was writt

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread Greg Hendershott
There is a "generic" `sequence-map`. But it's not variadic like `map` -- and like you want in your example. You could try writing a variadic `sequence-map`? As for `for/list`, you _could_ write: (for/list ([a as] [b bs] [n (in-naturals)]) (foo a b n)) It's faster if yo

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread David Storrs
On Thu, Mar 2, 2017 at 12:15 PM, David Storrs wrote: > > > > On Thu, Mar 2, 2017 at 11:22 AM, David Christiansen < > da...@davidchristiansen.dk> wrote: > >> > Not with map, which requires equal-length arguments. >> > >> > You could do the slightly less ugly: >> > >> > (map >> > foo >> > l

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread David Storrs
On Thu, Mar 2, 2017 at 11:22 AM, David Christiansen < da...@davidchristiansen.dk> wrote: > > Not with map, which requires equal-length arguments. > > > > You could do the slightly less ugly: > > > > (map > > foo > > lst-A > > lst-B > > (range (length lst-A))) > > Why not do it this

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread David Christiansen
> Not with map, which requires equal-length arguments. > > You could do the slightly less ugly: > > (map > foo > lst-A > lst-B > (range (length lst-A))) Why not do it this way? (struct foo (a b c)) (define lst-A '(a b)) (define lst-B '(d e)) (for/list ([a (in-list lst-A)]

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread Stephen Chang
Not with map, which requires equal-length arguments. You could do the slightly less ugly: (map foo lst-A lst-B (range (length lst-A))) On Thu, Mar 2, 2017 at 11:14 AM, David Storrs wrote: > > > On Thu, Mar 2, 2017 at 10:09 AM, Stephen Chang wrote: >> >> The in-X forms are sequ

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread David Storrs
On Thu, Mar 2, 2017 at 10:09 AM, Stephen Chang wrote: > The in-X forms are sequences, and must be used with the sequence API, ie > for/X. > > map only works with lists, so you could use build-list or range: > (map > foo > lst-A > lst-B > (range 2)) > > Is there a way to do it if I

Re: [racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread Stephen Chang
The in-X forms are sequences, and must be used with the sequence API, ie for/X. map only works with lists, so you could use build-list or range: (map foo lst-A lst-B (range 2)) On Thu, Mar 2, 2017 at 9:55 AM, David Storrs wrote: > I'd like to be able to do something like this: >

[racket-users] Idiomatic way to include numbers in a map?

2017-03-02 Thread David Storrs
I'd like to be able to do something like this: (struct foo (a b c)) (define lst-A '(a b)) (define lst-B '(d e)) (map foo lst-A lst-B (in-naturals)) I'd expected this to produce: (foo 'a 'd 0) (foo 'b 'e 1), but instead it throws an exception "expected list, given stream". I coul

Re: [racket-users] Making a snip% select itself in a text%

2017-03-02 Thread Erich Rast
I found an easy solution that does what I want it do to. It's only suitable for non-editable snips, of course. Instead of checking whether draw-caret is a pair in draw, I simply use (not (equal? draw-caret 'no-caret)) That does the job. As for keyboard events, I think I'll handle them in the sn

Re: [racket-users] Making a snip% select itself in a text%

2017-03-02 Thread Matthew Flatt
At Thu, 2 Mar 2017 11:12:16 +, Erich Rast wrote: > Hi! I have a simple non-editable and non-resizable snip% class that in > its draw function distinguishes whether it's selected or not. It works > fine when I select it in a text% with the mouse. > > Now I want to select it in the text% when th

Re: [racket-users] Re: Making a snip% select itself in a text%

2017-03-02 Thread Erich Rast
On Thu, 2 Mar 2017 03:32:08 -0800 (PST) Alex Harsanyi wrote: > You need to tell the snip admin that the snip needs to be redrawn. > In your select-this-snip method, add > > (send (get-admin) needs-update this 0 0 width height) > It still doesn't work. I'm using this: (define/public (sele

[racket-users] Re: Making a snip% select itself in a text%

2017-03-02 Thread Alex Harsanyi
On Thursday, March 2, 2017 at 7:12:22 PM UTC+8, erich wrote: > Hi! I have a simple non-editable and non-resizable snip% class that in > its draw function distinguishes whether it's selected or not. It works > fine when I select it in a text% with the mouse. > > Now I want to select it in the text%

[racket-users] Making a snip% select itself in a text%

2017-03-02 Thread Erich Rast
Hi! I have a simple non-editable and non-resizable snip% class that in its draw function distinguishes whether it's selected or not. It works fine when I select it in a text% with the mouse. Now I want to select it in the text% when the user left-clicks on it, so I've overridden on-event and tried