dear.rafe
2018-8-17 14:17:00

@dear.rafe has joined the channel


dear.rafe
2018-8-17 14:20:21

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


samth
2018-8-17 14:22:05

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


dear.rafe
2018-8-17 14:23:07

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


dear.rafe
2018-8-17 14:23:36

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


dear.rafe
2018-8-17 14:23:47

That’s perfect, thank you


dear.rafe
2018-8-17 14:32:05

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?


samth
2018-8-17 14:32:47

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


dear.rafe
2018-8-17 14:35:17

OK, gotcha


dear.rafe
2018-8-17 17:09:40

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


soegaard2
2018-8-17 17:11:05

Use mlist-tail, then set-mcar!


dear.rafe
2018-8-17 17:23:21

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


dear.rafe
2018-8-17 17:29:49

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)