bug-apl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-apl] Doing without loops


From: Louis de Forcrand
Subject: Re: [Bug-apl] Doing without loops
Date: Mon, 31 Aug 2015 14:48:27 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Kacper Gutowski <address@hidden> writes:

> Well, actually you can.  Even without using explicit →gotos.
> 
> I'm not sure if that's the most elegant solution, but the first thing
> that comes to mind is that you can use dyadic predicate for stopping
> condition as right operand rather than a number.
> 
> In this form (f⍣g)Y iterates until ((f Y) g Y) becomes true; for
> example f⍣≡ is a fixed point of f.
> 
>       {¯1↓3↓({⍵,+/ ¯2 ↑ ⍵ } ⍣ {(↑⍵)<¯1↑⍺} ) ⍵, 0 1} 1000
> 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
> 
> (I passed the requested limit as (↑⍵) because GNU APL has no lexical
> scope in dfns that would allow to name it without spilling it outside.)
> 
> -k


Thank you! After some time spent trying to understand what you did 
there I got it. Basically,
       ( f⍣{⍺=10} ) X
means that f(X) will iterate (taking in its previous output as right operand) 
until its output is equal to ten, as I understand it.

Thanks again,
Louis

reply via email to

[Prev in Thread] Current Thread [Next in Thread]