Talk:Execute a Markov algorithm: Difference between revisions

m
→‎explicit vs tacit: tacit markovLexer & replace
(→‎J: strikeout notes on original version, which has been replaced with fully functional (if ugly) version from talk page)
m (→‎explicit vs tacit: tacit markovLexer & replace)
Line 70:
terminated =. _ * >@:{:@:] NB. (_ * terminated) = _ when terminated, 0 otherwise
replaceArg =. 1&{ , #&.>@:(2&{) , 3&{ NB. index ; (#pattern) ; replacement
replace =. 2 ;@:A. >@:{:@:[ ; (0 , 1 {:: [) }.&.> (split~ >@:{.)~
checkRule =. rule match txt
txt =. 1 {:: ]
Line 75 ⟶ 76:
match =. ] ; (>@:{.@:[ index ]) ; [ NB. txt ; index ; pattern ; replacement ; terminating
index =. E. i. 1:
ruleNo =. 0 {:: ]</lang>
markovLexer =. (,. ] (}.&.>~ ,. ]) ('.'={.)&.>)/@:|:@:lexed@:normal@:lines
lines =. LF cut h TAB&=`(,:&' ')}
normal =. a: -.~ (dltb h@:{.~ i:&'#')&.>
lexed =. 0 _1 {"1 '\s+->\s+' ( rxmatch h rxcut h ])S:0 ]</lang>
 
But I do not think that the tacit can claim any advantage over the explicit, in this case. Unless someone can come up with a clearer way of expressing the algorithm tacitly (maying using a different approach).
Anonymous user