On Wed, Jan 24, 2024 at 11:32:50AM +0100, Grégory Vanuxem wrote:
> Hello,
>
> Small question, is there a simple to use function to replace some
> characters or strings in a string, for example:
>
> replace("ababab", "b", "c")
> => "acacac"
For replacing single characters traditional FriCAS way would be to use
'map':
(1) -> map(c +-> (c = char("b") => char("c"); c), "ababab")
(1) "acacac"
Type: String
Of course, we can define:
replace(s, c1, c2) == map(c +-> (c = char(c1) => char(c2); c), s)
to get less verbose syntax. It gets more tricky when one wants
to replace more characters or especially replace substrings
--
Waldek Hebisch
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/ZhcVep6TlPgI1kfF%40fricas.org.