Raul wrote:
> That said, deleting an extra
> row and column is more concise than adding
> extra rows and columns, so with an approach
> like this I would not object too strenuously.
If I understand this correctly, what you're proposing is using the format:
magiCut =: (&>) (@:(<;._3 (_1 #~ #...@$) |. ] {.~ 2 + $))
2 2 < magiCut 10+i. 3 3
+----+-----+-----+----+
|0 0| 0 0| 0 0| 0 0|
|0 10|10 11|11 12|12 0|
+----+-----+-----+----+
|0 10|10 11|11 12|12 0|
|0 13|13 14|14 15|15 0|
+----+-----+-----+----+
|0 13|13 14|14 15|15 0|
|0 16|16 17|17 18|18 0|
+----+-----+-----+----+
|0 16|16 17|17 18|18 0|
|0 0| 0 0| 0 0| 0 0|
+----+-----+-----+----+
followed by deleting an extra row and column, as in:
magiCutR =: magiCut ((}.~ 1 #~ #@:$)@:)
2 2 < magiCutR 10+i. 3 3
+-----+-----+----+
|10 11|11 12|12 0|
|13 14|14 15|15 0|
+-----+-----+----+
|13 14|14 15|15 0|
|16 17|17 18|18 0|
+-----+-----+----+
|16 17|17 18|18 0|
| 0 0| 0 0| 0 0|
+-----+-----+----+
But we had that solution already, and didn't suit your need. Of course,
I've arbitrarily chosen to delete the trailing extra row and column; I
could pick the leading. But that would be just as arbitrary. We could,
of course, remove both:
seq =: (((&.>)/)(@:(|.@:[ , <@:]))) (>@:)
magiCutR =: magiCut ((}.seq~ 1 _1 #&.>~ #@:$)@:)
2 2 < magiCutR 10+i. 3 3
+-----+-----+
|10 11|11 12|
|13 14|14 15|
+-----+-----+
|13 14|14 15|
|16 17|17 18|
+-----+-----+
but then, we had that already too:
2 2 <;._3 ] 10+i. 3 3
+-----+-----+
|10 11|11 12|
|13 14|14 15|
+-----+-----+
|13 14|14 15|
|16 17|17 18|
+-----+-----+
which was the tesselation that was giving you trouble in the first
instance. So we've come full circle.
If you can't provide example inputs/outputs, because you're not sure what
you want yet, perhaps you can describe your situation in English? What
motivated the question? Did you have a case where you had to "code
around" edge conditions in a tesselation? From your earlier hint, I
gather it was here:
http://rosettacode.org/wiki/Image_convolution#J
?
-Dan
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm