Relevance for subtraction within two strings

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

2 Likes

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 !

3 Likes

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.