1 rem UTILFUN.BAS - Utility functions for Minimal BASIC
 2 rem by David Meyer <papa@twenex.org> 2012
 3 rem 
 4 rem FNA, FNO, FNN - Logical AND, OR, NOT
 5 rem FNA(<p>, <q>) => p AND q
 6 rem FNO(<p>, <q>) => p OR q
7 rem FNN(<p>) => NOT p
 8 rem 
 9 rem FNI, FNI$ - IF-ELSE (Numeric or string result)
10 rem FNI[$](BOOLEAN, <true result>, <false result>) => <result>
11 rem 
 12 rem FNY - Yes/no test (case-insensitive)
13 rem FNY(<yes/no>, <default>) => BOOLEAN
 14 rem
21 DEF FNA(P,Q)=-1*P*Q
22 DEF FNO(P,Q)=SGN(P+Q)
23 DEF FNN(P)=-1*P-1
24 DEF FNI(P,A,B)=ABS(P)*A+ABS(FNN(P))*B
25 DEF FNI$(P,A$,B$)=LEFT$(A$,ABS(P)*LEN(A$))+LEFT$(B$,ABS(FNN(P))*LEN(B$))
26 DEF FNY(A$,Q)=FNI(LEN(A$)=0,Q,FNO(LEFT$(A$,1)="Y",LEFT$(A$,1)="y"))