rlwhitcomb / utilities

Some of my personal utility programs
MIT License
2 stars 0 forks source link

Allow "replace" function in Calc to have missing or empty replacement value #625

Closed rlwhitcomb closed 11 months ago

rlwhitcomb commented 1 year ago

... meaning to remove it, as in:

a = 'abc'
replace(a, 'c') -> "ab"

This is more complicated syntax because there is also the optional mode parameter.

rlwhitcomb commented 11 months ago

The syntax that works the best is to require the extra comma if the replacement value is missing and the mode is used, as in:

replace 'abcabc', 'b', , first -> "acabc"
replace 'abcabc', 'b' -> "acac"
rlwhitcomb commented 11 months ago

Worse problem is the ambiguity when doing:

replace(read(file), 'a', 'b')

where the "read" greedily takes two params, leaving two for "replace", when it should be "read" has one, and "replace" has three.