HomeManualTopicsTypesSymbols

std::update_if_not

updates one or more variables depending on a condition

Parameters

condition
true or false
values*
the original values of the variables to be updated
body
a function used to update the variables

Result

values*
the maybe updated values

Example

$x -5 update_if_not x > 0 &x -> -x println! x

Output

5

Example

$items list("apples" "bananas" "cherries") $already_processed_items list() update_if_not items.is_empty &items &already_processed_items -> range(items 2 -1) push(already_processed_items items(1)) dump! `items `already_processed_items

Output

items: list <2> "bananas" "cherries" already_processed_items: list <1> "apples"

Topic

Branches

See also

std::update_if updates one or more variables depending on a condition
std::if_not can be used as a function or a procedure
std::if classic if; can be used as a function or a procedure

Implemented by

std_types::false updates the specified variable(s)
std_types::true does not update the specified variable(s)