@replace(t:tab, find:value, rep:value)
The argument find
represents a sub-sequence to be
replaced: if it is not a tab, then all the occurrences of this value at
the top-level of t
are replaced by rep
:
$t := [1, 2, 3, [2]]
@replace($t, 2, 0) -> [1, 0, 3, [2]]
find
is a tab, then the replacement is done on sub-sequence of t
:
@replace([1, 2, 3, 1, 2], [1, 2], 0) -> [0, 3, 0]
@replace([1, 1, 1, 2], [1, 1], 0) -> [0, 1, 2]
`rep
is a tab, then it represents at sub-sequence to be
inserted in place of the occurrences of find
. So, if the replacement is a
tab, it must be wrapped into a tab:
@replace([1, 2, 3], 2, [4, 5]) -> [1, 4, 5, 3]
@replace([1, 2, 3], 2, [[4, 5]]) -> [1, [4, 5], 3]
See also Tab Manipulations @binary_search @car @cdr @clear [@clone] @concat @cons @copy @count @dim @domain @drop @empty @find @flatten @gnuplot @insert @iota @is_list @is_prefix @is_subsequence @is_suffix @lace @last @listify @map @max_val @median @member @normalize @occurs @parse @permute @push_back @push_front @range @reduce @remove @remove_duplicate @replace @reshape @resize @reverse @rotate @scan @scramble @size @slice @sort @sputter @stutter @succession @tab_history @tab_history_date @tab_history_rdate @take @to_num