Newsgroups: comp.lang.apl
Path: watmath!watserv2.uwaterloo.ca!torn!spool.mu.edu!uwm.edu!cs.utexas.edu!zaphod.mps.ohio-state.edu!howland.reston.ans.net!gatech!purdue!mentor.cc.purdue.edu!mentor!weg
From: weg@mace.cc.purdue.edu (Eythan Weg)
Subject: Re: APL2 programming contest: The results
In-Reply-To: Berni@nw42.wiwi.uni-bielefeld.de's message of Tue, 18 May 1993 12:07:43 GMT
Message-ID: <WEG.93May20102013@mace.cc.purdue.edu>
Sender: news@mentor.cc.purdue.edu (USENET News)
Organization: Purdue University
References: <Berni.6.0@nw42.wiwi.uni-bielefeld.de>
Date: Thu, 20 May 1993 15:20:13 GMT
Lines: 20

Would you accept a late posting and comment on the APL logic
of the program below? I define a binary operation op
which counts the number of times the pair, made up by tying its
arguments, appears in the realization table.

Thus, if A is the table, x op y gives the frequency of x,y in A.
Now the rest simply a uses the outer product ---  op/ with
arguments being the ordered elements of the columns of the realization
table.  The labels are made by an idiom (by and over) of Iverson.   
I suspect that op is quite expensive.

+---------------------------------------------------------------------+-++
|E=. +/@:(y.&(-:"1))                                                  | ||
|op=.  E@([,])"0                                                      | ||
|(by=.' '&;@,.@[,.])[ over=.({. ; }. ) @ ": @ ,                       | ||
|( {.@] by }.@] over op//)  (/:~)&~."1& |: y.                         | ||
+---------------------------------------------------------------------+-++
Eythan


