Also you can remove  ~  and  if you  use the same  A  and  B  but reverse them 
you get:

A=:<"1 ":":"0>:i.12
   B=:;:'am pm'
   i=: 13 :'x(,~&.>)/y'
   j=: 13 :'x(,&.>)/y'
   A j B        
┌────┬────┐
│1 am│1 pm│
├────┼────┤
│2 am│2 pm│
├────┼────┤
│3 am│3 pm│
├────┼────┤
│4 am│4 pm│
├────┼────┤
│5 am│5 pm│
├────┼────┤
│6 am│6 pm│
├────┼────┤
│7 am│7 pm│
├────┼────┤
│8 am│8 pm│
├────┼────┤
│9 am│9 pm│
├────┼────┤
│10am│10pm│
├────┼────┤
│11am│11pm│
├────┼────┤
│12am│12pm│
└────┴────┘
   
Linda


-----Original Message-----
From: programming-boun...@forums.jsoftware.com 
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Linda Alvord
Sent: Saturday, April 05, 2014 12:22 PM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] I want to understand under

Thanks Dan,  You got me exactly what I needed.  I'm not opposed to   i=: ,~&.>/ 
    I just want to explain it.

]A=:<"1 ":":"0>:i.12
┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
│1 │2 │3 │4 │5 │6 │7 │8 │9 │10│11│12│
└──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘
   >A
1 
2 
3 
4 
5 
6 
7 
8 
9 
10
11
12
   ]B=:;:'am pm'
┌──┬──┐
│am│pm│
└──┴──┘
   >B
am
pm
   (>B),~>A
1 
2 
3 
4 
5 
6 
7 
8 
9 
10
11
12
am
pm
   <(>B),~>A
┌──┐
│1 │
│2 │
│3 │
│4 │
│5 │
│6 │
│7 │
│8 │
│9 │
│10│
│11│
│12│
│am│
│pm│
└──┘
   f =: 13 : '< (>x) ,~ >y'
   B f A
┌──┐
│1 │
│2 │
│3 │
│4 │
│5 │
│6 │
│7 │
│8 │
│9 │
│10│
│11│
│12│
│am│
│pm│
└──┘
   f
