Also:  You can replace  *.  With  *   
This is one of the great things to note.  Boolean tables from logic are
still numbers! This takes a while to remember, but  * is simply multiplying
all values by zero or one.  That never was apparent when I went to school.
You will find it handy at times.

   X=:?(2$n)$2
   Y=: X *. (i.n) </ i.n  
   X
0 1 1 1
1 1 1 1
1 1 0 0
0 0 0 1
   Y
0 1 1 1
0 0 1 1
0 0 0 0
0 0 0 0
   Y=: X *(i.n) </ i.n  
   X
0 1 1 1
1 1 1 1
1 1 0 0
0 0 0 1
   Y
0 1 1 1
0 0 1 1
0 0 0 0
0 0 0 0
   ]Z=: Y + |: 2*Y     
0 1 1 1
2 0 1 1
2 2 0 0
2 2 0 0
   
More later.

Linda

-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Linda Alvord
Sent: Saturday, November 10, 2012 4:33 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Arc consistency in J

Mike, I think the  0=  is not necessary since both tables are random anyway.

    X =: 0= ? (2$n)$2       NB. generate random matrix of [0,1]
   ]X   =: ? (2$n)$2      
1 0 0 0
1 0 0 1
0 1 1 0
1 0 1 0
   0=X
0 1 1 1
0 1 1 0
1 0 0 1
0 1 0 1

Linda


-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Linda Alvord
Sent: Saturday, November 10, 2012 2:35 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Arc consistency in J

Kip suggested doing some testing.  Over time you will develop all kinds of
testing skill to answer questions for yourself.  Here's a sample I used on
#$  

In the early days all the explanations like the dictionary were prepared to
be printed and thus are extremely terse.  One of the joys of communication
on the forum is that you can provide a long series of samples which can be
read easily and are just as easily disposed of if not useful. 

So here is a long version:

   rank1=:#$
   rank1
