Pattern Matching

There have been quite a few questions recently about the pattern type in the CL documentation, so I thought I’d record a few short videos to help you get started. I’ll share here each time a new video is posted, and we’ll also keep them in a playlist on our YouTube channel.

First up: Scientific Notation


Tutorial #2: Fractions

1 Like

Tutorial #3 More Complex Patterns


Hey Jay, I was able to follow along with the pattern matching but I was curious if you have a copy of the original slide where you broke down the exponents as feedback for students. I wasn’t sure how you were able to make the series of /cdots.

Thanks in advance.

It’s linked in the video description!

Spoiler alert, they’re points.


Haha, I thought they might be. I mean, I had in mind how I might build it. But I’m always looking for more tools in the tool kit! Pattern Matching might be my new side project :wink:

Wondering if there is a way to use pattern matching for ratio notation ___ : ___ ?

No pattern for that, sorry

1 Like

Any way to build that up from other pieces? Could I parse out if there is a number to the left and right of the colon?

Not with patterns, no.

Pattern Matching with CL tutorial 4/5 - Building more flexible patterns.

Final video coming out later this week… using patterns for correctness :scream:

Awesome… Thanks for all the support you provide, it has made my lessons so much more interactive this school year and I look forward to embed it into my daily lessons next year… Fun stuff.

These videos have definitely been really useful and help to not only learn how to use Pattern matching, but strategies for simplifying the CL code.

Our last pattern matching tutorial is on using patterns to help mark correctness and its a double feature!

First example starts at 1:32
Second example starts at 12:29

1 Like

Is there anyway to use p.literal for parsing (parentheses, period, bracket, etc.)?

For example can I pattern match to check if a student is putting a 0 before their decimal point?

Not really, no. The literal pattern is like a character match but for only numbers and letters (including Greek)

If you’re only looking at positive numbers then I guess there’s a way to do that without pattern matching. What’s the used case?

For the decimal, I needed it to have a zero in front for something else I was validating, but I found a workaround.

For the bracket/parentheses it is to validate interval notation, similar to using parse ordered pair. Or to parse interval notation for say domain and range and have student inputs be able to graph inequalities as if the domain/range was in interval notation. Currently, I just have it where students must enter it with parentheses and I parse ordered pair.

Got it. Sorry, nothing for those symbols yet.

Jay, this video (3/5) is marked as “Playback on other websites has been disabled by the video owner”. The first three parts of this series worked inline.

It does work just fine on youtube!

I can’t find the pattern reference in the documentation anymore. I vaguely remember seeing patterns at the bottom of the old documentation, but I can’t find it anywhere in the new documentation. Is this still documented anywhere?