I've been fiddling with this for 30 minutes and I can't figure it
out... Maybe it's too late in the day
a=:_2]\'a';1;'b';2;'c';3
b=:_2]\'c';5;'a';4
what verb will produce this?
]a,.(4;'';5)
┌─┬─┬─┐
│a│1│4│
├─┼─┼─┤
│b│2│ │
├─┼─┼─┤
│c│3│5│
└─┴─┴─┘
I went down this path:
] ((0{"1 b)i.(0{"1 a))
1 2 0
I figured I could use { and return '' if the index was greater than
the length (e.g., 2 should be '')
I tried using :: to return '' on index error but I couldn't get that to work
NB. not what I wanted
] ((0{"1 b)i.(0{"1 a)) ({ :: ('no'"_)) b
no
Then I tried using ^: to return '' if the length was greater than # b
Then I tried writing a explicit verb using if.
Then I threw in the towel and decided to ask for help since this must
be a common need
I'm sure I've solved this before but cannot remember how
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm