04-07-2012 09:45 AM
I'm working my way with the homework, and I been searching the web about concatening the word into two substrings. However, how do I tell it so it knows that it always separates it 50%? Meaning half the word goes in the 1st indicator and the other half goes into the 2nd indicator. At the moment, I have to manually set the count, but this won't work if I type in a different word obviously.
Solved! Go to Solution.
04-07-2012 10:15 AM - edited 04-07-2012 10:16 AM
(Splitting a string into two is the opposite of concatenating, so make sure to keep the terminologies straight.)
You can only split it in two if the string lenght is an even number, else you need to decide with side should be longer by one.
In any case, the string palette has a primitive called "string length" that could provide useful for this problem. Try using it.
See how far you get. 😉
04-07-2012 10:20 AM
thanks for the correction.
Umm I don't see how the string length will help me, I've wired it to the input, but won't that just take the length of the word I put in? you mentioned that if it was an even number word, that I could split it easily. Do I have to change something in the offset to do so, extactly half? Right now I have it set to 3 but I know that can't be right
04-07-2012 10:33 AM
What if you would divide the lenght by two and wire it into the split string primitive, replacing the current diagram constant?
04-07-2012 10:39 AM
Divide the string length buy two and then select the subset of the string using half the length as either the length or the offset.
Ex.
string = "SplittingStrings"
length = 16
length/2 = 8
subset with offset equal to 8 = SplittingStrings = "gStrings" (by the was that was totally not intended ahead of time)
subset with length equal to 8 = SplittingStrings = "Splittin"
Either way, the subset you get will be one indicator and the rest of the string wil be your other indicator.
As altenbach said, notice this worked well with a string with an even length. If the length is odd, you will have to round it and have uneven substrings.
04-07-2012 10:58 AM
@PackersFan wrote:
As altenbach said, notice this worked well with a string with an even length. If the length is odd, you will have to round it and have uneven substrings.
You don't want to use the plain divide operation, because it will give you an orange output. Use quotient and remainder to keep it blue at all times. 😉
04-07-2012 10:59 AM
awesome!, Thank you! That help me solved a bunch of steps so far, I'm going to see how far I can get and take some time to figure it out before replying back.