Named parameters: Difference between revisions
→{{header|ALGOL 68}}: Updated for latest ALGOL 68G, print an/a depending on whether the breed starts with a vowel or not
(→{{header|ALGOL 68}}: Updated for latest ALGOL 68G, print an/a depending on whether the breed starts with a vowel or not) |
|||
Line 38:
OWNER=STRUCT(STRING first name, middle name, last name);
#
# VOID would need to be included in the MODEs for options and Empty option lists #
#
MODE OPTIONS = FLEX[1:0]UNION(OPTNAME,OPTSPECIES,OPTBREED,OWNER
# due to the Yoneda ambiguity simple arguments must have an unique operator defined #
Line 60:
ESAC
OD;
print(("Details:
,IF CHAR c = breed[LWB breed]; char in string( c, NIL, "AaEeIiOoUu" ) THEN "an " ELSE "a " FI
,breed, " ", species, " named ",name," owned by ",owner, newline))
);
print pet((NAME "Mike", SPECIES "Dog", BREED "Irish Setter", OWNER("Harry", "S.", "Truman")));
print pet(()) # use print pet((EMPTY)) for Algol 68G version 2 #
END</lang>
Output:
<pre>
Details:
Details: a Tyrannosaurus Dinosaur named Rex owned by
</pre>
|