comparing arrays

For general discussion related FlowStone
Post Reply
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

comparing arrays

Post 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...?
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
tester
Posts: 1786
Joined: Wed Jan 18, 2012 10:52 pm
Location: Poland, internet

Re: comparing arrays

Post 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
Attachments
compare arrays.fsm
(839 Bytes) Downloaded 884 times
Need to take a break? I have something right for you.
Feel free to donate. Thank you for your contribution.
Post Reply