CMC logo Cave Man Code

binga runs some code only when a check is gronk (yes).

grunk rocks = 5

binga rocks > 3
    oga "That is a rock collection!"
unga

wonga means "otherwise":

binga rocks > 3
    oga "Lots of rocks!"
wonga
    oga "Not many rocks."
unga

Only one unga is needed. It closes the whole binga, whether or not the wonga part ran.

Else if, caveman style

Chain checks with wonga binga:

binga score >= 90
    oga "A"
wonga binga score >= 80
    oga "B"
wonga binga score >= 70
    oga "C"
wonga
    oga "keep trying"
unga

CMC reads them in order and stops at the first gronk.

The checks

CheckMeans
a == ba is equal to b
a != ba is not equal to b
a < ba is smaller than b
a <= ba is smaller or equal
a > ba is bigger
a >= ba is bigger or equal
x in pilex is inside a pile or inside text
x not in pilex is not inside

Join checks with the logic words:

binga hungry and rocks > 0
    oga "eat a rock"
unga

binga name == "Ugg" or name == "Oona"
    oga "family!"
unga

binga not tired
    oga "let us play!"
unga

and needs both sides to be gronk; or needs just one; not flips. They stop early when the answer is already known.

What counts as yes?

See Values and types, but the short version: 0, nork, "", an empty pile, and plop are all nork. Everything else is gronk. So this works:

binga rocks
    oga "there is at least one rock"
unga

One compare at a time

This is not allowed:

binga 1 < x < 10     ugg OOGA!

Write it with and:

binga 1 < x and x < 10
    oga "one digit"
unga

Nesting

Blocks can live inside blocks:

binga door == "open"
    binga light == "on"
        oga "walk on in"
    wonga
        oga "it is dark in there"
    unga
wonga
    oga "knock first"
unga

Every binga gets its own unga. Line up the unga under its binga and your code will look like a tidy cave shelf.

Next: Loops.