Here's a misguided implementation of singleton extension in J:

flattensingles=: ,/^:(1 +/@(*/\) .= $)

It works by removing any leading "1" dimensions:

   $ flattensingles=: ,/^:(1 +/@(*/\) .= $) i. 1 1 2 3
2 3

So
   A=:1 1$4

   3 2 +&flattensingles A
7 6

The reason this is misguided is that sometimes you will want a leading
dimension of 1.

The right way to solve this problem is to not use leading dimensions
of 1 when you do not want them.  (The computer cannot read your mind,
though, so this is best implemented in your data.)

-- 
Raul
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to