An easy J version (once I figure out what  _  is doing since I can't
eliminate it.)

 

   

   ]'A B'=:3|L:0(([:<i.)"1)3 5,:5 4

----------T-------┐
│0 1 2 0 1│0 1 2 0│
│2 0 1 2 0│1 2 0 1│
│1 2 0 1 2│2 0 1 2│
│         │0 1 2 0│
│         │1 2 0 1│
L---------+--------

   j=: 13 :' ;x <@((,"1}.)"1#~(=&{:|.)"1)"1 _ y'

   A j B

0 1 2 0 1 2 0 1
0 1 2 0 1 2 0 1
2 0 1 2 0 1 2 0
2 0 1 2 0 1 2 0
1 2 0 1 2 0 1 2

   f=: 13 :';x ([:<(,"1}.)"1#~(((= {:)~ {:) |.)"1)"1 _ y'

   A f B

0 1 2 0 1 2 0 1
0 1 2 0 1 2 0 1
2 0 1 2 0 1 2 0
2 0 1 2 0 1 2 0
1 2 0 1 2 0 1 2

   f

[: ; ([: < (,"1 }.)"1 #~ (((= {:)~ {:) |.)"1)"1 _

 

Thanks Raul for the coaching.

 

Linda

     

 

-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Linda Alvord
Sent: Friday, October 19, 2012 10:08 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] stitching matrices

 

Wow!  That keep me busy for a week.  Thanks.

 

Linda

 

-----Original Message-----

From:  <mailto:programming-boun...@forums.jsoftware.com>
programming-boun...@forums.jsoftware.com

[ <mailto:programming-boun...@forums.jsoftware.com>
mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Raul Miller

Sent: Friday, October 19, 2012 9:30 AM

To:  <mailto:programm...@jsoftware.com> programm...@jsoftware.com

Subject: Re: [Jprogramming] stitching matrices

 

On Fri, Oct 19, 2012 at 4:00 AM, Linda Alvord <
<mailto:lindaalv...@verizon.net> lindaalv...@verizon.net>

wrote:

>    G B

> 1 1 1 1 1

>    H B

> ran with error:

> |domain error: H

> |       H B

> |[-30] c:\users\owner\j701-user\temp\37.ijs

> 

> G WORKS!  H DOESN'T!

> 

> How can I write the function  H  without & and get 1 1 1 1  ?

 

Here's G B

   ((=&{:)|.)"1 $~&5 4 i.3

1 1 1 1 1

 

Here, I rephrase G by eliminating the &

   (({:@[ = {:@])|.)"1 $~&5 4 i.3

1 1 1 1 1

 

Note that I am testing the result at each step, here, to make sure I've not
made any bad assumptions (for example, hypothetically speaking some
intermediate results in these kinds of transformations might need some
explicit treatment of rank).

 

Here, I further rephrase G by also eliminating both of the @ conjunctions

   ((([: {: [) = ([: {: ]))|.)"1 $~&5 4 i.3

1 1 1 1 1

 

Here, I simplify slightly by using a hook

   (((([: {: [) = ]) {:)|.)"1 $~&5 4 i.3

1 1 1 1 1

 

Here, I simplify again by using a cross hook

   (((= {:)~ {:) |.)"1 $~&5 4 i.3

1 1 1 1 1

 

Good enough?

 

Thanks,

 

--

Raul

----------------------------------------------------------------------

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

 

----------------------------------------------------------------------

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

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

Reply via email to