Intermediate 5
Hello! This is page 12 of the course called “Y Combinator for Non-programmers”. If you just got here, click here to read from the beginning.

Y Combinator for
Non-programmers

Advanced 1: The “Conditional” Feature

Slide 1 / 11

Welcome to the advanced levels!

Welcome to the advanced levels: Previously, the villagers in Lambda Village got the “Plus 1” feature and the “Minus 1” feature back.

Got these two features back

They were able to reproduce each feature using a lunchbox.

The “Plus 1” feature of a mathbox
Reproduce using a lunchbox
1
Lunchbox that can be converted to
1
13
2
23
1

The “Minus 1” feature of a mathbox
Reproduce using a lunchbox
1
Lunchbox that can be converted to
1
3
2
1
12
2
1
123

Looking for some other page?

Intermediate 5·
·Advanced 2
Slide 2 / 11

Review: The “Repeat” feature

However, they still haven’t gotten the “Repeat” feature back. They need to reproduce this using a lunchbox to get it back.

Repeat
times
Reproduce with
a lunchbox
Repeat
times
Reproduce with
a lunchbox

In case you forgot about the “Repeat” feature , let’s do a quick review.

Let’s review the “Repeat” feature .

Take a look at this mathbox and try pressing Run :

The result is . Because there’s next to , it repeats four times.

Repeats four times
Calculated
Slide 3 / 11

It’s necessary for additions and subtractions of large numbers

(This is still a review) For the villagers in Lambda Village, the “Repeat” feature was necessary to do additions and subtractions of large numbers.

The “Repeat” feature was necessary
to do additions and subtractions of
large numbers

Example (from Beginner 2): If you don’t use the “Repeat” feature , and wanted to calculate , you need to use ten times.

Use ten times

However: As the number gets large, we might make a mistake on the number of ’s to use. In such cases, we won’t get the correct results.

We might put the wrong number of
’s as the number gets large

On the other hand: If you use the “Repeat” feature , you can calculate as follows. You won’t make a mistake on the number of ’s to use.

Repeat ten times

By using the “Repeat” feature , you’ll always use the correct number of ’s or ’s. You can be confident that your additions and subtractions are accurate.

This is why the “Repeat” feature was absolutely necessary for the villagers in Lambda Village.

By using the “Repeat” feature , we can do
additions and subtractions accurately
Slide 4 / 11

How do you reproduce it?

How do you reproduce
the “Repeat” feature with a lunchbox?

The villagers have been trying hard to reproduce the “Repeat” feature using a lunchbox.

Repeat
times
Reproduce with
a lunchbox
Repeat
times
Reproduce with
a lunchbox

However, looks like it’s not going well for them.

Hmm… no matter how much I try, we can’t think of a way to reproduce the “Repeat” feature using a lunchbox.

Saya, do you have any good ideas?

I have no idea either…

Oh no. If Saya can’t figure it out, we’re doomed!

But luckily for them, Minion seems to be willing to offer some help.

Hey guys, it looks like you’re struggling. Do you want some hint?

Oh, thank you, Minion. Please, give us a hint!

Sure. First, let’s talk about the “Conditional” feature .

The “Conditional” feature ? What’s that?

Slide 5 / 11

The “Conditional” feature

Take a look at this mathbox:

A mathbox with the “Conditional” feature

What’s this?

  • It contains , , and .
  • On the left, there are three signs:

It looks like a traffic signal

First: You can fill each of , , and with any number.

The numbers could be all the same or all different.

You can fill each of
, , and with any number

Here’s an example. I used:

  • for
  • for
  • for
Used for

Next: Before I explain what means, let’s run this mathbox and see what happens.

Try pressing Run .

It became .

Let me explain why.

Slide 6 / 11

Check if the bottom section is

Here’s how the “Conditional” feature works.

First: It checks if the number in the bottom section is or not.

Check if is

In this case, the number in the bottom section is .

Yes. And this is what happens next:

  • If the number in the bottom section is ,
  • Then the number in the middle section becomes the final result.
Because is , it chooses
The result is , which was in

I see—that’s why it becomes .

Slide 7 / 11

Yes / No Quiz

I’ll show you another example. This one’s going to be a Yes / No quiz.

Take a look at this mathbox:

Question: If we run it, will it become like this?

It’s okay if you have no idea.
Just guess!

Intermediate 5
Japanese Site (日本語版) · About this Site · Twemoji