Number names: Difference between revisions
→{{header|Quackery}}: extended valid range, improved comma/and logic.
(Added BASIC256) |
(→{{header|Quackery}}: extended valid range, improved comma/and logic.) |
||
Line 5,582:
{{trans|C#}}
<syntaxhighlight lang="quackery">[ [ table
$ "zero" $ "one" $ "two"
$ "three" $ "four" $ "five"
Line 5,591 ⟶ 5,590:
$ "fourteen" $ "fifteen"
$ "sixteen" $ "seventeen"
$ "eighteen" $ "nineteen" ] do ] is units ( n --> $ )
[ [ table
Line 5,597 ⟶ 5,596:
$ "thirty" $ "fourty" $ "fifty"
$ "sixty" $ "seventy" $ "eighty"
$ "ninety" ] do ] is tens ( n --> $ )
[ $ "" swap
Line 5,614 ⟶ 5,613:
[ over -1 peek space != if
[ dip [ space join ] ] ]
units join ] is triplet ( n --> $ )
[ $ "" swap
dup 999999999999999 > if
[ 1000000000000000 /mod swap triplet
$ " quadrillion" join
swap dip join
dup 0 = iff drop ]done[ ]
dup 999999999999 > if
[ over size 0 > if
[ dip [ $ ", " join ] ]
1000000000000 /mod swap triplet
$ " trillion" join
swap dip join
dup 0 = iff drop ]done[ ]
dup 999999999 > if
[ over size 0 > if
[ dip [ $ ", " join ] ]
1000000000 /mod swap triplet
$ " billion" join
swap dip join
dup 0 = iff drop ]done[ ]
dup 999999 > if
[
[ dip [ $ ", " join ] ]
1000000 /mod swap triplet
$ " million" join
swap dip join
Line 5,631 ⟶ 5,651:
over size 0 > if
[ dip [ $ ", " join ] ]
triplet join
dup reverse witheach
[ char , = if
[ i split
behead drop
$ " and" swap
join join
conclude ] ] ] is name$ ( n --> $ )
10 times
[ 10
1+ ** random
dup echo
say " is:"
name$ nest$
60 wrap$ cr cr ]</syntaxhighlight>
{{out}}
<pre>
four
eighty two thousand, eight hundred and eighty six▼
sixty three million, seven hundred, ninety eight thousand,
seven hundred and fourteen
six
three billion, six hundred, eighty nine million, one
▲five million, fifty nine thousand, six hundred and ninety
million, three hundred, eighty six thousand, three hundred
and seventy
twenty
eight hundred and
six thousand, four hundred and eighty one▼
four million,
▲hundred and seventy four
47022976290599343 is:
</pre>▼
fourty seven quadrillion, twenty two trillion, nine hundred,
seventy six billion, two hundred, ninety million, five
▲three</pre>
=={{header|R}}==
|