ruby binary operators for arrays
Posted: Sun Jun 29, 2014 1:31 pm
What are the ruby binary operators for arrays?
Like OR:
1
0
1
0
with
1
1
0
0
gives
1
1
1
0
Like OR:
1
0
1
0
with
1
1
0
0
gives
1
1
1
0
DSP Robotics and FlowStone Graphical Programming Software Support and Forums
https://dsprobotics.com/support/
Code: Select all
output 0, @array1.zip(@array2).map{|a, b| a | b} # OR version
output 0, @array1.zip(@array2).map{|a, b| a & b} # AND version
output 0, @array1.zip(@array2).map{|a, b| a ^ b} # XOR versionCode: Select all
output 0, @a.zip(@a).map{|a, b| 1-a} # NOT version
Code: Select all
@a.map{|a| 1 - a}