# $
   rank2=:[:#$
   rank2
[: # $
   rank3=:#@$
   rank3
#@$
   
   (#$ 7)-:rank1 7
0
   (#$ 7)-:rank2 7
1
   (#$ 7)-:rank3 7
1
   
   5!:4 <'rank1'
  -- #
--+- $
   5!:4 <'rank2'
  -- [:
--+- #
  L- $ 
   5!:4 <'rank3'
      -- #
-- @ -+- $
   
   #$ A=:i.3 2 5
3
   f=: 13 :'#$y'
   f
[: # $
   5!:4 <'f'
  -- [:
--+- #
  L- $ 
   
   f A
3
  
   rank1 Ayo
|length error: rank1
|       rank1 A
   rank2 A
3
   rank3 A
3
   
Conclusion:  As a mathematician you get the answer you want like  #$A . When
it works, you can write  f  .  Earlier there was a discussion about the
default that J uses.  To me it appears to be  [: # $ .

Now that I understand the first couple of lines of your development of your
Sudoku solver, I'm anxious to continue.

Linda

-----Original Message-----
From: programming-boun...@forums.jsoftware.com
[mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Michal D.
Sent: Saturday, November 10, 2012 12:21 AM
To: programm...@jsoftware.com
Subject: Re: [Jprogramming] Arc consistency in J

Some nice things learned: ?~ instead of (?]).

Bo: is it true that (3$3) is not a list of integers but (3#3) is?

Fascinating discussion on ?/... so much intricatness.

Mike

On Thu, Nov 8, 2012 at 11:12 PM, Linda Alvord
<lindaalv...@verizon.net>wrote:

> The dawn finally broke.  It's a deal!
>
>     3 10 4 ? 10 10 10
> 8 2 5 0 0 0 0 0 0 0
> 4 1 0 9 3 7 6 8 5 2
> 9 0 1 8 0 0 0 0 0 0
>
>     3 10 4 ?/ 10 10 10
> 6 0 5 0 0 0 0 0 0 0
> 9 5 0 0 0 0 0 0 0 0
> 2 6 1 0 0 0 0 0 0 0
>
> 8 4 9 5 6 1 3 0 2 7
> 9 3 5 8 0 6 4 7 1 2
> 1 6 8 0 4 2 5 3 9 7
>
> 1 9 5 7 0 0 0 0 0 0
> 3 9 8 0 0 0 0 0 0 0
> 1 3 7 0 0 0 0 0 0 0
>
> So:
>
>    8 8 8 8 8 ? 8 8 8 8 8
> 0 1 7 6 5 3 4 2
> 0 7 3 2 5 1 4 6
> 5 0 7 6 4 1 3 2
> 6 1 5 7 3 0 2 4
> 4 7 3 5 6 0 2 1
>
> There is only one zero in each row.
>
> It is nice when the fog lifts.  Thanks to everyone who helped me.
>
>    f=:0 = # ? #
>    5 f 8
> 0 0 0 0 0 1 0 0
> 0 0 0 0 0 0 1 0
> 0 0 1 0 0 0 0 0
> 0 0 0 0 0 0 0 1
> 0 0 0 0 0 1 0 0
>
> 5!:4 <'f'
>   -- 0
>   +- =
> --+   -- #
>   L---+- ?
>       L- #
>
>
> Quite a pretty picture.
>
> Linda
>
>
>
> -----Origineal Message-----
> From: programming-boun...@forums.jsoftware.com
> [mailto:programming-boune...@forums.jsoftware.com] On Behalf Of Peter B.
> Kessler
> Sent: Thursday, November 08, 2012 9:24 PM
> To: programm...@jsoftware.comn
> Subject: Re: [Jprogramming] Arc consistency in J
>
> The shape of the arguments to the verb that's being inserted is 3x4, 
> so when that verb returns an atom, as dyadic + does, the shape of the 
> result is 3x4.
> But dyadic ? (Deal[1]) doesn't return an atom: it returns a list of 
> the number of items of its left argument.  So for each of the 3x4 
> applications of dyadic ? returns a list of 3 elements, so the shape of 
> the result is 3x4x3.  There's probably a more official way to say 
> that, but that's my model of J, so far.
>
> It might be slightly less confusing to use arguments that aren't also 
> the shapes of those arguments.  E.g.,
>
> The left argument is a list of length 2, and the right argument is a 
> list of length 4, so there are 2x4 pairs between each of which is 
> inserted a Deal.
> Each Deal chooses 3 items from i. 6 without replacement.
>
>        3 3 ?/ 6 6 6 6
>     5 0 2
>     3 5 0
>     1 4 5
>     1 0 3
>
>     0 3 2
>     0 5 2
>     1 2 4
>     3 0 1
>
> so the shape of the result is 2x4x3.
>
>        $ 3 3 ?/ 6 6 6 6
>     2 4 3
>
> Does that seem less odd?
>
>                         ... peter
>
> [1] http://www.jsoftware.com/help/dictionary/d640.htm
>
> Linda Alvord wrote:
> >    f=: 13 :'0=?~ x#y'
> >    f
> > 0 = [: ?~ #
> >
> > Maybe someday I'll just write expressions like yours easily.....   The
> idea
> > seems so simple now.
> >
> > However, I discovered this oddity:
> >
> >     3 3 3 +/ 4 4 4 4
> > 7 7 7 7
> > 7 7 7 7
> > 7 7 7 7
> >
> >    3 3 3 ?/ 4 4 4 4
> > 3 2 1
> > 1 3 0
> > 2 3 1
> > 3 2 1
> >
> > 2 3 1
> > 2 1 3
> > 1 3 0
> > 1 0 2
> >
> > 2 0 3
> > 0 3 1
> > 0 1 3
> > 2 3 1
> >
> > This seems odd:
> >
> > Linda
> >
> > -----Original  Message-----
> > From: programming-boun...@forums.jsoftware.com
> > [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Bo 
> > Jacoby
> > Sent: Thursday, November 08, 2012 4:46 AM
> > sTo: programm...@jsoftware.com
> > Subject: Re: [Jprogramming] Arc consistency in J
> >
> > Linda, stick to integer arithmetic:
> >    5 (0=[:?~#) 8
> > 0 0 0 0 0 0 1 0
> > 1 0 0 0 0 0 0 0
> > 0 0 1 0 0 0 0 0
> > 0 0 0 1 0 0 0 0
> > 0 0 0 0 0 1 0 0
> > - Bo
> >
> >
> >
> >
> >> ________________________________
> >> Fra: Linda Alvord <lindaalv...@verizon.net>
> >> Til: programm...@jsoftware.com
> >> Sendt: 10:10 torsdag den 8. november 2012
> >> Emne: Re: [Jprogramming] Arc consistency in J
> >>
> >>    ee=:(]%2) > ?~@$
> >>    ee
> >> 0.5 > ?~@$
> >>    ff=: 13 :'0.5 > ?~x$y'
> >>    ff
> >> 0.5 > [: ?~ $
> >>    5 ff 8
> >> 0 0 0 0 1 0 0 0
> >> 0 0 0 0 0 0 0 1
> >> 0 0 0 0 1 0 0 0
> >> 0 1 0 0 0 0 0 0
> >> 0 0 1 0 0 0 0 0
> >>
> >> J is so smart, it eliminate the need for  *
> >>
> >>    hh=: 13 :' ?~x$y'
> >>    hh
> >> [: ?~ $
> >>    ]A=:5 hh 8
> >> 4 7 1 6 0 5 3 2
> >> 4 2 3 1 5 7 0 6
> >> 7 3 5 4 1 2 6 0
> >> 5 3 2 4 1 7 6 0
> >> 2 5 4 0 3 6 7 1
> >>    0.5 > A
> >> 0 0 0 0 1 0 0 0
> >> 0 0 0 0 0 0 1 0
> >> 0 0 0 0 0 0 0 1
> >> 0 0 0 0 0 0 0 1
> >> 0 0 0 1 0 0 0 0
> >>
> >> Mind boggling!
> >>
> >> Linda
> >>
> >>
> >> -----Original Message-----
> >> From: programming-boun...@forums.jsoftware.com
> >> [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of 
> >> Devon McCormick
> >> Sent: Wednesday, November 07, 2012 12:56 PM
> >> To: J-programming forum
> >> Subject: Re: [Jprogramming] Arc consistency in J
> >>
> >> At first glance, I thought the right tine of this fork
> >>    (2 %~ ]) > [: (? ]) $
> >> could be replaced by an idiom I frequently use
> >>    (?@$)
> >> but then realized that what we need is
> >>    (?~@$)
> >> so "dd" can be written as
> >>    (]%2) > ?~@$
> >>
> >>
> >> On Wed, Nov 7, 2012 at 1:31 AM, Michal D.
> > <michal.dobrog...@gmail.com>wrote:
> >>> Thanks Roger, that makes sense now.  The history of J is one of 
> >>> it`s intriguing aspects for sure.
> >>>
> >>> Re: Linda: I would call it a v(erb) as opposed to a N(oun).  But 
> >>> what do I know? ;-)
> >>>
> >>> Mike
> >>>
> >>> On Tue, Nov 6, 2012 at 8:53 AM, Roger Hui 
> >>> <rogerhui.can...@gmail.com>
> >>> wrote:
> >>>
> >>>> 'noun verb verb' is a fork and is interpreted as 'noun"_ verb verb'
> >>> (noun"_
> >>>> is a constant verb whose result is noun).
> >>>> http://keiapl.org/anec/#nvv
> >>>>
> >>>> 'verb verb noun' can not be made into a fork because 'verb noun'
> >>>> already has an interpretation (*viz*., apply verb to noun).
> >>>>
> >>>>
> >>>> On Tue, Nov 6, 2012 at 8:47 AM, Michal D.
> >>>> <michal.dobrog...@gmail.com
> >>>>> wrote:
> >>>>>> Change from a Noun to a verb, view its tacit version and apply 
> >>>>>> it to
> >>>>> data:
> >>>>>>      dd=: 13 :'(y%2) > (?]) x$y'
> >>>>>>
> >>>>>>      dd
> >>>>>> (2 %~ ]) > [: (? ]) $
> >>>>>>
> >>>>> That is quite cool.  I'm surprised that you can automatically 
> >>>>> get the
> >>>> tacit
> >>>>> definition.  Does this work for any explicitly defined verb?
> >>>>>
> >>>>> I'm also surprised at the way %~ came out.  Do left hand 
> >>>>> arguments not require a & to bind the argument?  It is strange 
> >>>>> to me that
> >>>>> (1) works
> >>> but
> >>>>> (2) does not.  It seems to me that (3) is the logical way to 
> >>>>> phrase
> >>>> either
> >>>>> of them (ie. a fork with a constant right / left side).  To 
> >>>>> reiterate,
> >>>> why
> >>>>> does (1) work?
> >>>>>
> >>>>> (1)    (2 %~ ]) > [: (? ]) $
> >>>>> (2)    (] % 2) > [: (? ]) $
> >>>>> (3a)   (2: %~ ]) > [: (? ]) $
> >>>>> (3b)   (] %~ 2:) > [: (? ]) $
> >>>>> (4a)   (%&2 ]) > [: (? ]) $      NB. incorrect (hook caught me
> >>>>> out
> >>>> again)!
> >>>>> (4b)   ([: %&2 ]) > [: (? ]) $   NB. correct
> >>>>>
> >>>>> Cheers,
> >>>>>
> >>>>> Mike
> >>>>> ----------------------------------------------------------------
> >>>>> -
> >>>>> -
> >>>>> ---- 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
> >>>
> >>
> >>
> >> --
> >> Devon McCormick, CFA
> >> ^me^ at acm.
> >> org is my
> >> preferred e-mail
> >> -------------------------------------------------------------------
> >> --
> >> - 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
> ----------------------------------------------------------------------
> 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

----------------------------------------------------------------------
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