Vous n'êtes pas identifié(e). Pour pouvoir écrire ou répondre à un message, vous devez vous connecter ou vous créer un compte sur JAWA.

#1 20-10-2018 11:11:43

spook1
Membre
Inscription : 12-02-2018

Compare two arrays

How can I compare two arrays?

I have tried some syntaxes, but these seem not to work..

I tried

array1$1$1=={{array2$1$0}}

And

array1$1$1={{array2$1$0}}

And

array1$1$1==array2$1$0

And

array1$1$1=array2$1$0

Now I am trying to colpare all elements in my arrays. Is it also possible to compare two arrays alltogether? Like

array1 = {{array2}}

Hors ligne

#2 21-10-2018 18:41:51

jawa
Admin

Re : Compare two arrays

Hi Martijn Spook !

About the syntax :
- you need to add the {{ }} on the right side of conditions, otherwise you'll compare array1 value to the literal string "array2".  Values on the left side always stands for variables so you can and the {{ }} but it's not mandatory.

- the equality operator is just " =" , not  "=="

So :

- to compare specific cells values  the good syntax is:

array1$1$1={{array2$1$0}}

BUT, the was a bug on this case (array cell to array cell comparison) which is FIXED now *


- to compare full arrays :

array1={{array2}}

is the right syntax BUT you need to remove spaces around the "=" because spaces are included in the literal values on the right size of comparison.


* Arrays variables is a new feature in JAWA 32 with lot of implications in the engine so their may be other bugs or missing cases like this. Please post any bug or potential bug in this room if it occurs again.

Z




I added

#3 03-11-2018 14:32:18

spook1
Membre
Inscription : 12-02-2018

Re : Compare two arrays

Thanks for the elaborate answer.
The way I have set uip my tyestgame mnow, I need to compare two rows of an array.

Woudl it be possible to do something like:

array1$*$1={{array2$*$0}}

to compare the whole first row tot the whole second row?

Hors ligne

#4 07-11-2018 13:09:27

jawa
Admin

Re : Compare two arrays

hello Martijn
Sadly there's no syntax to extract and compare a specific row or column from an array. I'll think about it for the next version (could be an interesting feature) but in the meantime you'll need to compare each cell of the row or split the 2D array in 1D arrays.

Z

#5 10-11-2018 15:43:17

jawa
Admin

Re : Compare two arrays

Ok now you can compare rows or columns of array using the char "*", meaning "all cells", instead of a cell or column coordinate. To be a bit more clear :

ARRAY$*$2 = all cells from line 2 = line 2
ARRAY$4$* = all cells from column 2 = column 2

#6 22-11-2018 19:46:14

spook1
Membre
Inscription : 12-02-2018

Re : Compare two arrays

Wow. I just noticed the feature now.
Great!


little remark: I suppose the last line must be:

ARRAY$4$* = all cells from column 4 = column 4

Hors ligne

#7 24-11-2018 14:23:59

jawa
Admin

Re : Compare two arrays

yes, my mistake !

Pied de page des forums