How to resolve the algorithm Selectively replace multiple instances of a character within a string step by step in the Phixmonti programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Selectively replace multiple instances of a character within a string step by step in the Phixmonti programming language

Table of Contents

Problem Statement

This is admittedly a trivial task but I thought it would be interesting to see how succinctly (or otherwise) different languages can handle it. Given the string: "abracadabra", replace programatically:

Note that there is no replacement for the third 'a', second 'b' or first 'r'. The answer should, of course, be : "AErBcadCbFD".

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Selectively replace multiple instances of a character within a string step by step in the Phixmonti programming language

Source code in the phixmonti programming language

/# Rosetta Code problem: https://rosettacode.org/wiki/Selectively_replace_multiple_instances_of_a_character_within_a_string
by Galileo, 11/2022 #/

include ..\Utilitys.pmt

"ABaCD" var A "Eb" var B "rF" var R

"abracadabra" len for >ps
    tps get tochar
    dup "a" == if drop A pop var A tps set else
    dup "b" == if drop B pop var B tps set else
    "r" == if R pop var R tps set
    endif endif endif
    ps> drop
endfor

pstack

  

You may also check:How to resolve the algorithm Numbers which are not the sum of distinct squares step by step in the Pascal programming language
You may also check:How to resolve the algorithm Hello world/Newline omission step by step in the bootBASIC programming language
You may also check:How to resolve the algorithm Kronecker product step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Take notes on the command line step by step in the Ada programming language
You may also check:How to resolve the algorithm Pascal's triangle step by step in the Pascal programming language