Names to numbers: Difference between revisions

m
m (→‎{{header|Quackery}}: small tweak)
Line 1,929:
=={{header|Quackery}}==
 
The idea is that, with a few tweaks and appropriate definitions for number names etc, a string such as <pre>one billion, two hundred and thirty four million, five hundred and sixty seven thousand, eight hundred and ninety</pre> can ''be'' a valid Quackery program.
 
The tweaks turn it into the nest <pre>[ {{ , one billion , two hundred thirty four million , five hundred sixty seven thousand , eight hundred ninety }} ]</pre> by prepending <code>{{ ,</code>, inserting a space in front of each comma, and appending <code> }}</code> before being compiled with <code>build</code>, and removing references to the word <code>and</code> after compilation.
 
 
Finally, the compiled nest is executed with <code>do</code>.
 
<lang Quackery> [ 1 + ] is one ( --> n )
[ 1 + ] is one ( --> n )
[ 2 + ] is two ( --> n )
[ 3 + ] is three ( --> n )
Line 1,972 ⟶ 1,971:
[ 0 ] is , ( --> n )
 
[ this , ] is {{ ( --> [ )
 
[ over ' {{ = iff
nip done
+ again ] is }} ( [ * --> n )
 
[ $ "{{ , " swap
witheach
[ dup char , = if
Line 1,988 ⟶ 1,987:
swap witheach
[ dup ' and = iff
drop
else
[ nested join ] ]
do ] is name->number ( $ --> n )
 
1,488

edits