RosettaCodeData/Task/Extend-your-language/ALGOL-68/extend-your-language.alg

14 lines
640 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
# operator to turn two boolean values into an integer - name inspired by the COBOL sample #
PRIO ALSO = 1;
2024-10-16 18:07:41 -07:00
OP ALSO = ( BOOL av, bv )INT: IF av AND bv THEN 1 ELIF av THEN 2 ELIF bv THEN 3 ELSE 4 FI;
2023-07-01 11:58:00 -04:00
# using the above operator, we can use the standard CASE construct to provide the #
2024-10-16 18:07:41 -07:00
# required costruct, e.g.: #
2023-07-01 11:58:00 -04:00
BOOL a := TRUE, b := FALSE;
CASE a ALSO b
IN print( ( "both: a and b are TRUE", newline ) )
, print( ( "first: only a is TRUE", newline ) )
, print( ( "second: only b is TRUE", newline ) )
, print( ( "neither: a and b are FALSE", newline ) )
ESAC