Page 1 of 1

comparing arrays

Posted: Sun Jun 26, 2016 10:49 pm
by tester
I need some simple code for comparing arrays and getting output with 0/1 values.

example input1:

50
50
50
...

example input2

40
50
120
...

output array: 1 if input1>=input2, else 0

0
1
1
...

Note: basically I will need to extend it into value versus range (to check whether value is within a range specified by two arrays: min and max) and range versus range (to check whether there is a common part between range1 made of min1 and max1 array and range 2 made of min2 and max2 array). Anyone has it perhaps...?

Re: comparing arrays

Posted: Wed Jun 29, 2016 9:20 am
by tester
Okay, the problem I had was with automatic output conversion. Ruby does not donverts booleans to integers, like greenery does.

So here are 3 goodies.
1) simple compare between two arrays (between row elements on two arrays)
2) check if value is within range (detection for array set of course)
3) check if 2 ranges have some common part