# Patterns with parentheses

**URL:** <https://cl.desmos.com/t/patterns-with-parentheses/7262>\
**Category:** Questions\
**Tags:** patterns\
**Created:** [September 12, 2024, 9:01pm UTC](https://cl.desmos.com/t/patterns-with-parentheses/7262 "2024-09-12T21:01:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Itzik](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/itzik/32/4888_2.png) [@Itzik](https://cl.desmos.com/u/Itzik)\
**Post date:** [September 12, 2024, 9:01pm UTC](https://cl.desmos.com/t/patterns-with-parentheses/7262/1 "2024-09-12T21:01:37Z")

</div>

how I can define a pattern for expression with parantheses. see row 3 in the table.[patterns definition for row 3](https://teacher.desmos.com/activitybuilder/custom/66e354c42b4ce44f38972b32)

---

<div class="post-metadata">

**Author:** ![Daniel\_Wekselgreene](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/daniel_wekselgreene/32/1819_2.png) [@Daniel\_Wekselgreene](https://cl.desmos.com/u/Daniel_Wekselgreene)\
**Post date:** [September 12, 2024, 10:09pm UTC](https://cl.desmos.com/t/patterns-with-parentheses/7262/2 "2024-09-12T22:09:17Z")

</div>

You can nest product patterns within sum patterns. So it’s not that there are parentheses, it’s about how the terms and factors break down. In this case, you have 1 + 2(9 - x), so it is a sum on the outside of 1 + a product, and that product is 2 \* a difference.

You can also match to specific numbers with the .satisfies(“x=”) term. So it could look like this:

validPattern = p.sum( p1, p.product( p2, p.sum(p9, pX).allowNegativeTerms ) )

I made a new table with no CL so you can see the relevant part easily.

> **[\[Copy of\] match pattern with parentheses • Activity Builder by Desmos Classroom](https://teacher.desmos.com/activitybuilder/custom/66e364849932a7cb13cb6097)**
>
> by Daniel Wekselgreene

---

<div class="post-metadata">

**Author:** ![Itzik](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/itzik/32/4888_2.png) [@Itzik](https://cl.desmos.com/u/Itzik)\
**Post date:** [September 13, 2024, 3:17am UTC](https://cl.desmos.com/t/patterns-with-parentheses/7262/3 "2024-09-13T03:17:21Z")

</div>

Makes lot of sense.

Thank you very much.

Itzik

בתאריך יום ו׳, 13 בספט׳ 2024, 1:19, מאת Daniel Wekselgreene via Computation Layer Support Forum ‏\<[notifications@desmos.discoursemail.com](mailto:notifications@desmos.discoursemail.com)\>:
