If you’ve recently visited the updated Computation Layer documentation, you may have noticed a new section: pattern matching. That’s right. The highly sought after tools for parsing student expressions are finally here! We’ve made a short series of videos to help you learn more about pattern matching.
This month, we’ll take some key points from those videos and present them as tips to help you get started.
A few notes before we jump in:
You’ll probably use pattern matching very rarely or not at all. Don’t feel obligated to use it. Be more cautious of overuse than underuse.
Pattern matching is more advanced than most of the topics we cover in our monthly newsletters. If you feel like you’re not yet ready to take that leap, don’t worry! We’ll save this newsletter in our archives for you to dig into later.
We don’t want anyone to leave empty handed, so if pattern matching isn’t something that interests you right now, Take a look at this interaction.
What do you like? What don’t you like? What would you change? How could you adapt it to work for something you teach? Let us know!
5 Tips for Making The Most Out of Patterns
1. Avoid writing “patterns” over and over (watch video)
Start all of your pattern matching by creating a variable for the word “patterns.” (We like to use “p”.) That way all of this . . . :
Instead of trying to determine whether a string matches a pattern and taking out the part you want every time, determine that the pattern matches the string once, then parse out the pieces you need separately.
3. Write sub-patterns for commonly used parts (watch video)
Is there a piece of the pattern that you use over and over again? Turn it into a variable! You can place that variable into your pattern instead.
Instead of writing a complicated specific pattern, pull out latex strings of part of a more general pattern, then match and parse each portion of the entire string separately as it becomes more specific.
There are so many great and reliable methods already in place to check for correctness. Pattern matching is a great tool for extracting parts of an input to build more comprehensive feedback, but it is brittle and can break if not done correctly. Instead, use error messages and warnings to gently nudge students toward the right form. Let each thing do what they do best.
MatchMyCL Recap
Last month we asked you to create an interaction that utilized a hidden graph to do your calculations. Here's what you shared:
Patty Stephens led us off with not one, not two, but three examples!
Joe Grogan used a graph to evaluate a series of student generated equations for equivalence.
Stein Schreiber took a similar approach, sinking in solutions to trigonometric equations as functions to evaluate. Unrelated to the challenge, check out the 🌖 animation in the feedback table!
Jenn Vadnais used a hidden table to store factors of a given integer and check them against multiple student inputs.
Nathaniel Heading created a secret message encoder using a table and a hidden graph! 🤯
Craig Winske took a different approach to the challenge and instead made a graph that is hidden to the student, but displays a student's progress on the teacher dashboard. Very cool! 😎
As always, the responses have been compiled into a collection here.
This Month's Challenge:
We're better together! This month, share an activity created by someone else that was helpful to you.