Re: [racket-users] Macro help

2019-05-25 Thread yfzhe
Another "syntax-case-y" version generates `define-values`:

(define-syntax-rule (aux clause ...)
  (aux-helper () (clause ...)))

(define-syntax (aux-helper stx)
  (syntax-case stx ()
[(_ ([id val] ...) ())
 #'(define-values (id ...) (values val ...))]
[(_ (id+val ...) ([id val] more ...))
 (identifier? #'id)
 #'(aux-helper (id+val ... [id val]) (more ...))]
[(_ (id+val ...) (id more ...))
 (identifier? #'id)
 #'(aux-helper (id+val ... [id #f]) (more ...))]))


在 2019年5月24日星期五 UTC+8下午12:41:20,lysseus写道:
>
> Hi guys, 
> I’ve been wracking my brains all day trying to come up with a macro that 
> would convert this syntax: 
>
> ;; (aux a (b (* 2 pi)) c (d pi)) 
> ;; => (define-values (a b c d) (values #f 6.28318530717958 #f 
> 3.141592653589793) 
>
>
> I’m missing some part of the picture. The closest I’ve come is to create a 
> list of the pairs: 
>
> #lang racket 
>
> (define-syntax (aux stx) 
>   (syntax-case stx () 
> [(_ (var val)) #'`((var ,val))] 
> [(_ var) #''((var #f))] 
> [(_ (var0 val0) var1 ...) #'(append `((var0 ,val0)) (aux var1 ...))] 
> [(_ var0 var1 ...) #'(append '((var0 #f)) (aux var1 ...))])) 
>
> (aux a (b (* 2 pi)) c (d pi)) ;=> '((a #f) (b 6.283185307179586) (c #f) (d 
> 3.141592653589793)) 
>
>
> Any help is greatly appreciated! 
>
> Kevin

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/38e8096f-0831-43be-879c-86fb9252004f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Online IDE’s for Racket ?

2019-05-25 Thread Hendrik Boom
On Fri, May 24, 2019 at 03:20:47PM -0700, Stephen Foster wrote:
> I came across some old posts on compiling Racket for the web, but I was 
> wondering if there was any recent activity on this.  Has anyone ever 
> compiled Racket (including DrRacket) for the web -- i.e. with Emscripten?  
> (I know about things like Whalesong and RacketScript.  But I don't think 
> these are applicable here.)

Or Webassemby?

-- hendrik

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20190525120150.eljk32bauag4s3q2%40topoi.pooq.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Online IDE’s for Racket ?

2019-05-25 Thread Stephen De Gabrielle
Thank you Annaia - that is awesome!



On Wed, May 1, 2019 at 1:02 PM Annaia Berry  wrote:

> I set up a Racket web project on Glitch here:
> https://glitch.com/~rantstack
>
> With this you can get live reloading and hosting of a Racket web server.
>
> On Wed, May 1, 2019 at 1:58 PM Laurent  wrote:
>
>> Rollapp looks interesting, but when I want to sign in with my gmail
>> account it requires to get information about all my linked email addresses.
>> That really seems unnecessary to me, so I didn't try it.
>>
>> On Fri, Apr 26, 2019 at 9:59 PM Stephen De Gabrielle <
>> spdegabrie...@gmail.com> wrote:
>>
>>> Yes - WeScheme is awesome - and so is
>>> http://pasterack.org
>>>
>>> Suggestion: upvote racket on repl.it so you can run it from everywhere:
>>>
>>> https://repl.it/language-requests/p/racket
>>>
>>> (I know it is unlikely to be as good as the full DrRacket or racket-mode
>>> experience)
>>>
>>> S.
>>>
>>> On Wed, 24 Apr 2019 at 19:58, Stephen Foster 
>>> wrote:
>>>
 Wow!  This is is cool.

 Also +1 -- since I'm interested in this very topic and curious to know
 what's out there.

 P.S. You probably already know about wescheme.org, right?


 On Tuesday, April 23, 2019 at 5:17:40 AM UTC-7, Stephen De Gabrielle
 wrote:
>
> Hi
>
> I found that you can run DrRacket on rollApp virtualisation
> platform[1].
>
> Are there any other online IDE’s for Racket? I’m interested in both
> in-browser repl/editor combinations or virtualised DrRacket.
>
> Stephen
>
> [1] rollApp DrRacket free version does not permit saving. Signup
> required. https://www.rollapp.com/app/drracket
>
> --
> 
>
 --
 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 racket-users+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.

>>> --
>>> 
>>>
>>> --
>>> 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 racket-users+unsubscr...@googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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 racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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 racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAGHj7-JeQo6g%2BPLv1d1ozvjiTtJefYXpTSdqWDLKpztZyak96g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] redundancy in GUI callback functions

2019-05-25 Thread Travis Hinkelman
Hi All,

I'm working through the tasks in 7guis 
 to learn about GUI programming in 
Racket. My code 
 for 
the temperature converter task works as expected but there is a lot of 
redundancy in my update-fahrenheit and update-celsius callback functions. I 
would appreciate feedback on how to make this code less redundant.

Thanks,

Travis

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/8f97260c-62be-4a6f-9459-244a88632ef9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] redundancy in GUI callback functions

2019-05-25 Thread Sorawee Porncharoenwase
Just abstract the common part out? E.g.,

(define (update-text-field read-field write-field converter)
  (define text (send read-field get-value))
  (cond
[(string=? text "")
 (send read-field set-field-background (make-object color% 255 255 255 1))
 (send write-field set-value "")]
[(number? (string->number text))
 (send read-field set-field-background (make-object color% 255 255 255 1))
 (send write-field set-value (converter (string->number text)))]
[else
 (send read-field set-field-background (make-object color% 255 0 0 1))
 (send write-field set-value "")]))

(define (update-fahrenheit control event)
  (update-text-field text-celsius text-fahrenheit convert-c))

(define (update-celsius control event)
  (update-text-field text-fahrenheit text-celsius convert-f))

Note that your original code has a bug: you always use convert-c in both
directions. Obviously, in update-celsius you want to use convert-f.

There’s also another subtle bug that I didn’t fix. Suppose you type an
invalid character (like “a”) to the left text field. This will make the
field become red. Now, switch to the right field and type “32”. The left
field will output “0” while being red, though it probably should now be
white.

On Sat, May 25, 2019 at 7:57 PM Travis Hinkelman 
wrote:

> Hi All,
>
> I'm working through the tasks in 7guis
>  to learn about GUI programming
> in Racket. My code
>  for
> the temperature converter task works as expected but there is a lot of
> redundancy in my update-fahrenheit and update-celsius callback functions. I
> would appreciate feedback on how to make this code less redundant.
>
> Thanks,
>
> Travis
>
> --
> 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 racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/8f97260c-62be-4a6f-9459-244a88632ef9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CADcuegukbchny44MGo6cnDH8THEfp74t09%2B0sqZTPa3UNiOa2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.