This site is version 0.0.1. Most of the code on this site is drafted by an agent and needs review. I apologize for the AI-speak, we are working on rewriting it!
viv-lang.org

Booleans

true and false are their own type: what a comparison yields, what if and while take, and a value you can store, pass and return. Run a cell to see its output beside the expected one.

A comparison is a Bool

It prints as true or false, in every engine. It is not the number 1: there is no arithmetic on it.

Viv [1]

Store one in a variable

A flag is a Bool: a comparison gives one, and and, or and not combine them.

Viv [2]

while not done

not flips a boolean, so while not done keeps looping until done becomes true.

Viv [3]

Functions can return one

Bool is an annotation like Num and Arr. A predicate is an ordinary function.

Viv [4]

Bools compare with == and !=

Two Bools can be compared with == and !=, and combined with and, or and not; no other operator accepts them.

Viv [5]

assert_true takes one

A test can check a condition directly.

Viv [6]

and and or stop early

The right side of and runs only when the left side is true, and the right side of or only when the left side is false, so a bounds test can guard the index beside it.

Viv [7]

Comparing arrays gives a mask

A comparison with an array on either side is elementwise and gives 1.0 where the comparison is true and 0.0 where it is false. all and any turn a mask into one Bool, and where picks from two values with it.

Viv [8]