Language syntax
This section describes the syntax of the language
Last updated
>>> x = 10
>>> x > 0
True
>>> x <= 0
False
>>> x == 10
True
>>> x += 2
>>> x
12
>>> x *= 2
>>> x
24
>>> y = 0
>>> x == 0 and y > 0 or x != 0 and y < 0
False
>>> not (x == 0 and y > 0 or x != 0 and y < 0)
True
# let's say %sex% is "female"
>>> 'yes' if %gender% == 'female' else 'no'
'Yes'
# let's say %message% is "hello world"
>>> 'priv' in %message%
True
>>> ' ' in %message%
True
>>> 'yet' not in %message%
True'hello' | len
6
>>>len('hello')
6
>>> 'hello'.len()
6# suppose %message% is "hello world"
>>> %message%.startswith('hello')
True
>>> %message%.endswith('hello')
False
>>> %message%.endswith('world')
True
>>> round(0.23)
0
>>> round(0.23, 1)
0.2
>>> 12345678 | pretty
12 345 678
# note: \ is used to escape a quote in a string
>>> 12345678 | pretty('\'')
12'345'678
>>> rand([1, 2, 3])
1
>>> rand([1, 2, 3])
1>>> cart = []
>>> cart.push('bread')
>>> cart.push('buckwheat')
>>> shopping cart
['bread', 'buckwheat']
>>> 'bread' in basket
True
>>> 'cheese' in basket
False
>>> shopping cart | pretty('\n')
bread
buckwheat>>> cart = {}
>>> basket['bread'] = 3
>>> basket['buckwheat'] = 10
>>> shopping cart
{'bread': 3, 'buckwheat': 10}
>>> 'bread' in basket
True
>>> 'cheese' in basket
False
>>> shopping cart | pretty
bread: 3
buckwheat: 10a, b, c => a + b + c>>> cart = {}
>>> basket['bread'] = 3
>>> basket['buckwheat'] = 10
# display the dictionary in the format we need
>>> shopping cart | map((k, v) => k + ' - ' + v + 'kg') | join
bread - 3 kg
buckwheat - 10 kg