Re: [racket-users] [racket ursers] Keyword question

2019-08-22 Thread Tim Meehan
If it was just passing keyword arguments to your function, you might be
able to do it like this:

; https://docs.racket-lang.org/guide/lambda.html
; https://docs.racket-lang.org/reference/procedures.html

(define greet
  (lambda (given #:last surname)
(string-append "Hello, " given " " surname)))

; 'apply' allows you to specify a keyword argument ...
(define (test f . args)
  (apply f args #:last "Doe"))

(test greet "John") ; => "Hello, John Doe"

On Thu, Aug 22, 2019 at 3:32 PM Kevin Forchione  wrote:

>
>
> > On Aug 22, 2019, at 1:33 PM, Kevin Forchione  wrote:
> >
> > Hi guys,
> > Suppose I have something like the following:
> >
> > (define (f  g . args)
> >   (apply g args))
> >
> > How would I be able to pass keyword arguments to g?
>
> After racking my brains for the common lisp  and googling
> for the scheme/Racket equivalent, stumbling through  mzlib/kw and finally a
> bit of digging through racket procedure documentation I cobbled together an
> approach that seems to do what I’m after. So I thought I’d share. Here’s an
> example:
>
> #lang racket
>
>
> (define (foo #:a (a 0) #:b (b 1) c (d 3) . rst) (list a b c d rst))
>
> (define show
>   (make-keyword-procedure (λ (kws kw-args f . args) (keyword-apply f kws
> kw-args args
>
> (show foo #:a 10 2 3 4 5 6 7)
> => '(10 1 2 3 (4 5 6 7))
>
> Now apparently any keywords defined for show itself are captured in the
> kWh and kw-args lists and would need to be filtered out of those lists
> before tasing them on to f, but that shouldn’t be too difficult.
>
> 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/395CF1DB-3B85-4FFA-9C1B-5566EB2CC60F%40gmail.com
> .
>

-- 
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/CACgrOxJ%3DAadxH4_9a2u%2B0XZhVpyT2gA-qLtRrhWAy3w2JLRtmw%40mail.gmail.com.


Re: [racket-users] Re: The case, and a proposal, for elegant syntax in #lang racket2

2019-08-22 Thread Gustavo Massaccesi
 [I remember an old discussion about this, but I can't find the message.]
For small number of clauses, case is expanded to a bunch of if. When there
are more than ¿12? it may be use a hash table or binary search. It has a
few tricks:

https://github.com/racket/racket/blob/master/racket/collects/racket/private/case.rkt

Gustavo

On Thu, Aug 22, 2019 at 3:38 PM George Neuner  wrote:

>
> On 8/21/2019 3:25 PM, Jon Zeppieri wrote:
> > Racket's `case` is an implementation of this approach:
> > http://scheme2006.cs.uchicago.edu/07-clinger.pdf
> >
> > It is not significantly complicated by `else`. And that approach was
> > created in the context of Scheme, which leaves the return value
> > unspecified when none of the tests are successful. That seems like it
> > should offer more opportunities for optimization, but I don't think
> > this approach is any less efficient when the unsuccessful result is
> > specified as # (as it is in Racket) than when it is not.
> >
> > - Jon
>
> Thanks for the pointer!
>
> 'case' in Scheme is an interesting challenge for compilation because it
> can involve dispatching on multiple types, each having its own
> comparison ordering.  I would hope that Racket leverages generic table
> searches where possible - depending on the use, generating a complete
> static dispatch routine everywhere can result in explosive growth of the
> code.  [Not that I've seen this happen, but I haven't had occasion to
> experiment in Racket with extremely large or complicated 'case'
> constructs.]
>
> George
>
> --
> 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/a8dd208d-dd3f-a2a7-3d20-3c1027932ac9%40comcast.net
> .
>

-- 
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/CAPaha9PvohKnSZwsnF8gn8hOKejQMpCCVWVPiNmZuQOjO2Odzw%40mail.gmail.com.


[racket-users] [racket ursers] Keyword question

2019-08-22 Thread Kevin Forchione



> On Aug 22, 2019, at 1:33 PM, Kevin Forchione  wrote:
> 
> Hi guys,
> Suppose I have something like the following:
> 
> (define (f  g . args) 
>   (apply g args))
> 
> How would I be able to pass keyword arguments to g? 

After racking my brains for the common lisp  and googling for 
the scheme/Racket equivalent, stumbling through  mzlib/kw and finally a bit of 
digging through racket procedure documentation I cobbled together an approach 
that seems to do what I’m after. So I thought I’d share. Here’s an example:

#lang racket


(define (foo #:a (a 0) #:b (b 1) c (d 3) . rst) (list a b c d rst))

(define show
  (make-keyword-procedure (λ (kws kw-args f . args) (keyword-apply f kws 
kw-args args

(show foo #:a 10 2 3 4 5 6 7)
=> '(10 1 2 3 (4 5 6 7))

Now apparently any keywords defined for show itself are captured in the kWh and 
kw-args lists and would need to be filtered out of those lists before tasing 
them on to f, but that shouldn’t be too difficult.

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/395CF1DB-3B85-4FFA-9C1B-5566EB2CC60F%40gmail.com.


Re: [racket-users] (curry map string->number) in Typed Racket

2019-08-22 Thread Jon Zeppieri
(curry (inst map (U Complex False) String)
 string->number)

... typechecks, but in your expression, you're going to need to handle
the possibility that the pattern variables in `list-rest` pattern are
#f.

- Jon

On Thu, Aug 22, 2019 at 4:15 PM Štěpán Němec  wrote:
>
>
> I have a hard time persuading Typed Racket to accept the expression
> "(curry map string->number)". No amount of type annotations or added
> `inst`s (as recommended by the guide[1]) I could come up with seem to
> help.
>
> Is there a way to make it work?
>
> [1] 
> https://docs.racket-lang.org/ts-guide/caveats.html#%28part._.Type_inference_for_polymorphic_functions%29
>
> Here's an example with a bit more context (solely for illustration
> purposes; I couldn't make the simple expression above work even
> isolated):
>
> (match-let ([(pregexp "#\\d+ +@ +(\\d+),(\\d+): +(\\d+)x(\\d+)"
>   (list-rest _ (app (curry map string->number)
> (list x y dx dy
>  "#1299 @ 414,871: 29x11"])
>   x)
>
> Thank you,
>
>   Štěpán
>
> --
> 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/8736hths88.fsf%40gmail.com.

-- 
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/CAKfDxxwOSK%3DAg0tw%3DtQgvZ9sRrnXt_J7YSz12V1wvLYRusfOzQ%40mail.gmail.com.


[racket-users] [racket ursers] Keyword question

2019-08-22 Thread Kevin Forchione
Hi guys,
Suppose I have something like the following:

(define (f  g . args) 
   (apply g args))

How would I be able to pass keyword arguments to g? 

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/CAD069C0-09B7-4984-B1F6-19AE2A85CF29%40gmail.com.


[racket-users] (curry map string->number) in Typed Racket

2019-08-22 Thread Štěpán Němec


I have a hard time persuading Typed Racket to accept the expression
"(curry map string->number)". No amount of type annotations or added
`inst`s (as recommended by the guide[1]) I could come up with seem to
help.

Is there a way to make it work?

[1] 
https://docs.racket-lang.org/ts-guide/caveats.html#%28part._.Type_inference_for_polymorphic_functions%29

Here's an example with a bit more context (solely for illustration
purposes; I couldn't make the simple expression above work even
isolated):

(match-let ([(pregexp "#\\d+ +@ +(\\d+),(\\d+): +(\\d+)x(\\d+)"
  (list-rest _ (app (curry map string->number)
(list x y dx dy
 "#1299 @ 414,871: 29x11"])
  x)

Thank you,

  Štěpán

-- 
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/8736hths88.fsf%40gmail.com.


[racket-users] Re: Splicing the result of one macro into another

2019-08-22 Thread Michael Ballantyne
Here's another implementation you might consider. In this version you can 
view the body of `phone-numbers` as a language consisting of the `number` 
and `number-list` syntactic forms. The language also supports its own kind 
of macros---phone number macros---that can expand to forms of the 
`phone-numbers` body language. `number` and `add-prefix` aren't allowed 
outside of `phone-numbers`, because they're thought of as a part of that 
language rather than Racket expressions on their own. 
`expand+extract-number` is a tiny macro expander for the language.

```
#lang racket

(require (for-syntax syntax/parse syntax/apply-transformer))

(define-syntax number
  (lambda (stx)
(raise-syntax-error #f "number can only be used in phone-numbers 
syntax" stx)))
(define-syntax number-list
  (lambda (stx)
(raise-syntax-error #f "number-list can only be used in phone-numbers 
syntax" stx)))

(begin-for-syntax
  (struct phone-number-macro (proc)
#:property prop:procedure
(lambda (s stx) (raise-syntax-error #f "phone number macros can only be 
used in phone-numbers syntax" stx

(define-syntax (phone-numbers stx)
  (define (expand+extract-number stx)
(syntax-parse stx
  #:literals (number number-list)
  [(number s:string)
   (list #'s)]
  [(number-list num ...)
   (apply append (map expand+extract-number (syntax->list #'(num 
...]
  [(head . rest)
   #:do [(define v (syntax-local-value #'head (lambda () #f)))]
   #:when (phone-number-macro? v)
   (expand+extract-number
(local-apply-transformer (phone-number-macro-proc v)
 this-syntax
 'expression
 '()))]))

  (syntax-parse stx
[(_ num ...)
 (define expanded-nums
   (apply append (map expand+extract-number (syntax->list #'(num 
...)
 #`(list #,@expanded-nums)]))

(phone-numbers
 (number "123")
 (number-list (number "123")))

(define-syntax add-prefix
  (phone-number-macro
   (syntax-parser
 [(_ prefix ((~literal number) str) ...)
  #:with (prefixed ...) (map (λ (s)
   (datum->syntax
this-syntax
(string-append (syntax-e #'prefix)
   (syntax-e s
 (attribute str))
  #'(number-list (number prefixed) ...)])))

(phone-numbers
 (add-prefix "555"
 (number "1212")
 (number "2121"))
 (number "1234"))
```


On Tuesday, August 20, 2019 at 6:13:21 PM UTC-4, Brian Adkins wrote:
>
> Consider the following two macros:
>
> (require (for-syntax syntax/parse))
>
> (define-syntax (phone-numbers stx)
>   (syntax-parse stx
> [(_ ((~literal number) phone) ...)
>  #'(list phone ...)]))
>
> (define x (phone-numbers
>(number "1212")
>(number "2121"))) ; ==> '("1212" "2121")
>
> (define-syntax (add-prefix stx)
>   (syntax-parse stx
> [(_ prefix ((~literal number) str) ...)
>  #'(list (list 'number (string-append prefix str)) ...)]))
>
> (define y (add-prefix "555"
>   (number "1212")
>   (number "2121"))) ; ==> '((number "5551212") (number 
> "5552121"))
>
> I would like to be able to do the following:
>
> (phone-numbers
>  (add-prefix "555"
>  (number "1212")
>  (number "2121"))
>  (number "1234")) ; ==> '("5551212" "5552121" "1234")
>
> I was hoping it would be possible to do this without modifying the 
> phone-numbers macro. In other words, to have the result of expanding 
> add-prefix macro call be:
>
> (number "5551212") (number "5552121")
>
> So that it would appear to the phone-numbers macro as if the user had 
> actually typed:
>
> (phone-numbers
>   (number "5551212")
>   (number "5552121")
>   (number "1234"))
>
> Is it possible to do this w/o the explicit cooperation of the 
> phone-numbers macro?
>
> Brian Adkins
>

-- 
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/262b8824-ab94-47a1-b6be-88216c0de937%40googlegroups.com.


Re: [racket-users] Re: The case, and a proposal, for elegant syntax in #lang racket2

2019-08-22 Thread George Neuner



On 8/21/2019 3:25 PM, Jon Zeppieri wrote:

Racket's `case` is an implementation of this approach:
http://scheme2006.cs.uchicago.edu/07-clinger.pdf

It is not significantly complicated by `else`. And that approach was
created in the context of Scheme, which leaves the return value
unspecified when none of the tests are successful. That seems like it
should offer more opportunities for optimization, but I don't think
this approach is any less efficient when the unsuccessful result is
specified as # (as it is in Racket) than when it is not.

- Jon


Thanks for the pointer!

'case' in Scheme is an interesting challenge for compilation because it 
can involve dispatching on multiple types, each having its own 
comparison ordering.  I would hope that Racket leverages generic table 
searches where possible - depending on the use, generating a complete 
static dispatch routine everywhere can result in explosive growth of the 
code.  [Not that I've seen this happen, but I haven't had occasion to 
experiment in Racket with extremely large or complicated 'case'  
constructs.]


George

--
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/a8dd208d-dd3f-a2a7-3d20-3c1027932ac9%40comcast.net.


[racket-users] The truth about the death of Charles Aznavour

2019-08-22 Thread Steve Brown
Why do we have to question Canadians to know the causes of the death of 
Charles Aznavour ?

Charles Aznavour was murdered after what he said in an interview. Canada, 
like many other countries, disseminates information on litigations against 
foreign governments and these code-form (wooden language) that Aznavour 
delivered the opinion that was fatal. His death is totally accidental. 
However, he had done nothing illegal and, what is serious, was in no way 
indebted to canada. His death was caused by the work of a pure incompetent. 
The reprisals against him had no foundation and originated from a total 
lack of judgment.

You have to know that Canada is a very beautiful country, and the Canadian 
people are a great people, but the same is not true of their politicians 
who are highly corrupt and who periodically engage in human rights abuses. 

This is how Charles Aznavour died in perfect health.

-- 
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/94ccafa5-cf28-47f5-b27f-12318fa4839f%40googlegroups.com.


Re: [racket-users] Racket News - Issue 14

2019-08-22 Thread Stephen Foster
By the way, Paulo: I'm happy to help with this (if you want).  I can either
put in some person-hours to get/install the certificate; and/or help
purchase a new one.

On a related note, a meta question for the community: Do we have any
infrastructures in place to help financially support community-driven
initiatives like this newsletter?  For example: certs and hosting costs.
Or does it just come out of individual pockets?



On Wed, Aug 21, 2019 at 11:43 AM Annaia Berry  wrote:

> the SSL cert seems to have expired the other day.
>
> On Wed, Aug 21, 2019 at 8:37 PM Stephen Foster 
> wrote:
>
>> My browser is telling me that the SSL certificate for racket-news.com is
>> invalid.
>> Is it just me?
>>
>> On Monday, August 19, 2019 at 7:54:54 AM UTC-7, Stephen De Gabrielle
>> wrote:
>>>
>>> Thank you Paulo!
>>> Another awesome issue of Racket News.
>>>
>>> S.
>>>
>>>
>>>
>>>
>>> On Fri, Aug 16, 2019 at 9:49 PM Paulo Matos  wrote:
>>>
 Racket News issue 14 is here.
 https://racket-news.com/2019/08/racket-news-issue-14.html

 Enjoy!

 --
 Paulo Matos

 --
 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...@googlegroups.com.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/racket-users/05377b52-dc75-09ce-97b6-5c9734bbaec3%40linki.tools
 .

>>> --
>> 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/9586f6ed-f0b3-4889-abf7-77e3a436537e%40googlegroups.com
>> 
>> .
>>
>

-- 


Stephen Foster
ThoughtSTEM Co-Founder
318-792-2035

-- 
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/CA%2BzSu2_mdxK22FYCQYd1k0odBJpM0nS_tSLNxtjmY6qSd0C-qw%40mail.gmail.com.


Re: [racket-users] Code generation options for a self-made compiler

2019-08-22 Thread Matthew Flatt
At Tue, 20 Aug 2019 17:53:45 +0300, Dmitry Pavlov wrote:
> > Your tool would use `make-compilation-manager-load/use-compiled-handler`
> 
> In what way my tool would use that?

I think you probably don't want to go this way. But if you want to
support multiple build variants within the same tree, you could use the
"compiled" subpath to effectively select among those variants.

> To be clear, I care about my own options (C/Racket code and 
> 64-bit/80-bit reals) rather than the options that DrRacket currently 
> provides to user.

Right. I meant only that you might do something similar to what
DrRacket does, but with your own "compiled" subpaths instead of
subpaths like "compiled/drracket/errortrace".


Matthew

-- 
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/20190822150100.25C53650159%40mail-svr1.cs.utah.edu.


Re: [racket-users] Seeking good benchmark code for immutable hash and hash set usage

2019-08-22 Thread Robby Findler
(sorry for the self-followup; the unifier uses immutable hashes; grep
suggests the other hashes that get used a lot are mutable hashes)

On Thu, Aug 22, 2019 at 9:33 AM Robby Findler  wrote:
>
> It looks like the pattern unifier uses hashes. I'm not sure if it they
> would end up being good benchmarks (probably best to try to instrument
> the hashes to see if they actually get  used a lot or not) but there
> are redex benchmarks that measure how long it takes to find specific
> bugs and one of the generators they use involves the pattern unifier.
>
> https://docs.racket-lang.org/redex/benchmark.html
>
> I'm happy to help provide more pointers if it seems useful
>
> Robby
>
> On Wed, Aug 21, 2019 at 9:04 PM Ben Greenman
>  wrote:
> >
> > A few of the GTP benchmarks [1] use immutable hashes. Here's a link
> > with the ones that look most interesting:
> >
> > http://ccs.neu.edu/home/types/tmp/gtp-hash.tar.gz
> >
> >
> > And here's a small (untyped) program that uses code from the tr-pfds
> > library to make a trie:
> >
> > http://ccs.neu.edu/home/types/tmp/trie.tar.gz
> >
> >
> > Redex and the graph library might be good places to look for other
> > examples. I know graph uses lots of hashes internally, and I bet Redex
> > does too.
> >
> > [1] https://github.com/bennn/gtp-benchmarks
> >
> > On 8/14/19, Jon Zeppieri  wrote:
> > > Hello Racketeers,
> > >
> > > I'm looking for examples of code that would make good benchmarks for
> > > evaluating the performance of immutable hashes.
> > >
> > > Some background:
> > > Immutable hashes used to be implemented in Racket as red-black trees.
> > > That was changed to hash array mapped tries (HAMTs) a number of years
> > > back. In Racket CS, the current implementation is a Patricia trie.
> > > That choice was based largely on the fact that it performed
> > > significantly faster on the hash demo benchmarks[1] that any of the
> > > HAMT variants I tested against. In particular, the write performance
> > > of the HAMTs seemed especially poor.
> > >
> > > However, on some real-world code[2] I recently had occasion to test, a
> > > HAMT consistently performs better than the Patricia trie, _especially_
> > > on writes, which makes me think I put entirely too much weight on the
> > > hash demo benchmark.
> > >
> > > So I'm looking for more realistic cases to use for benchmarking. If
> > > you have a Racket application or library that makes heavy use of
> > > immutable hashes or hash sets (from the racket/set module), please let
> > > me know.
> > >
> > > Thanks,
> > > Jon
> > >
> > > [1] 
> > > https://github.com/racket/racket/blob/master/racket/src/cs/demo/hash.ss
> > > I also tried to use the expander demo as a benchmark, but the timings
> > > weren't significantly different with different hash implementations.
> > >
> > > [2] https://github.com/racket/racket/pull/2766#issuecomment-520173585
> > > Well, it's a lot closer to real-world code than the hash demo.
> > >
> > > --
> > > 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/CAKfDxxwjPcWewzo2X5uXGH06Ud1hjURNuKFW59duXrZq4-7tWQ%40mail.gmail.com.
> > >
> >
> > --
> > 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/CAFUu9R4dwNWS28MyApTYUkiQ-%2BhV%3DuWPBAF77xMV-wNsDMduLw%40mail.gmail.com.

-- 
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/CAL3TdOOrCRQ1FC%2BxU-tUgt5c2YjdJyxLCeuDpDwDgat%3DEe-aiA%40mail.gmail.com.


Re: [racket-users] Seeking good benchmark code for immutable hash and hash set usage

2019-08-22 Thread Robby Findler
It looks like the pattern unifier uses hashes. I'm not sure if it they
would end up being good benchmarks (probably best to try to instrument
the hashes to see if they actually get  used a lot or not) but there
are redex benchmarks that measure how long it takes to find specific
bugs and one of the generators they use involves the pattern unifier.

https://docs.racket-lang.org/redex/benchmark.html

I'm happy to help provide more pointers if it seems useful

Robby

On Wed, Aug 21, 2019 at 9:04 PM Ben Greenman
 wrote:
>
> A few of the GTP benchmarks [1] use immutable hashes. Here's a link
> with the ones that look most interesting:
>
> http://ccs.neu.edu/home/types/tmp/gtp-hash.tar.gz
>
>
> And here's a small (untyped) program that uses code from the tr-pfds
> library to make a trie:
>
> http://ccs.neu.edu/home/types/tmp/trie.tar.gz
>
>
> Redex and the graph library might be good places to look for other
> examples. I know graph uses lots of hashes internally, and I bet Redex
> does too.
>
> [1] https://github.com/bennn/gtp-benchmarks
>
> On 8/14/19, Jon Zeppieri  wrote:
> > Hello Racketeers,
> >
> > I'm looking for examples of code that would make good benchmarks for
> > evaluating the performance of immutable hashes.
> >
> > Some background:
> > Immutable hashes used to be implemented in Racket as red-black trees.
> > That was changed to hash array mapped tries (HAMTs) a number of years
> > back. In Racket CS, the current implementation is a Patricia trie.
> > That choice was based largely on the fact that it performed
> > significantly faster on the hash demo benchmarks[1] that any of the
> > HAMT variants I tested against. In particular, the write performance
> > of the HAMTs seemed especially poor.
> >
> > However, on some real-world code[2] I recently had occasion to test, a
> > HAMT consistently performs better than the Patricia trie, _especially_
> > on writes, which makes me think I put entirely too much weight on the
> > hash demo benchmark.
> >
> > So I'm looking for more realistic cases to use for benchmarking. If
> > you have a Racket application or library that makes heavy use of
> > immutable hashes or hash sets (from the racket/set module), please let
> > me know.
> >
> > Thanks,
> > Jon
> >
> > [1] https://github.com/racket/racket/blob/master/racket/src/cs/demo/hash.ss
> > I also tried to use the expander demo as a benchmark, but the timings
> > weren't significantly different with different hash implementations.
> >
> > [2] https://github.com/racket/racket/pull/2766#issuecomment-520173585
> > Well, it's a lot closer to real-world code than the hash demo.
> >
> > --
> > 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/CAKfDxxwjPcWewzo2X5uXGH06Ud1hjURNuKFW59duXrZq4-7tWQ%40mail.gmail.com.
> >
>
> --
> 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/CAFUu9R4dwNWS28MyApTYUkiQ-%2BhV%3DuWPBAF77xMV-wNsDMduLw%40mail.gmail.com.

-- 
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/CAL3TdOP9yZisqcK%2B96f5BW8YbarfHkyTkcQNf7GxHKva%3D1JsDw%40mail.gmail.com.


[racket-users] Re: Error when I try to use slideshow?

2019-08-22 Thread Stephen De Gabrielle
Thanks Alex!

On Thursday, August 22, 2019 at 1:58:13 PM UTC+9, Alex Harsanyi wrote:
>
> This may or may not work for them, but ask the user to open the 
> "viewer.rkt" file in their racket installation (it should be in C:\Program 
> Files\Racket\share\pkgs\slideshow-lib\slideshow) and comment out the 
> `set-icon` call around line 1512.   That is, comment out the following 
> block:
>
> (let* ([bm slideshow-bm]
>[mbm slideshow-mbm])
>   (when (send bm ok?)
> (send f set-icon bm (and (send mbm ok?) mbm) 'both)))
>
> This is the line in GitHub:
>
>
> https://github.com/racket/slideshow/blob/c61c80de63cf7b2197d67c078bdc9133823c0030/slideshow-lib/slideshow/viewer.rkt#L1509
>
> ---
>
> Others may come up with better workarounds, but this looks to me like a 
> problem with the Racket GUI library.  Slideshow fails on my home PC but 
> works on my work PC, both Windows 10 but different build numbers.  The 
> problem is that the windows CreateIconIndirect API call is passed an 
> invalid parameter (this is what code 87 means).  Not sure what the invalid 
> parameter is (or why it is invalid), but it is probably either the bitmap 
> or the mask.
>
> Alex.
>
> On Thursday, August 22, 2019 at 11:40:45 AM UTC+8, Stephen De Gabrielle 
> wrote:
>>
>> Hi
>>
>> I’m trying to help a user who is getting an error when trying to run 
>> slideshow:
>>
>> I typed "#lang slideshow" into DrRacket and got the following error:
>>
>> CreateIconIndirect: call failed (87)
>>
>> Interactions disabled: slideshow does not support a REPL (no 
>> #%top-interaction)
>>
>> They have two computers - slideshow works on a newer pc(win 10) but fails 
>> on one that has been upgraded from windows 7 to 10. I can’t determine any 
>> other difference.
>>
>>
>> Any ideas how I can help this user ?
>>
>>
>>
>> https://www.reddit.com/r/Racket/comments/ct95b0/error_when_i_try_to_use_slideshow/?utm_source=share_medium=ios_app
>>
>>
>> Kind regards
>>
>> Stephen
>>
>

-- 
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/1c6da499-8c23-48b7-88c3-f05c2179a42a%40googlegroups.com.


Re: [racket-users] handin-server: writing a first checker

2019-08-22 Thread Matthew Flatt
I'm not able to provoke this error with the pieces that you provided.

Just to be sure, it's not an error in the submission that you sent to
the handin server, right? Normally the error in that case would be
"Error in your code", so I think that's not it. But does the error
depend on the program that you send as a submission?

At Wed, 21 Aug 2019 21:32:58 +, "'Wayne Harris' via Racket Users" wrote:
> I haven't been able to write a first checker.  I'm always getting
> 
>   map: all lists must have same size
> 
> in the server's log.
> 
> The submission always shows this in the log file:
> 
> [16|2019-08-21T21:12:35] connect from 191.35.15.190
> [16|2019-08-21T21:12:39] running 12KB (123MB 133MB)
> [16|2019-08-21T21:12:39] login: (wharr...@protonmail.com)
> [16|2019-08-21T21:12:39] assignment for (wharr...@protonmail.com): 
> assignment-1
> [16|2019-08-21T21:12:40] timeout-control: reset
> [16|2019-08-21T21:12:40] checking assignment-1 for (wharr...@protonmail.com)
> [16|2019-08-21T21:12:42] running 37KB (123MB 133MB)
> [16|2019-08-21T21:12:46] running 37KB (123MB 133MB)
> [16|2019-08-21T21:12:49] running 39KB (123MB 133MB)
> [16|2019-08-21T21:12:52] ERROR: map: all lists must have same size
> [16|2019-08-21T21:12:52]   first list length: 3
> [16|2019-08-21T21:12:52]   other list length: 1
> [16|2019-08-21T21:12:52]   procedure: #
> 
> It also pops up the message error message to the student in DrRacket.
> 
> Any ideas what's causing this?
> 
> Taking the typical checker from the documentation, I started with:
> 
> (module checker handin-server/checker
>   (check: :language  '(special intermediate)
> (!procedure Fahrenheit->Celsius 1)
> (!test (Fahrenheit->Celsius  32)   0)
> (!test (Fahrenheit->Celsius 212) 100)
> (!test (Fahrenheit->Celsius  -4) -20)))
> 
> My student code in DrRacket is set to intermediate language and the
> code is:
> 
> (define (Fahrenheit->Celsius x)
>   (* 5/9 (- x 32)))
> 
> (check-expect (Fahrenheit->Celsius 32) 0)
> 
> Here's my server configuration:
> 
> $ cat config.rktd
>  ((active-dirs ("assignment-1"))
>   (allow-web-upload #t)
>   (allow-new-users #t)
>   (master-password "4c96f8324e3ba54a99e78249b95daa30"))
> $
> 
> $ cat users.rktd
> (
>  (wharr...@protonmail.com ("4c96f8324e3ba54a99e78249b95daa30" "Wayne Harris"))
> )
> $
> 
> $ cat assignment-1/checker.rkt
> (module checker handin-server/checker
>   (check: :language  '(special intermediate)
> (!procedure Fahrenheit->Celsius 1)
> (!test (Fahrenheit->Celsius  32)   0)
> (!test (Fahrenheit->Celsius 212) 100)
> (!test (Fahrenheit->Celsius  -4) -20)))
> $
> 
> -- 
> 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/Le2v4fuorTS76ru-EzIcXTxB9t0I3wyV
> 56qTFtRFY8cErV3l4mIJVUsi-s9qSlv7Q_2PVix-prxqDh5noOcmrlm3yyeB7gdBx02fwaUICW8%3D%
> 40protonmail.com.

-- 
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/5d5ea010.1c69fb81.71fbf.0dbdSMTPIN_ADDED_MISSING%40gmr-mx.google.com.


Re: [racket-users] Seeking good benchmark code for immutable hash and hash set usage

2019-08-22 Thread Jon Zeppieri
Thanks Ben! - Jon

On Wed, Aug 21, 2019 at 10:04 PM Ben Greenman
 wrote:
>
> A few of the GTP benchmarks [1] use immutable hashes. Here's a link
> with the ones that look most interesting:
>
> http://ccs.neu.edu/home/types/tmp/gtp-hash.tar.gz
>
>
> And here's a small (untyped) program that uses code from the tr-pfds
> library to make a trie:
>
> http://ccs.neu.edu/home/types/tmp/trie.tar.gz
>
>
> Redex and the graph library might be good places to look for other
> examples. I know graph uses lots of hashes internally, and I bet Redex
> does too.
>
> [1] https://github.com/bennn/gtp-benchmarks
>
> On 8/14/19, Jon Zeppieri  wrote:
> > Hello Racketeers,
> >
> > I'm looking for examples of code that would make good benchmarks for
> > evaluating the performance of immutable hashes.
> >
> > Some background:
> > Immutable hashes used to be implemented in Racket as red-black trees.
> > That was changed to hash array mapped tries (HAMTs) a number of years
> > back. In Racket CS, the current implementation is a Patricia trie.
> > That choice was based largely on the fact that it performed
> > significantly faster on the hash demo benchmarks[1] that any of the
> > HAMT variants I tested against. In particular, the write performance
> > of the HAMTs seemed especially poor.
> >
> > However, on some real-world code[2] I recently had occasion to test, a
> > HAMT consistently performs better than the Patricia trie, _especially_
> > on writes, which makes me think I put entirely too much weight on the
> > hash demo benchmark.
> >
> > So I'm looking for more realistic cases to use for benchmarking. If
> > you have a Racket application or library that makes heavy use of
> > immutable hashes or hash sets (from the racket/set module), please let
> > me know.
> >
> > Thanks,
> > Jon
> >
> > [1] https://github.com/racket/racket/blob/master/racket/src/cs/demo/hash.ss
> > I also tried to use the expander demo as a benchmark, but the timings
> > weren't significantly different with different hash implementations.
> >
> > [2] https://github.com/racket/racket/pull/2766#issuecomment-520173585
> > Well, it's a lot closer to real-world code than the hash demo.
> >
> > --
> > 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/CAKfDxxwjPcWewzo2X5uXGH06Ud1hjURNuKFW59duXrZq4-7tWQ%40mail.gmail.com.
> >

-- 
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/CAKfDxxxYbOqjpy2GsLtumrK9q7vcfv_42c%3DR%3DAJXBO%2BhbJ%2BnUQ%40mail.gmail.com.