© Tyl Software Foundation 2019-2021
▶ LIST ASSIGNMENT BY FUNCTION
Assign a List by Function
Even Only example:
nums 8 1 4
evennums evenonly nums
print evennums
evenonly items »
result [ ]
items item ~ modulotwo item ? result ◄ item
result
modulotwo number »
division number ÷ 2
integraldivision math.floor division
result number - integraldivision • 2
result 0 ? t ⇋ f
[ 8, 4 ]
evennums
is declared and assigned by the list variable result of evenonly
function.
There are some system functions that return a list, among them
string.words
:
phrase 'two point zero = 10 / 2'
reversedwords reverse phrase
msg ''
reversedwords word ~ msg ++ word + ' '
print string.trim msg
reverse phrase:
items
words string.words phrase
ind max len words
i max ~ items <- words ( ind -- )
items
2 / 10 = zero point two
In line
words string.words phrase
, words
is assigned by the result of
string.words
, thus turning phrase
into words
list.