Why does this work: h=: 13 :'0=(x#y)?x#y' h 0 = # ? # 5 h 8 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1 0 1 0 0 0 0 0 0 0
Linda -----Original Message----- From: programming-boun...@forums.jsoftware.com [mailto:programming-boun...@forums.jsoftware.com] On Behalf Of Linda Alvord Sent: Thursday, November 08, 2012 8:53 PM To: programm...@jsoftware.com Subject: Re: [Jprogramming] Arc consistency in J 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