Here's an example of implementing recursion in a modular
fashion with an explicit definition.

Since recursion needs a name to work in an explicit definition,
I use an object to contain the name and its definition.

a=:a_aye_          NB. exported adverb
coclass 'aye'      NB. helper class

f=:4 :0            NB. core definition for derived function
  if. 1<#y do.
    x f }.y
  else.
    x U y
  end.
)

a=:1 :0            NB. helper adverb (reference manager)
:
  o=. conew 'aye'
  U__o=. u
  r=. x f__o y
  coerase o
  r
)
cocurrent'base'    NB. end of definition of helper class

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

Reply via email to