Re: [racket-users] Using match on hash tables with optional keys

2018-08-30 Thread Greg Hendershott
A general trick for optional values with match is something like (or pat (app (λ _ default-value) pat)). But that doesn't work for hash-table which uses [pat path] for each mapping. (At least I couldn't see how.) Here's _a_ way you could write this as a match pattern: (define ((hash-has-keys? key

Re: [racket-users] Using match on hash tables with optional keys

2018-08-30 Thread George Neuner
On 8/30/2018 11:36 AM, David Storrs wrote: I'd like to be able to write something like this: (match (hash 'a 1 'b 2)   [(hash-table ('a a) ('b b) ('c c))  (list a b c)]) ...except with something that says "if 'c isn't present, that's fine.  Use this value instead." I've gone through the pag

Re: [racket-users] Using match on hash tables with optional keys

2018-08-30 Thread David Storrs
On Thu, Aug 30, 2018 at 12:20 PM, Matthew Butterick wrote: > > On Aug 30, 2018, at 8:36 AM, David Storrs wrote: > > I'd like to be able to write something like this: > > (match (hash 'a 1 'b 2) > [(hash-table ('a a) ('b b) ('c c)) (list a b c)]) > > ...except with something that says "if 'c i

Re: [racket-users] Using match on hash tables with optional keys

2018-08-30 Thread David Storrs
Cool, thank you. On Thu, Aug 30, 2018 at 11:38 AM, Sam Tobin-Hochstadt wrote: > No, there isn't something here that you're missing. An addition here > would probably be useful, though -- you might take a look at how > Clojure does this, since they pattern match on a lot of dictionaries. > > Sam

Re: [racket-users] Using match on hash tables with optional keys

2018-08-30 Thread Sam Tobin-Hochstadt
No, there isn't something here that you're missing. An addition here would probably be useful, though -- you might take a look at how Clojure does this, since they pattern match on a lot of dictionaries. Sam On Thu, Aug 30, 2018 at 11:36 AM David Storrs wrote: > > I'd like to be able to write som

[racket-users] Using match on hash tables with optional keys

2018-08-30 Thread David Storrs
I'd like to be able to write something like this: (match (hash 'a 1 'b 2) [(hash-table ('a a) ('b b) ('c c)) (list a b c)]) ...except with something that says "if 'c isn't present, that's fine. Use this value instead." I've gone through the page on pattern matching and been unable to find an

Re: [racket-users] Legal/Business Case Management DSLs

2018-08-30 Thread Richard Parsons
Again, thank you all for your information and input which has been invaluable. I will now go away and have a think about everything. If I decide to proceed then I will prepare a specification or roadmap document and then post it on Github. Many thanks Richard On Mon, Aug 27, 2018 at 4:54 PM, Wil