It is not possible to define tacit conjunctions
in current versions of J.  They were removed
in J5.01 released in September 2002.

Some expressions in your post contain typos which would be errors in any 
version of J.  For example:  
at =: 12 : 'x.@:y.)y.)'

[. was a conjunction that gave the left argument
and ]. was a conjunction that gave the right.

An updated version of Richard Brown's article
can be found in the J Wiki:
http://www.jsoftware.com/jwiki/Stories/RichardBrown



----- Original Message -----
From: Carl Ledbetter <[EMAIL PROTECTED]>
Date: Saturday, September 2, 2006 10:01 am
Subject: [Jprogramming] Tacit Conjunction

> I found an interesting (apparently untitled) article by Richard L. 
> W. Brown
> of York University in which he uses J to illustrate functional 
> programmingby writing a short program to implement a version of 
> George Danzig's Simplex
> algorithm for solving linear programming problems.  The article 
> says it is
> an update in 2001 from versions that appeared in Gimme Arrays in 
> November of
> 1994 and in Vector, vol 11, #4, in April 1995, so that the code 
> would have
> been from an earlier version of J, which may partially explain the 
> problemI've encountered, which is described below.
> 
> 
> 
> In the article, Brown creates a conjunction by:
> 
> 
> 
> at =: 2 : '([EMAIL PROTECTED])y.]'
> 
> 
> 
> This conjunction works fine.
> 
> 
> 
> However, Brown also suggests making a tacit version of 'at' by:
> 
> 
> 
> at =: 12 : 'x.@:y.)y.)'
> 
> 
> 
> but this produces an error:
> 
> 
> 
> at =: 12 : 'x.@:y.)y.)'
> 
> |domain error
> 
> |   at=:    12 :'x.@:y.)y.)'
> 
> 
> 
> Brown then actually writes out the tacit definition he says the 12 
> : command
> produces as:
> 
> 
> 
> at =: ((@:`].)`])(`:6) 
> 
> 
> 
> which, when run, also produces an error:
> 
> 
> 
> at =: ((@:`].)`])(`:6)
> 
> 
> 
> |spelling error
> 
> |      at =: ((@:`].)`])(`:6)
> 
> |                      ^
> 
> 
> 
> The ]. is not a typo--the dot is there in the text, so I am 
> assuming that
> there was once a definition for ]. that is now withdrawn (I'd love 
> to know
> what it was).  More perplexing to me is that I can't see why the tacit
> version doesn't work.  Is there a tacit version, or did the loss 
> of ].
> prevent the possibility of a tacit version?  
> 
> 
> 
> I'm not second-guessing dropping ]. (if that's what the issue is)--
> I'm sure
> there are good reasons for the choice made; I just want to know if 
> there is
> a way to work around this to produce a tacit version of the 
> conjunction.  
> 
> 
> 
> Using 
> 
> 
> 
> at =: 2 : '([EMAIL PROTECTED])y.]'
> 
> 
> 
> works fine, but I'm just trying to understand more about tacit 
> programming.
> 
> 
> For those who want to tinker with Brown's program, it is (with 
> some changes
> in notation I made for unrelated reasons):
> 
> 
> 
> pc =: ml@(0&,)@}:@{. NB. Second way, accounting for 0
> 
>          if =: @.
> 
>          else =: `
> 
>          inf =: _:@[
> 
>          unb =: 1&[EMAIL PROTECTED]@]
> 
>          opt =: 0&= @ ]
> 
>          frX =: [EMAIL PROTECTED]
> 
>          lrX =: }.-(({."1 @}.)*/{.)
> 
>          pivX =: ({.,lrX)@(frX,}.)
> 
>          rowX =: ((|[EMAIL PROTECTED]),}.)~
> 
>          colX =: rowX"1
> 
>          atX =:  2 : '(u.@:v.)v.]'   
> 
>          prX =: >:@ml@:(({:"1)dp({."1))
> 
>          pinX =: (pivX atX rowX else inf if unb prX) atX colX
> 
>          simplexX =: (simplexX @ pinX else [ if opt) pc
> 
> 
> 
> A typical linear programming problem formatted for input is:
> 
> 
> 
> MBrown =: 3 6 $ 1 _2 _3 0 0 0 0 4 1 1 0 12 0 2 5 0 1 15
> 
> 
> 
>   MBrown
> 
> 
> 
> 1 _2 _3 0 0  0
> 
> 0  4  1 1 0 12
> 
> 0  2  5 0 1 15
> 
> 
> 
> And simplexX MBrown produces the solution correctly as:
> 
> 
> 
>   simplexX MBrown
> 
> 1 0 0  0.22222   0.55556  11
> 
> 0 1 0  0.27778 _0.055556 2.5
> 
> 0 0 1 _0.11111   0.22222   2
> 
> 
> 
> (For those who want to go look up the paper, I've found another 
> problem in
> an earlier part of it:  Brown gives two other versions of a J 
> program to
> solve the same problem, but these, although they work on his 
> example, do not
> work on other more general linear programming problems; the 
> version above
> does, which is why I've concentrated on studying this one.)


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

Reply via email to