CL Newsletter, January 2020 - Ordering Conditional Statements

Welcome to the first edition of the Desmos Computation Layer Newsletter! Every month, we’ll spend some time updating you on the newest and grooviest features released to CL, teach you something new, and give you a place to level up your CL skills. Along the way, we’ll share a little bit about who we are and what we do at Desmos.

Let’s start by welcoming the newest member of the Desmos Graph and CL team! The Desmos Computation Layer team doubled its size this year with John Rowe joining as a CL specialist. John's a math teacher from South Australia, and he loves the way CL can help teachers mould a lesson around the student so they can ask more meaningful questions.

John burst onto the scene in March with an activity that has since been run nearly 5,000 times and was featured on a YouTube video with over 900,000 views. He’s practically a celebrity! He brings to the team a wealth of CL know-how and an intangible knack for creating really delightful interactions.

For those new to CL, we thank you for taking that first step towards creating delightful activities with Desmos. For the CL veterans who have signed up for this newsletter, we hope to bring you something of value and an update on new features. To everyone, read, enjoy, and participate in the learning!

- Team Desmos CL


Ordering Conditional Statements

In this section we'll share some tips and tricks to keep you CL-ing happily. If you're brand new to CL or want a more comprehensive introduction, you can also tune in to our webinar series!

A big reason why Computation Layer is so powerful is its ability to design interactions that respond to the user input. It allows us to produce various outputs and control the behaviour of a component based on conditions we set. It might come in handy, for example, if you want to show an estimate that students make at the beginning of a lesson on a later screen, or you can use it to disable an action button if students haven't entered a response. We are able to do these things (and much more) using conditional statements.

Conditional statements in Computation Layer are programmed to check each statement, beginning with the first and stopping once it has found a true statement. This prevents the possibility of an input generating two outputs. The otherwise statement catches anything that is not true for any of the conditions.

How can we use this to our advantage? First, we can reduce the number of things we need to check on each line by remembering that in order to reach lines 2, 3, 4, etc., the statement must have already been marked as false on the previous lines. Furthermore, the order of the conditions can be changed to further simplify the code.

Try It Yourself

Want to learn more? Try this activity to experience how reordering conditions can optimize and error proof your code.

Rearrange conditional statements and verify the results of your condition order.
Help settle a dispute between two friends.