# Pattern Matching

**URL:** <https://cl.desmos.com/t/pattern-matching/2972>\
**Category:** Discussion\
**Tags:** patterns\
**Created:** [March 22, 2021, 10:07pm UTC](https://cl.desmos.com/t/pattern-matching/2972 "2021-03-22T22:07:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [March 22, 2021, 10:07pm UTC](https://cl.desmos.com/t/pattern-matching/2972/1 "2021-03-22T22:07:36Z")

</div>

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

[![](https://i.ytimg.com/vi/NtDJdVW5uMk/hqdefault.jpg "Scientific Pattern") ](https://www.youtube.com/watch?v=NtDJdVW5uMk)

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [March 24, 2021, 3:48pm UTC](https://cl.desmos.com/t/pattern-matching/2972/2 "2021-03-24T15:48:56Z")

</div>

Tutorial #2: Fractions

[![](https://img.youtube.com/vi/EEfBweAWVEM/hqdefault.jpg "Fraction Pattern") ](https://www.youtube.com/watch?v=EEfBweAWVEM)

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [March 27, 2021, 12:58am UTC](https://cl.desmos.com/t/pattern-matching/2972/3 "2021-03-27T00:58:29Z")

</div>

Tutorial #3 More Complex Patterns

[![](https://img.youtube.com/vi/9TNf4sZ2iD4/hqdefault.jpg "More Complex Patterns") ](https://www.youtube.com/watch?v=9TNf4sZ2iD4)

---

<div class="post-metadata">

**Author:** ![HumanizedMath](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/humanizedmath/32/2947_2.png) [@HumanizedMath](https://cl.desmos.com/u/HumanizedMath)\
**Post date:** [March 27, 2021, 2:33am UTC](https://cl.desmos.com/t/pattern-matching/2972/4 "2021-03-27T02:33:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [March 27, 2021, 2:41am UTC](https://cl.desmos.com/t/pattern-matching/2972/5 "2021-03-27T02:41:55Z")

</div>

It’s linked in the video description!

Spoiler alert, they’re points.

---

<div class="post-metadata">

**Author:** ![HumanizedMath](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/humanizedmath/32/2947_2.png) [@HumanizedMath](https://cl.desmos.com/u/HumanizedMath)\
**Post date:** [March 27, 2021, 11:25am UTC](https://cl.desmos.com/t/pattern-matching/2972/6 "2021-03-27T11:25:00Z")

</div>

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 😉

---

<div class="post-metadata">

**Author:** ![Jeff\_Holcomb](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jeff_holcomb/32/433_2.png) [@Jeff\_Holcomb](https://cl.desmos.com/u/Jeff_Holcomb)\
**Post date:** [March 28, 2021, 3:43pm UTC](https://cl.desmos.com/t/pattern-matching/2972/7 "2021-03-28T15:43:47Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [March 28, 2021, 4:45pm UTC](https://cl.desmos.com/t/pattern-matching/2972/8 "2021-03-28T16:45:36Z")

</div>

No pattern for that, sorry

---

<div class="post-metadata">

**Author:** ![Jeff\_Holcomb](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jeff_holcomb/32/433_2.png) [@Jeff\_Holcomb](https://cl.desmos.com/u/Jeff_Holcomb)\
**Post date:** [March 28, 2021, 5:15pm UTC](https://cl.desmos.com/t/pattern-matching/2972/9 "2021-03-28T17:15:50Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [March 28, 2021, 11:22pm UTC](https://cl.desmos.com/t/pattern-matching/2972/10 "2021-03-28T23:22:48Z")

</div>

Not with patterns, no.

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [March 31, 2021, 3:45pm UTC](https://cl.desmos.com/t/pattern-matching/2972/11 "2021-03-31T15:45:10Z")

</div>

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

[![](https://i.ytimg.com/vi/oPAevo7CaHU/hqdefault.jpg "Pattern Matching - Being Flexible") ](https://www.youtube.com/watch?v=oPAevo7CaHU)

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

---

<div class="post-metadata">

**Author:** ![David\_Diaz](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/david_diaz/32/228_2.png) [@David\_Diaz](https://cl.desmos.com/u/David_Diaz)\
**Post date:** [March 31, 2021, 4:26pm UTC](https://cl.desmos.com/t/pattern-matching/2972/12 "2021-03-31T16:26:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![SteinSchreiber](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/steinschreiber/32/2267_2.png) [@SteinSchreiber](https://cl.desmos.com/u/SteinSchreiber)\
**Post date:** [April 1, 2021, 6:50pm UTC](https://cl.desmos.com/t/pattern-matching/2972/13 "2021-04-01T18:50:22Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [April 2, 2021, 4:08pm UTC](https://cl.desmos.com/t/pattern-matching/2972/14 "2021-04-02T16:08:11Z")

</div>

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

[![](https://img.youtube.com/vi/JTAGsw1InOg/hqdefault.jpg "Pattern Matching - Correctness") ](https://www.youtube.com/watch?v=JTAGsw1InOg)

---

<div class="post-metadata">

**Author:** ![HumanizedMath](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/humanizedmath/32/2947_2.png) [@HumanizedMath](https://cl.desmos.com/u/HumanizedMath)\
**Post date:** [April 8, 2021, 5:08pm UTC](https://cl.desmos.com/t/pattern-matching/2972/15 "2021-04-08T17:08:33Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [April 8, 2021, 5:37pm UTC](https://cl.desmos.com/t/pattern-matching/2972/16 "2021-04-08T17:37:07Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![HumanizedMath](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/humanizedmath/32/2947_2.png) [@HumanizedMath](https://cl.desmos.com/u/HumanizedMath)\
**Post date:** [April 8, 2021, 8:13pm UTC](https://cl.desmos.com/t/pattern-matching/2972/17 "2021-04-08T20:13:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JayChow](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jaychow/32/1674_2.png) [@JayChow](https://cl.desmos.com/u/JayChow)\
**Post date:** [April 9, 2021, 5:15pm UTC](https://cl.desmos.com/t/pattern-matching/2972/18 "2021-04-09T17:15:45Z")

</div>

Got it. Sorry, nothing for those symbols yet.

---

<div class="post-metadata">

**Author:** ![Aethir](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/aethir/32/2767_2.png) [@Aethir](https://cl.desmos.com/u/Aethir)\
**Post date:** [April 17, 2021, 2:28am UTC](https://cl.desmos.com/t/pattern-matching/2972/19 "2021-04-17T02:28:05Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jsimms](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/jsimms/32/1521_2.png) [@jsimms](https://cl.desmos.com/u/jsimms)\
**Post date:** [April 29, 2021, 10:06pm UTC](https://cl.desmos.com/t/pattern-matching/2972/20 "2021-04-29T22:06:45Z")

</div>

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?

[Next page](https://cl.desmos.com/t/pattern-matching/2972.md?page=2)
