Hello.
Someone will advise.
I have text e.g. "101".
I want to change the character in 2 positions to "1" ... so that the text "111" is created. Or similar combinations in the 1st or 3rd position.
Do I have to do this by combining text and list functions?
Or is there an easier solution?
Ondrej
Well thank you !!!
@dora_paz the result of the variable global name is in dictionary form and he is point somthing like "101" replace char at 2 to "1" then it would be "111" string form.
What you think if we add new built-in block for replace char at?
I had these BASIC(TM) flavored procedures in stock:
text.aia (18.0 KB)
Those were written before we had the JOIN WITH SEPARATOR block, which could probably be used with the SPLIT AT '' block to make a shorter version.
P.S. These blocks can be dragged directly into your Blocks Editor workspace.
See A way to group projects by theme
for a demo.
Here is an alternate version using the split and join with separator technique I mentioned in a prior post:
text.aia (20.0 KB)
P.S. The index + 1 for the replacement is because SPLIT AT '' adds an extra empty item at slot 1 of its output list. The empty item is swallowed up by the subsequent JOIN WITH SEPARATOR '' block.
Hello.
If I use this procedure like this:
So the result should be 101, but he is 10.
Where did I make a mistake?
Ondrej
You did not make a mistake.
You found a bug in my mid$ procedure.
Thanks for the bug alert!
Here are the corrected blocks ...
text.aia (20.6 KB)
Hello.
I don't have access block Do .... result .. How to add it to the app?
Or how to copy the whole example to the app?
Ondrej
One way is from provided aia copy blocks to backpack and paste them in your project
But I don't have it in aia. These are the blocks from TIMAI2 ....
Ondrej
Then you have to replicate them because they are not dragable
I'm sorry, but somehow I don't understand ....
Ondrej
It works for me!
Well thank you !
Ondrej
Just continuing with the code base provided here by @TIMAI2 in previous post, to have support for insertCharAt and removeCharAt.
Having analyzed the output of code below
It is looking to be related to the concepts of Power Set where we are just looking for 1 element subset(s) and 0 element subset as we are trying to split the string with empty string.