Post Reply 
How to write a program to output multiple results
10-26-2020, 10:27 AM (This post was last modified: 10-26-2020 10:55 AM by pinkman.)
Post: #4
RE: How to write a program to output multiple results
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;

Thibault - not collector but in love with the few HP models I own - Also musician : http://walruspark.co
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 - pinkman - 10-26-2020 10:27 AM



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