Is there any method to do subtraction within two strings such that
string 1 item 0 - string 2 item 0, string 1 item 1 - string 2 item 1, string 1 item 2 - string 2 item 2β¦ ?
They are initially character string and do not know the exact length.
And string 1 and string 2 are both in the same length.
They are all integers but expressed in strings
I need the result of two strings subtract each other in the above pattern until the end of string,
I know strings should be changed to integer to do the subtraction, but I cannot find appropriate method in relevance to do my work. Can anyone help? Please.
For example:
(β2β,β3β,β5β) - (β1β,β2β,β4β)
so, the anticipated result should be (1,1,1)
Well, this might be of SOME helpβ¦
β2β as integer - β1β as integer
will return 1β¦
The problem I have here is the comma delimited list between the two. Obviously you can use the βas integerβ inspector but there needs to be an operator between the numbers that isnβt the comma because of the way IEM reads the strings together with commas. The only way you could do it that I can see is this:
(statement for "2" as integer - statement for "1" as integer), (statement for "3" as integer - statement for "2" as integer), (statement for "5" as integer - statement for "4" as integer)
There is a way to make a set using integers but it wonβt have the output you want because you want the values to be independent of one another even though they are in the same string set. From what little messing I did in the fixlet debugger there may not be a way to get integer 1 of set 1 to be subtracted from integer 1 of set 2 and so on.
The closest I can get right off causes a cross-pollination of the two sets. Maybe someone can further refine.
((numeric value of items 0 of it) - (numeric value of items 1 of it)) of ((substrings separated by β,β of ((β2β,β3β,β5β) as string ) as trimmed string) , (substrings separated by β,β of ((β1β,β2β,β4β) as string ) as trimmed string))
A: 1
A: 0
A: -2
A: 2
A: 1
A: -1
A: 4
A: 3
A: 1
T: 0.203 ms
I: plural integer
This is definitely a case that is hard to solve in relevance due to lack of more advanced logic.
You might be better off having an action that runs periodically on systems and computes the results you are looking for and saves the answer to a file, then read those results using relevance.
Thanks all of you, especially ekkopto. It is what I want exactly. The only problem remain is just print out the desired value inside the string.
I have found a solution. This can be solved by this relevance :
concatenation ", " of(tuple string items (integers in (0,length of it,4)) of concatenation ", " of(
((numeric value of items 0 of it) - (numeric value of items 1 of it)) of
((substrings separated by β,β of ((β2β,β3β,β5β) as string ) as trimmed string) ,
(substrings separated by β,β of ((β1β,β2β,β4β) as string ) as trimmed string))as string))
Thanks all of you !
Good work. Thatβs definitely a tough one. This works due to a quirk in the way βitβ works within βtuple string itemsβ that is different in most other cases. It would be much easier to write complex relevance if you could access the βparent of itβ
I would make sure that logic works with other inputs in the way you expect.