Hey, I’m just wondering if there is a shortcut to printing suffixes for numbers like 1st and 2nd? What I mean is that if the number ends in 1 it would add a ‘st’ to make it 1st, so a number 2 changes to to 2nd and so on? If not, is there a syntax to say:
It’s not built in, but you can write a function for it:
[code]Test chamber is a room.
To say ordinalize (N - a number):
let the last digit be the remainder after dividing N by 10;
if the last digit is:
– 1: say “[N]st”;
– 2: say “[N]nd”;
– 3: say “[N]rd”;
– otherwise: say “[N]th”;
Every turn:
say “This is the [ordinalize the turn count] turn.”
Just occurred to me, you’ll want to write in exceptions for 11, 12, and 13, all of which end with “th”.
To say ordinalize (N - a number):
let last-2-digits be the remainder after dividing N by 100;
if last-2-digits is at least 11 and last-2-digits is at most 13:
say "[N]th";
otherwise:
let the last digit be the remainder after dividing N by 10;
if the last digit is:
-- 1: say "[N]st";
-- 2: say "[N]nd";
-- 3: say "[N]rd";
-- otherwise: say "[N]th";