Notifications
Clear all

[Closed] Two Arrays

Afternoon,

I’m trying to compare two arrays and return from the first array what isn’t matching in the second. For example. I know this should be simple…

array_1=#(“array_1_a”,“array_1_b”,“array_1_c”,“array_1_d”,“array_1_e”)
array_2=#(“array_1_a”,“array_1_b”,“array_1_c”)

for x = 1 to array_1.count do
(
for xx = 1 to array_2.count do
(
if array_1[x] == array_2[xx] then (

    )else(
        print array_1[x]
    )
)

)

The result i want is this.
“array_1_d”
“array_1_e”

Thanks!

3 Replies

i don’t have max around but i can try to write it blind:

fn arrayDifference arr1 arr2 = for item in arr1 where (finditem arr2 item) == 0 collect item
fn arrayIntersection arr1 arr2 = for item in arr1 where (finditem arr2 item) > 0 collect item

The simplest solution is

for element in array_1 do
	if (findItem array_2 element == 0) then print element

but for sure not very efficient.

So simple. Thanks Denis, Kamil. Works exactly as i want. Have a good day.

T