[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-apl] Doing without loops
From: |
Louis de Forcrand |
Subject: |
[Bug-apl] Doing without loops |
Date: |
Mon, 31 Aug 2015 00:19:52 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
Hi, it's me again.
The latest svn works like a charm. ./configure, make, make check,
make install, make installcheck. Couldn't be easier.
Now, my two questions aren't necessarily bugs, but the
blog is titled "bugs and discussion". Anyway, how would I go about
repeating a function using ⍣ until the answer reaches a certain value?
e.g.:
FIB ← { 2 ↓ ( { ⍵ , +/ ¯2 ↑ ⍵ } ⍣ ⍵ ) 0 1 }
FIB 5
1 2 3 5 8
As you can see, FIB produces a vector of the ⍵ first Fibonacci numbers.
Now I want to produce a vector of all the Fibonacci numbers under, say, 1000.
I could just do:
{(⍵ ∊ ⍳1000) / ⍵} FIB 30
as the 30th Fibonacci number is obviously above 1000, but I'm sure
there's a more elegant (and versatile) way of doing this.
I keep wanting to do something like:
while ( ( ¯1 ↑ FIB i ) < 1000) {
i++;
}
FIB i
but I know I can't.
It's not elegant anyway :)
Best regards,
Louis
- [Bug-apl] Doing without loops,
Louis de Forcrand <=