Passes a boolean through unchanged, so a value can be given a name and reused.
Example: true -> true
The boolean
The same boolean
Draws a list of random booleans, each true with a given probability.
Example: length 5 with trueThreshold 0.7 -> perhaps [true, true, false, true, true]
How many booleans to draw and the probability of true
The random booleans
Turns numbers into booleans with a random blend between two thresholds.
Below the first threshold a number is always true, above the second always false; in between, the chance of true falls in steps from one to the other, so a pattern fades out instead of switching sharply. Example: [0.1, 0.9] with thresholds 0.3 and 0.7 -> [true, false]
The numbers, the two thresholds and how many steps the fade has
One boolean per number
Turns numbers into booleans: true below the threshold, false at or above it.
inverse flips every result.
Example: [0.3, 0.7, 0.5] with threshold 0.6 -> [true, false, true]
The numbers, the threshold and whether to flip the result
One boolean per number
Turns numbers into booleans: true when the number falls inside any of the given ranges, false otherwise.
Each range is [min, max] with both ends included; inverse flips every result.
Example: [0.2, 0.5, 0.8] with ranges [[0.3, 0.6], [0.7, 0.9]] -> [false, true, true]
The numbers, the ranges and whether to flip the result
One boolean per number
Flips a boolean: true becomes false and false becomes true.
Example: true -> false
The boolean
The opposite boolean
Flips every boolean in a list.
Example: [true, false, true] -> [false, true, false]
The booleans
The flipped booleans, in the same order
Compares two values with an operator: less, less or equal, greater, greater or equal, equal
or not equal, in the loose (==) or strict (===) form.
Example: 5 greater than 3 -> true; 'hello' strictly equal to 'world' -> false
The two values and the operator
The result of the comparison
Lets a value through when the boolean is true and gives undefined when it is false.
Example: 42 with true -> 42; 42 with false -> undefined
The value and the boolean that opens the gate
The value, or undefined when the gate is closed
Picks the first of two values that is defined, so the second acts as a fallback.
Example: 42 and 10 -> 42; undefined and 10 -> 10
The preferred value and the fallback
The first defined value, or undefined when both are missing
Booleans and decisions: comparing values, flipping booleans, turning lists of numbers into lists of booleans by thresholds, drawing random booleans, and gating a value so it passes only when a condition holds. The threshold methods are the usual way to decide which items of a pattern get a feature and which do not.