[: < ([: > [) ,~ [: > ]
   g=: 13 :'x(f"0)/y'
   B g A
┌────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┐
│1 am│2 am│3 am│4 am│5 am│6 am│7 am│8 am│9 am│10am│11am│12am│
├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
│1 pm│2 pm│3 pm│4 pm│5 pm│6 pm│7 pm│8 pm│9 pm│10pm│11pm│12pm│
└────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┘
   h=: 13 :'x(([: < ([: > [) ,~ [: > ])"0)/y'
   B h A
┌────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┐
│1 am│2 am│3 am│4 am│5 am│6 am│7 am│8 am│9 am│10am│11am│12am│
├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
│1 pm│2 pm│3 pm│4 pm│5 pm│6 pm│7 pm│8 pm│9 pm│10pm│11pm│12pm│
└────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┘
   h
([: < ([: > [) ,~ [: > ])"0/
   
   NB.      Here's the definition of Under:
   NB.      As in APL, the right side implies the left side.
   
   NB.     x u&.v y ↔ vi (v x) u (v y) 
   
   i=: 13 :'x(,~&.>)/y'
   B i A
┌────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┬────┐
│1 am│2 am│3 am│4 am│5 am│6 am│7 am│8 am│9 am│10am│11am│12am│
├────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┼────┤
│1 pm│2 pm│3 pm│4 pm│5 pm│6 pm│7 pm│8 pm│9 pm│10pm│11pm│12pm│
└────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┴────┘
   (B i A)-:B h A
1
   
Linda

  
-----Original Message-----
From: programming-boun...@forums.jsoftware.com 
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Dan Bron
Sent: Friday, April 04, 2014 9:22 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] I want to understand under

Linda, every time you try to use  x u&.v y ↔ vi (v x) u (v y) to make a 
substitution, you must remember to respect rank (I know that one sentence in 
the definition of &. doesn't say so explicitly, so you must remember for 
yourself). 

Open (>) is rank 0, i.e. operates on individual atoms,  so somewhere in your 
replacement you must do likewise. The most straightforward way to say this is 
just to say it:

   sh =: 13 : '< (>x) ,~ (>y)' NB. vi (v x) u (v y)
   h =: 13 : 'x sh"0/ y' NB. g with sh"0 substituted for ,~&.>

   (B h A) -: (B g A)
1
 
   sh
[: < ([: > [) ,~ [: > ]
   h f.
([: < ([: > [) ,~ [: > ])"0/

Here, it's the isolation of vi (v x) u (v y) and the explicit application of it 
at "0 (rank zero) that makes the substitution work. Try removing the "0 or 
embedding sh into h directly (in its x and y form, as opposed to its tacit 
from) and see what happens.

Finally I'll recommend, as I do every time we discuss this, that you step back, 
try to shelve any preconceptions, and with new eyes, sincerely compare 

([: < ([: > [) ,~ [: > ])"0/

with

,~ each/

and perhaps reconsider your position on eliminating conjunctions. If your goal 
is simplicity, to make J easier to learn for kids, I just can't see how anyone 
would look at those two expressions and say "whoa, the first one is simpler".

-Dan

PS: And not to pick nits, but the first sentence contains a conjunction as well 
(") and not only is it necessary, it's fundamental to the solution. So if we're 
going to accept ", why not also accept &. and stop worrying?



> On Apr 4, 2014, at 2:25 AM, "Linda Alvord" <lindaalv...@verizon.net> wrote:
> 
> Here’s the problem.  Hopefully this looks better and fully defines the
> problem.
> 
>   f=: 13 :'  (B=:;:''am pm''),~&.>/A=:<"1 ":":"0>:i.y'
>   f 12
> ┌────┬────┬────┬────┬────┬────┬────┬──
> ──┬────┬────┬────┬────┐
> │1 am│2 am│3 am│4 am│5 am│6 am│7 am│8 am│9 am│10am│11am│12am│
> ├────┼────┼────┼────┼────┼────┼────┼──
> ──┼────┼────┼────┼────┤
> │1 pm│2 pm│3 pm│4 pm│5 pm│6 pm│7 pm│8 pm│9 pm│10pm│11pm│12pm│
> └────┴────┴────┴────┴────┴────┴────┴──
> ──┴────┴────┴────┴────┘
>   A
> ┌──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┬──┐
> │1 │2 │3 │4 │5 │6 │7 │8 │9 │10│11│12│
> └──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┴──┘
>   B
> ┌──┬──┐
> │am│pm│
> └──┴──┘
>   g=: 13 :'x(,~&.>)/y'
>   B g A
> ┌────┬────┬────┬────┬────┬────┬────┬──
> ──┬────┬────┬────┬────┐
> │1 am│2 am│3 am│4 am│5 am│6 am│7 am│8 am│9 am│10am│11am│12am│
> ├────┼────┼────┼────┼────┼────┼────┼──
> ──┼────┼────┼────┼────┤
> │1 pm│2 pm│3 pm│4 pm│5 pm│6 pm│7 pm│8 pm│9 pm│10pm│11pm│12pm│
> └────┴────┴────┴────┴────┴────┴────┴──
> ──┴────┴────┴────┴────┘
>   g
> ,~&.>/
> 
> NB. x u&.v y ↔ vi (v x) u (v y)   Definition of Under
> 
> 
> I can’t seem to write  a simple definition   h=:       but use the second
> definition of under.
> 
> It should have the same result as  B g A  when you enter   B h A
> 
> Linda
> 
> 
> 
> ----------------------------------------------------------------------
> 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
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to