# ExpressionPatternMatch example?

**URL:** <https://cl.desmos.com/t/expressionpatternmatch-example/722>\
**Category:** Questions\
**Tags:** simplefunction, patterns, validation, correctness\
**Created:** [February 27, 2020, 4:32pm UTC](https://cl.desmos.com/t/expressionpatternmatch-example/722 "2020-02-27T16:32:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Roxas](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/mark_roxas/32/333_2.png) [@Mark\_Roxas](https://cl.desmos.com/u/Mark_Roxas)\
**Post date:** [February 27, 2020, 4:32pm UTC](https://cl.desmos.com/t/expressionpatternmatch-example/722/1 "2020-02-27T16:32:15Z")

</div>

Hi. A lot of the computation layer documentation is lacking code examples. Was hoping to solve this mystery.

I have a table where I ask student to enter responses to questions where students have to reduce a radical into simplified radical form. So if I give them a randomly generated question like \sqrt{72} and expect 6\*\sqrt{2} as an answer, I am trying to build in correctness. So far,

> check1 =  
> when this.cellNumericValue(1,2)= simpleFunction(“\sqrt{f}”,“f”).evaluateAt(a) 1  
> otherwise 0

This code checks if their answer evaluates to \sqrt{72} but I am trying to also find a way to check their latex input if it is reduced to simpified form by checking to see if there is a \sqrt{prime}. I am hoping maybe ExpressionPatternMatch can help with this but I do not know how to implement it? Or is there something else?

---

<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:** [February 27, 2020, 4:36pm UTC](https://cl.desmos.com/t/expressionpatternmatch-example/722/2 "2020-02-27T16:36:26Z")

</div>

Hey mark!

Pattern matching is a feature that is used in our advanced editing process and is not publicly consumable.

If you want to check for a particular form you could use a combination of numericValue and countNumberUsage.

---

<div class="post-metadata">

**Author:** ![Arthur\_Henry\_Watson](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/arthur_henry_watson/32/1549_2.png) [@Arthur\_Henry\_Watson](https://cl.desmos.com/u/Arthur_Henry_Watson)\
**Post date:** [January 2, 2021, 5:07am UTC](https://cl.desmos.com/t/expressionpatternmatch-example/722/3 "2021-01-02T05:07:21Z")

</div>

Adding countVariableUsage and countOperatorUsage and maybe countFunctionUsage would go a long way towards enabling form checking scenarios. Like countVariableUsage("(x-1)(x+5)(x-3)", “x”) would be 3, and countOperatorUsage("(x-1)(x+5)(x-3)", “^”) would be 0, and maybe countFunctionUsage(“3\*\sqrt{5}”, “sqrt”) would be 1.

---

<div class="post-metadata">

**Author:** ![Mushunrek](https://avatars.discourse-cdn.com/v4/letter/m/73ab20/32.png) [@Mushunrek](https://cl.desmos.com/u/Mushunrek)\
**Post date:** [January 4, 2021, 8:20am UTC](https://cl.desmos.com/t/expressionpatternmatch-example/722/4 "2021-01-04T08:20:55Z")

</div>

Hey Jay!  
Is there any hope that pattern recognition will be publicly accessible in the future? It would open a lot of opportunities to adapt feedback for the students!
