This is probably the most important tip. Nearly every golfed Röda program uses underscores.
The underscore syntax is syntactic sugar for
for loops. The following lines of code are equivalent:
ls""|fileLength x for x|sort|pull
Each underscore adds a new variable to an invisible
for loop that is around the statement. The loop pulls one value from the stream for each variable/underscore and then repeats, until no values are left.
Underscores can be used anywhere in statements:
a[x:y+1]=*(1+y-x) /* Sets range x..y (inclusive) */
seq x,y|a[_]=1 /* 6 bytes less */
If you must refer to the same underscore value more than once, or use the values in reverse order, you can put a number after the underscore:
a|[_^_1] /* maps x to x^x */
a|[_2-_1] /* maps each pair (x,y) to y-x, eg. [1,2,4,8] -> [1, 4] */