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
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
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
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
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
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
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
7 matches
Mail list logo