I think I see the problem. It's from my usage of $:. I had assumed
that $: worked in a different way.

On 12 October 2010 14:34, Mike Day <[email protected]> wrote:
>  It's not immediately obvious what "pairs" signifies in, eg,
>
> <@(pairs getRegion)@,:@(opposing&pairs"1) region
>
> Is it (Are they) the same as "getPairs"?
>
> Could you give an example?
>
> Meanwhile,  is this the sort of thing you're looking for, using
> boxed forms, but they could be opened up?
>
>    pd1
> 1 5 2 4
> 3 1 4 6
> 5 3 6 2
>
>    crnrs   =: ((2<\]) @: (,{. )"1)     NB. alternative for corners
>
>    crnrs pd1
> +---+---+---+---+
> |1 5|5 2|2 4|4 1|
> +---+---+---+---+
> |3 1|1 4|4 6|6 3|
> +---+---+---+---+
> |5 3|3 6|6 2|2 5|
> +---+---+---+---+
>
>    crnregs =: ((1&|.),:each(_1&|.) )@:crnrs NB. "regions" for corners
>
>    crnregs pd1
> +---+---+---+---+
> |3 1|1 4|4 6|6 3|
> |5 3|3 6|6 2|2 5|
> +---+---+---+---+
> |5 3|3 6|6 2|2 5|
> |1 5|5 2|2 4|4 1|
> +---+---+---+---+
> |1 5|5 2|2 4|4 1|
> |3 1|1 4|4 6|6 3|
> +---+---+---+---+
>
> Probably not - as it just rotates pairs from the original pd1,
> and doesn't seem to add much to that original.
>
> Mike
>
> On 12/10/2010 11:52, Justin Paston-Cooper wrote:
>> Hello,
>>
>> I'm trying to implement a way to, given a region (a list of corners,
>> corners being a pair of edge numbers), find all regions which are
>> incident to it. I don't know how much I need to define for my problem
>> to be solved. I'll just give the code here and I can explain more if
>> needed. My idea is to find all of the regions which contain corners
>> opposite (across a crossing) to corners in the given region, and to
>> take the union.
>>
>> pd1 =: 3 4 $ 1 5 2 4 3 1 4 6 5 3 6 2 NB. A planar diagram of a trefoil knot
>> getPairs =: {~ (,.0&C.)@i...@#
>> corners =: getPairs"1 pd1
>>
>> cyclicNext =: 1 : '([ ((4 | u&+)@{.@(#~<&4)@] { {.@(#~<&4)) i."2)~'
>> nextMatch =: {.@(((({:@[ = {...@])"1 # ]) ,/) -. 1 cyclicNext)
>> getRegion =: (nextMatch&) (@{.) ($:@,`...@.(-: {:)~`) (`: 6)
>> opposing =: 2 cyclicNext
>>
>> corners is an n x 4 x 2 matrix where each 4 x 2 table is a clockwise
>> list of corners of a crossing. One can find the region in which a
>> corner is by doing the following:
>>
>> region =: corners getRegion ,: 1 5
>>
>> The result in this case is 3 x 2
>>
>> 3 1
>> 5 3
>> 1 5
>>
>> For some reason
>>
>> <@(pairs getRegion)@,:@(opposing&pairs"1) region
>>
>> gives "stack error: opposing"
>>
>> But
>>
>> pairs getRegion"2 ,:@(opposing&pairs"1)region
>>
>> works fine.
>>
>> But strangely
>>
>> <@(pairs getRegion)"2 ,:@(opposing&pairs"1)region
>>
>> ┌───────┬───────┬───────┐
>> │┌─────┐│┌─────┐│┌─────┐│
>> ││┌───┐│││┌───┐│││┌───┐││
>> │││2 4│││││4 6│││││6 2│││
>> │││6 2│││││2 4│││││4 6│││
>> │││4 6│││││6 2│││││2 4│││
>> ││└───┘│││└───┘│││└───┘││
>> │└─────┘│└─────┘│└─────┘│
>> └───────┴───────┴───────┘
>>
>> At the moment I would just like a boxed list of the regions which
>> result from each corner. I have tried to figure out the problem for
>> ages now, and I'd be grateful for a hint.
>>
>> Justin
>> ----------------------------------------------------------------------
>> For information about J forums seehttp://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