Stream: beginners

Topic: Capture rest in list pattern matching?


view this post on Zulip Sebastian Porto (Dec 14 2022 at 10:32):

Reading about list pattern matching in Roc https://www.roc-lang.org/tutorial#pattern-matching-on-lists

Is it possible to bind the rest to a variable?

when list is
  [a, b, c, d, ..rest] ->

view this post on Zulip Luke Boswell (Dec 14 2022 at 10:35):

I'm pretty sure that is not supported. I recall it being discussed somewhere, I'll see if I can dig a reference out for you.

view this post on Zulip Luke Boswell (Dec 14 2022 at 10:37):

Zulip discussion here if you want to read more about it. :smiley:

view this post on Zulip Luke Boswell (Dec 14 2022 at 10:38):

If your interested the seamless slices is pretty neat, you can also read more about it in Richard's design doc.

view this post on Zulip Sebastian Porto (Dec 14 2022 at 10:41):

thanks


Last updated: Jul 06 2025 at 12:14 UTC