(Done as an exercise more than anything else, really. I think there are probably much better/straightforward/READABLE ways to code this in J rather than recklessly chain together a whole bunch of functions like I did, but I'm not really familiar with it so I brainpineapple'd myself doing it this way. Nevertheless, considering that the number of operations needed to be performed is the same, syntax differences won't change the length too much.)