I started with the rectangular case, so have this rather more
complicated monad:
deo =: 13 : 's$i{;y[ i =. /:;</.i.s =. (((+/(],%)>./)@:(#every)))y'
I was a bit surprised that the result is tacit.
deo
(+/ (% , ]) >./)@:(#&>) $ ; {~ [: /: [: ; [: </. [: i. (+/ (] , %)
>./)@:(#&>)
As Marshall observes, it's not possible to deduce the orientation of
the rectangle. The verb here assumes a landscape shape.
Unfortunately, the result is wrong if the original was portrait...
eg
[land =: </.(a.{~97+i.25){~i.3 8
+-+--+---+---+---+---+---+---+--+-+
|a|bi|cjq|dkr|els|fmt|gnu|hov|pw|x|
+-+--+---+---+---+---+---+---+--+-+
[port =: </.(a.{~97+i.25){~i.8 3
+-+--+---+---+---+---+---+---+--+-+
|a|bd|ceg|fhj|ikm|lnp|oqs|rtv|uw|x|
+-+--+---+---+---+---+---+---+--+-+
deo land NB. ok
abcdefgh
ijklmnop
qrstuvwx
deo port NB. !!!
abcfilor
dehknqtu
gjmpsvwx
This dyad allows us to specify landscape or portrait with the
optional left argument; explicit odd x forces portrait; the default
is landscape.
deod =: 3 : 0
0 deod y
:
s =. (((+/(] (x |.,) %)>./)@:(#every)))y
i =. /:;</.i.s
s$i{;y
)
deod land
abcdefgh
ijklmnop
qrstuvwx
1 deod port
abc
def
ghi
jkl
mno
pqr
stu
vwx
I've assumed that the input is properly derived from oblique
boxing of a rectangular array.
Mike
On 17/02/2016 17:42, Marshall Lochbaum wrote:
deoblique =: ($:~ [: ((1+i.,i:)>./) #@>) : ([ $ (/:&; </.@:i.)~)
---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm