
|
replace
why do
> replace(({1,2,3}),2,17);
(6) Result: ({ /* 3 elements */
1,
17,
3
})
work, while
> replace(({1,2,3}),({2}),({17}));
(5) Result: ({ /* 3 elements */
1,
2,
3
})
does nothing?
|

|
replace
Because ({1,2,3}) does not contain an element with the value ({2})?
OTOH, this doesn't seem to work either:
> replace(({1,({2}),3}),({2}),({17}));
(1) Result: ({ /* 3 elements */
1,
({ /* 1 element */
2
}),
3
})
|

|
replace
Yes, it does.
> array a=({2});
> replace(({1,a,3}),a,({17}));
(1) Result: ({ /* 3 elements */
1,
({ /* 1 element */
17
}),
3
})
|

|
replace
Ah, of course. Well, that should answer Mirar's question then.
|

|
replace
Ah, I guess multi-replace is only for strings. I tried using just two
arguments with the second a mapping first, but that wasn't accepted
either.
|

|
Re: replace
hmm, i can see how
replace(({ 1,2,3, }), ({ 2 }), ({ 17 }));
is not clear whether it is to replace 2 or ({2}), but
replace(({ 1,2,3, }), ([ 2:17 ]));
should be unmistakeable.
currently it leads to an error, but i think it can be made to work.
greetings, martin.
|