Here's an attempt at making this code more "J-ish".  Mostly, I have
been assigning names to blocks (instead of allowing anonymous blocks).

I need better names, though.  ref0N is not a very evocative name.


trivial=: 0 *./ .= {.
NonTrivial=: ^:(0 = trivial)

refN=: (], 0,. [:REF 1 1}. [ - {."1@[ */ ]) (%{.)@{.
ref00=: 0,. [:REF }."1
ref0N=: [:REF (}.,~ {. + ({.@#~ 0 ~: {."1))
ref0=: ref0N`ref00@.(trivial@:|:)
REF=: refN`ref0@.(0 = {.@{.)NonTrivial

reduce0=: {."1,. [: reduceStep }."1
reduce1=: {., 0 ,. }."1@}.@(- ({."1 */ {.))
reduceStep=: reduce0`reduce1`]@.(2 <. {.@{.) NonTrivial

RREF =: ([:{.&> (reduceStep@}.&.>^:(1<#&>)^:a:@ <@reduceStep))&.|. @ REF

Note that I have eliminated the code corresponding to

if. 0=#y do. i.0 0 return. end.

since this case never happens -- it is handled by

if. *./0={.y do. y return. end.

FYI,

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

Reply via email to