Sure...

If I define:

Y0=:1 :0
  f=. u Defer
  (5!:1<'f') f y
)

Defer=: 1 :0
:
  g=. x&(x`:6)
  (5!:1<'g') u y
)

and I also define

almost_factorial=: 4 :0
  if. 0 >: y do. 1
  else. y * x`:6 y-1 end.
)

Then
   almost_factorial Y0 9
362880

Similarly, if I define:

Y2=:1 :0
  f=. u f.1 :(':';'g=. x&(x`:6)';'(5!:1<''g'') u y')
  (5!:1<'f') f y
)

Then
   almost_factorial Y2 9
362880

But
   almost_factorial Y 9
|domain error

Thanks,

-- 
Raul
On Fri, Nov 30, 2018 at 3:59 PM Henry Rich <[email protected]> wrote:
>
> I don't see the : line as being lost when I type in Y.  (It's in Y, not
> the 0 : 0 part).
>
> I notice that the 0 : 0 seems to go unused, since it is the v argument
> to the conjunction Y.
>
> If you still think there is a problem, give an example of how to produce
> the error.
>
> Henry Rich
>
> On 11/30/2018 3:48 PM, Raul Miller wrote:
> > While working on the Y combinator rosettacode entry (
> > https://rosettacode.org/wiki/Y_combinator#Explicit_alternate_implementation
> > ), I ran into what looks like a bug.
> >
> > If I write the combinator this way:
> >
> > Y=:2 :0(0 :0)
> >    f=. u (1 :n)
> >    (5!:1<'f') f y
> > )
> > :
> >    g=. x&(x`:6)
> >    (5!:1<'g') u y
> > )
> >
> > I get a domain error when I try to use it, because that : line gets lost.
> >
> > It's present when I inspect the 0 :0 result, but it vanishes from the
> > 5!:1 generated result.
> >
> > It looks like the code is trying to simplify for the 4 :0 case, even
> > though it turns out that that is not relevant.
> >
> > Thanks,
> >
>
>
> ---
> This email has been checked for viruses by AVG.
> https://www.avg.com
>
> ----------------------------------------------------------------------
> 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