# --- Simple calculations ---------------------------------------------------
# Allowed symbols: whitespace, numbers, dot, +-/*, **, (), eE
fourtytwo: !expr 6. * 7
seconds_per_day: !expr 60 * 60 * 24
powers: !expr 2**10
parentheses: !expr (2 + 3) * 4 / (5 - 6)
exp_notation: !expr (2.34 / 3.45) * 1e-10
# --- List generation -------------------------------------------------------
# Generate an integer-filled list using: list(range(*args))
list_foo: !listgen [10] # == [0, 1, 2, ..., 9]
list_bar: !listgen [4, 20, 2] # == [4, 6, 8, ..., 18]
# Can also specify more advanced arguments to control the list's content
list_fancy: !listgen # == [0, 10]
from_range: [0, 100, 10]
append: [0, 25, 50, 75, 100] # append these to the list
remove: [0] # remove _all_ occurences of these
unique: true # removes duplicates, here: 50
sort: true # whether to sort the list, default: true
# NOTE The arguments are always applied in the same order:
# from_range, append, remove, unique, sort (default: true)
# Nesting is also possible!
list_nested: !listgen # == [0, 2, 4, 6, 8, 10, 20, 40, 60, 80]
from_range: [0, 11, 2]
append: !listgen [0, 100, 20]
unique: true
# --- Boolean logic with !any and !all --------------------------------------
will_be_true: !any [false, false, true]
will_be_false: !all [true, false, true, false]
# These are useful to combine with YAML anchors
flag1: &flag1 true
flag2: &flag2 false
flag3: &flag3 true
some_parameters:
enabled: !all [*flag1, *flag2, *flag3]
# And they can also be nested:
another_set_of_parameters:
enabled: !any
- !all [*flag1, *flag2]
- *flag3