takecut=: 0&~:@[ #inv ;@:({.&.>&1)@[ <;.1 ]

The inserted empty boxes do not contain the correct shape and type, which should depend on the cut verb (< here).

Henry Rich

On 9/17/2012 11:51 PM, Ric Sherlock wrote:
How about this...

    takecut=: 0&~:@[ #inv (+/\@[ e.~ >:@i.@#@]) <;.2 ]

    3 2 2 takecut i.7
+-----+---+---+
|0 1 2|3 4|5 6|
+-----+---+---+
    2 4 1 takecut i.7
+---+-------+-+
|0 1|2 3 4 5|6|
+---+-------+-+
   3 0 2 2 takecut i.7
+-----++---+---+
|0 1 2||3 4|5 6|
+-----++---+---+
   0 0 4 3 0 takecut i.7
+++-------+-----++
|||0 1 2 3|4 5 6||
+++-------+-----++

On Tue, Sep 18, 2012 at 3:14 PM, June Kim (김창준) <[email protected]> wrote:
Hi

    takecut=:13 : '((}:0,+/\x)e.~i.#y) <;.1 y'
    3 2 2 takecut i.7
+-----+---+---+
|0 1 2|3 4|5 6|
+-----+---+---+
    2 4 1 takecut i.7
+---+-------+-+
|0 1|2 3 4 5|6|
+---+-------+-+

It's not so difficult. However, generalizing takecut into allowing 0 as an
item in x seems complicated. That is,

    3 0 2 2 takecut i.7
+-----++---+---+
|0 1 2||3 4|5 6|
+-----++---+---+
    0 0 4 3 0 takecut i.7
+++-------+-----++
|||0 1 2 3|4 5 6||
+++-------+-----++

Any ideas for simple solutions?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

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

Reply via email to