# Pattern Matching for Checking Correctness

**URL:** <https://cl.desmos.com/t/pattern-matching-for-checking-correctness/7837>\
**Category:** Questions\
**Tags:** patterns, validation, correctness\
**Created:** [March 21, 2025, 12:34pm UTC](https://cl.desmos.com/t/pattern-matching-for-checking-correctness/7837 "2025-03-21T12:34:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam.Kelly](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/adam.kelly/32/1644_2.png) [@Adam.Kelly](https://cl.desmos.com/u/Adam.Kelly)\
**Post date:** [March 21, 2025, 12:34pm UTC](https://cl.desmos.com/t/pattern-matching-for-checking-correctness/7837/1 "2025-03-21T12:34:00Z")

</div>

My CL is not working, specifically it says equality does not work for “Numerator=72” and “Denominator=13”

p=patterns

Numerator = p.fraction(p.integer,p.integer).parse(this.latex).numerator  
Denominator = p.fraction(p.integer,p.integer).parse(this.latex).denominator

isMixedFraction = p.mixedNumber.matches(this.latex)  
isFraction = p.fraction(p.integer,p.integer).matches(this.latex)

CoeffMixed = p.mixedNumber.parse(this.latex).whole  
NMixed = p.mixedNumber.parse(this.latex).numerator  
DMixed = p.mixedNumber.parse(this.latex).denominator

correct: correct  
correct = (isMixedFraction and CoeffMixed=5 and NMixed=9 and DMixed=13) or (isFraction and Numerator=72 and Denominator=13)  
#this.latex=`\frac{72}{13}` or this.latex=`5\frac{9}{13}`  
placeholderLatex: ``  
suffix: when this.numericValue=1 “hour” otherwise “hours”

Slide 2, Math Response component a1

> **[10-12th Grade Meet #3 2023-2024 \[Delaware Secondary School Mathematics League\]...](https://classroom.amplify.com/activity/67cda472b86148949d28b507)**
>
> Delaware Secondary School Mathematics League
> 10-12th Grade Meet #3 2023-2024
> For use by the Dover High School Math League club for practice purposes.

---

<div class="post-metadata">

**Author:** ![Daniel\_Grubbs](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_grubbs/32/719_2.png) [@Daniel\_Grubbs](https://cl.desmos.com/u/Daniel_Grubbs)\
**Post date:** [March 21, 2025, 1:31pm UTC](https://cl.desmos.com/t/pattern-matching-for-checking-correctness/7837/2 "2025-03-21T13:31:23Z")

</div>

![image](https://canada1.discourse-cdn.com/flex031/uploads/desmos/original/2X/e/e22b5b3d5be0fa66ee143ad153f32e42dae05dae.png)

When you parse those parts, you need to specify whether you want `.latex` or `.numericValue`. This is because you can specify different types for parts in a fraction pattern (e.g. expressions or radicals), and you may want to parse the actual latex vs the value.

The `mixedNumber` pattern, however, requires integers, and so its parts are consistent and its `numericValue` (within backticks) will be the same as it’s latex.
