(04-05-2017 09:51 AM)StephenG1CMZ Wrote: Here's my latest code, using local variables and L1...
My attempt at using MAKELIST doesn't give the desired result, but the other versions are fine.
Code:
SAVAGEPPL()
BEGIN
LOCAL AA;
AA:=1;
FOR I FROM 1 TO 2499 DO
AA:=TAN(ATAN(EXP(LN(√(AA*AA)))))+1
END;
END;
#CAS
SAVAGECAS1(f):=
BEGIN
LOCAL aa;
aa:=1;
FOR I FROM 1 TO 2499 DO
aa:=TAN(ATAN(EXP(LN(√(aa*aa)))))+1
END;
RETURN (aa);
END;
#END
SAVAGECAS2()
BEGIN
LOCAL aa;
aa:=1;
FOR I FROM 1 TO 2499 DO
aa:=CAS(TAN(ATAN(EXP(LN(√(aa*aa))))))+1;
END;
RETURN aa;
END;
SAVAGEML()
BEGIN
L1:={1};
L1:=MAKELIST(CAS(TAN(ATAN(EXP(LN(√(L1(0)*L1(0)))))))+1,I,1,2499);
RETURN L1(0);
END;
EXPORT SAVAGE()
BEGIN
LOCAL RR;
PRINT();
PRINT({" PPL1: ",TEVAL(RR:=SAVAGEPPL()),RR});
PRINT({" CAS1: ",TEVAL(RR:=SAVAGECAS1("")),RR});
PRINT({" CAS2: ",TEVAL(RR:=SAVAGECAS2()),RR});
PRINT({"ML1:WRONG: ",TEVAL(RR:=SAVAGEML()),RR});
PRINT("DONE");
//RETURN {TEVAL(RR:=SAVAGED()),RR,TEVAL(RR:=SAVAGEDCAS()),RR};
END;
If you used AA as a variable because you didn't know it, you can still use A as a local variable.
LOCAL A;