>(define not-found (gensym 'not-found))
>(define (not-not-found? x) (not (eq? x not-found)))
> ...
> #'(app (lambda (h) (hash-ref h key not-found))
>(? not-not-found? value-pattern)))
Oh dang. I shouldn't not have thought of that.
Nice!
--
You re
Summary of the thread:
"Hey, here's this thing I'd like to do. Is there a way to do it?"
T = : "Nope. Here's some suggestions, though."
T = 22 hours: "Here, let me add that feature to the language."
Man, I love this community. Thank you to everyone.
On Fri, Aug 31, 2018 at 5:46 AM, Ryan
On 8/31/18 4:28 AM, Greg Hendershott wrote:
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 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
8 matches
Mail list logo