It's easy to fix fact 0:

Recursion=:1 :0
   '`if else test next'=: m
   [: if/@(else@{: _1} ])f. (, next@{:)^:(test@{:)^:99 f.
)

However, the problem with Fib is that the recursion concept I used expects
a different kind of gerund than the kind you implemented.

So I would either need to change the gerund or I would need to rebuild my
adverb based on the requirements of that example.

Also, as http://www.jsoftware.com/jwiki/Essays/Fibonacci%20Sequence points
out, there are a lot of ways of computing the fibonacci sequence.

I'm not sure which to prefer.

Thanks,

-- 
Raul


On Tue, Feb 25, 2014 at 12:09 PM, Jose Mario Quintana <
jose.mario.quint...@gmail.com> wrote:

> >simplicity. Simplicity is a virtue?
>
>
>
> On designing econometric models one of the best advised: "Keep it
> Sophisticatedly Simple."  I think his advice also applies to programming;
> actually that is the primary reason why I prefer J versus other
> conventional programming languages and even to APL (at least the decade old
> versions of APL that I used to know).  Moreover, writing only tacitly keeps
> the list of concepts simple  in my mind.
>
>
>
> To stress the main point of my initial message; the case I am making for
> recursion without $: is, for instance,  the fixed tacit (or otherwise)
> implementation of the adverb sna.  The (atomic representation of the)
> Recursion adverb is an interesting testing argument taken by sna.
> Nevertheless,
> I posed the implementation of Recursion as a puzzle and yours and any other
> variants are very welcome.
>
>
>
>    Recursion=:1 :0
>
>    '`if else test next'=. m
>
>    [: (if else^:(-.@test))/f. (, next@{:)^:(test@{:)^:_ f.
>
> )
>
>
>
>    fact=. *`1:`*`<: Recursion
>
>
>
>    fact 5
>
> 120
>
>
>
> So far so good.  Unfortunately,
>
>
>
>    fact 0
>
> 0
>
>
>
> Also,
>
>
>
>    Fib=. >&1`(i.@>:)`(] , +/@(_2&{.)@])`<: Recursion
>
>
>
>    Fib 7
>
> |domain error: Fib
>
> |       Fib 7
>
> |[-15]
>
>
>
> Can you fix your interesting (primitive recursive) version?
> ----------------------------------------------------------------------
> 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