
@dear.rafe has joined the channel

Hello! Does racket’s pattern matching have anything like Haskell’s as-patterns? In Haskell I might write something like fn [x, ys@[y1, y2]] = y1:ys
, which matches a two element list, where the second element is also a two element list. I capture the second element of the outer list as ys, and its inner elements as y1
and y2

@dear.rafe your name is somewhat hard to type :slightly_smiling_face: You can just use (and ys (list y1 y2))
for that

Sorry, didn’t think of that! Changed it to ascii now

Great, thank you! That’s what I get for skipping parts of the docs that didn’t seem relevant

That’s perfect, thank you

Also, am I correct in thinking that one would match a hash table constructed with (hash ...)
with (hash-table ...)
? Is there any function which both constructs and matches a hash table?

yes, that’s correct, and wasn’t a good naming choice (although I think it was before my time)

OK, gotcha

Is there something like mlist-set
? I know mlist
s are discouraged, but I’m compiling to Racket and I want to keep the semantics of the mutable array in the source language

Use mlist-tail, then set-mcar!

OK cool. I’ll write a little helper for that. Thanks!

That’s me for question time today! Thanks for all the help. Hope I wasn’t too spammy (just let me know if I was)