07-14-2022, 07:12 PM
(07-09-2022, 11:55 PM)TempodiBasic Wrote: Hi
very strange code
DEF FNB(Q)=Q+8*((Q=9)-(Q=0))
this function returns Q for all value of Q except for 9 that returns 1 and for 0 that returns 8
Is it better using an IF THEN ELSEIF THEN ELSE that seems less cryptic!
and this other
DEF FNC(Q)=-Q*(Q<19)-18*(Q>18)
it returns Q + 18 if Q>18 or -Q if Q<19
moreover
DEF FND(Q)=64*(Q-1)+8*(X-1)+Y
translated in Function must get X and Y to do a correct calculation
Dim Shared versus Function parameters
and at last
DEF FNE(Q)=Q+100*(Q>99)
this FN returns Q if Q <=99 and it returns Q-100 for Q value > 99
However creativity is the first tool of a programmer|
Indeed.
I think this may have been created waaay back in the day, maybe in GW-BASIC or BASIC A?