Post Reply 
How to write a program to output multiple results
10-26-2020, 11:32 AM
Post: #5
RE: How to write a program to output multiple results
(10-26-2020 10:27 AM)pinkman Wrote:  Here is a small example. FIBO calculates the Fibonacci values between two numbers and returns the values as a list.

Usage example: FIBO(50, 250)
Returns: {55,89,144,233}

Code:

EXPORT FIBO(fstart, fend)
BEGIN
 LOCAL a := 1, b := 1, c := 1, ret := {};
 IF fend >= fstart AND fend >= 0 THEN
  WHILE c <= IP(fend) DO
   IF c >= fstart THEN
    ret := CONCAT(ret, c);
   END;
   c := a + b;
   a := b;
   b := c; 
  END; 
 END;
 RETURN ret; 
END;

I recreated the FIBO program on my Prime, and now I've learned to return multiple values, thank you very much!
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: How to write a program to output multiple results - cloudxff - 10-26-2020 11:32 AM



User(s) browsing this thread: 2 Guest(s)