From ftm
if <num: condition> <any: true value> <any: false value>
- choose between two values (both conditional values are evaluated)
The 'if' function (not method) should be pretty clear if you keep in mind the two drawbacks:
1. it is a function, i.e. all arguments are evaluated before the 'if' gets to decide which one to output, i.e. something like
(if ($1 != 1) ($myfmat mul 2) ($myfmat zero))
always multiplies and then zeros the myfmat!
2. The result of 'if' can only be one atom, not a list. If you want to output one list or another, use tuples, with a subsequent ftm.list, or the soon-to-be-official #untup feature of ftm.mess. This can be used with a 'route' to send a list out to one or another connection.
(if ($mydict exists $1) {1 $mydict[$1]} {2 $1 42}) | ftm.list | route 1 2