,: will pad whatever side is shortest (i.5) ,: i.3 0 1 2 3 4 0 1 2 0 0
for xor (i.5) (22 b.)/@:,: i.3 0 0 0 3 4 ----- Original Message ----- From: Jon Hough <[email protected]> To: "[email protected]" <[email protected]> Cc: Sent: Wednesday, December 3, 2014 7:56 PM Subject: [Jprogramming] Pad Arrays for XORing If I want to XOR two arrays (~:), I run into a problem if the two arrays are of different length. So before XORing I use my "pad" dyadic verb which pads zeros onto the front of the right argument (which is assumed to be the shorter array). pad =: ((#&0)@:(([: # [) - ([: # ]))) , ] I imagine this problem is common, so is there a standard verb to do this? I think my verb is not the most elegant, and it has the deficiency of assuming the right argument is the shorter. ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
