Post Reply 
Checking conditions [IF ... THEN ... ELSE] performance
09-15-2015, 09:42 AM
Post: #9
RE: Checking conditions [IF ... THEN ... ELSE] performance
I tried a little code like the excel function andlist, to see if having the functions in a list rather than separately might help: it doesn't.

Then I tried implementing the execution of one of two functions passed as parameters:
If choice then fun1 else fun2 end if.
Again, it seems both fun1 and fun2 are executed simply by being parameters.

Am I understanding this correctly?

Code:

 
 RR(V)
 BEGIN
  IF V THEN
   PRINT("TRUE");
  ELSE
   PRINT("FALSE");
  END;
 END;
 
 FLS()
 BEGIN
  PRINT("FLS");
 RETURN 0;

 END;

 TRU()
 BEGIN
  PRINT("TRU");
  RETURN 1; 
 END;

 

 ZAND(A,B)
 BEGIN
  0▶R;
  IF A  THEN
   IF B THEN
     PRINT("WHY");
     1▶R;
   END;
  END;
  PRINT("R"+R);
 END;

 ZANDLST(LL)
 BEGIN
  LOCAL SOFAR:=1;
  LOCAL I:=1;
  PRINT("ZANDLST:");
  WHILE I≤SIZE(LL)  AND SOFAR DO
    SOFAR:=LL(I);
    PRINT(I+","+SOFAR);
  END;
  RR(SOFAR);
  RETURN SOFAR; 
 END;

 CHS(CHOICE,A,B)
 BEGIN
  IF CHOICE THEN
   PRINT("A CHOSEN");
   A();
  ELSE
   PRINT("B CHOSEN");
   B();
  END;
 END;

EXPORT ZANDTRY()
BEGIN
 PRINT();
 ZAND(FLS(),TRU());
 //PRINT("ZL");
 //ZANDLST({FLS(),TRU()});
 PRINT("CHOICE:");
 CHS(1,FLS(),TRU());
 
 WAIT;
END;

Stephen Lewkowicz (G1CMZ)... USA's changing goals
In 1960s, delivering a man to the Moon...
In 2020s, delivering a vote to the electors.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Checking conditions [IF ... THEN ... ELSE] performance - StephenG1CMZ - 09-15-2015 09:42 AM



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