So...

First, '' is an empty list of characters.

Type: literal
Rank: 1
Shape: ,0
Data: empty

In other words an empty string.

And, f is a verb.  f'' gives us the result of its monadic definition
applied to the empty string argument.  And, since f will be a constant
function it's always going to give us the same result.

Here's the definition of Y:

Y=: 3 :0
  (Y bind y`'')&(y`:6)`''
)

So, in almost_fibonacci (when it's being handled through Y), f is
going to be the constant function
   Y bind (almost_fibonacci`'')
and f'' is going to be the gerund resulting from
   Y almost_fibonacci`''
and (f'')`:6 is going to be the same as (Y almost_fibonacci`'')`:6 --
it's a function to compute a fibonacci number.

Also note that `'' is something very different -- it's a suffix which
converts a verb into a gerund (a noun which represents that verb).

In other words, f is a verb which when run gives us the result of Y
applied to the gerundial form of almost_fibonacci.  We could not
compute this result directly in Y (because it's a part of the result
of Y), so instead of providing the result directly we provided a
gerund  that would let us calculate this result.  (And a gerund is the
most direct approximation of a lambda that I have found in J -- and a
trailing `:6 is the syntactic mechanism in J which gives an effect
like a lambda being at the head of a list, in a lisp dialect).

So... the result of f'' is a gerund which can be used to find a
fibonacci number.

Does this make sense?

Thanks,

-- 
Raul

On Wed, Jun 13, 2012 at 2:26 AM, Steven Taylor <tayl...@gmail.com> wrote:
> thanks for the post.  I have wondered about recursion in J before.  I'd
> like to dig into your example a little more.
>
> Could you elaborate on *f'' gives us a gerund that can handle one more
> level of recursion
> *
> Why the double single quote?
>
> thanks,
> -Steven
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to