> For those who want to train their tacit muscles, here's a challenge.
> A Markov algorithm is a specialized term rewriter. It accepts ... I am not sure the problem can be handled by tacit expressions better than with explicit expressions. Tacit way to implement 'while' is body^:predicate^:_ In J as it is there is no information flow between body and predicate, but for this problem there is a significant sharing of information. predicate is true when a non-terminal rule was applied and body is the application of this rule. Also, I belive, if you are demanding "tacit" solution, you should also use only tacitly defined utilities. stringreplace (which seems to be the cornerstone of the algorithm) is not. Anyway, here is my submission (sans parsing) NB. This rules file is extracted from Wikipedia: NB. http://en.wikipedia.org/wiki/Markov_Algorithm R1=:i.0 3 R1=:R1,'A';'apple';0 R1=:R1,'B';'bag';0 R1=:R1,'S';'shop';0 R1=:R1,'T';'the';0 R1=:R1,'the shop';'my brother';0 R1=:R1,'a never used';'terminating rule';1 T1=:'I bought a B of As from T S.' mapply=: 4 : 0 ri=.0 while. ri<#x do. z=.y E.~ p=.>{.r=.ri{x ri=.1+ri if. +./z do. y=.((> 1 { r) , (#p) }. ])&.((z i. 1)&|.) y ri=._*>{:r end. end. y ) NB. test NB. R1 mapply T1 _________________________________________________________________ Hotmail: Trusted email with powerful SPAM protection. http://clk.atdmt.com/GBL/go/177141665/direct/01/ ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
