Getting the number of decimal places: Difference between revisions

m
m (→‎{{header|Lambdatalk}}: minor change)
Line 422:
=={{header|Lambdatalk}}==
In lambdatalk numbers are words/strings, some operators, like "+,-,*,/,...", know what to do with words like "123".
 
A first answer could be
 
<lang Scheme>
{W.length
Line 428 ⟶ 431:
-> 4
</lang>
 
This is a better one, if considering that ending zeroes should not be considered as decimals
 
<lang Schema>
{def decimals
{def decimals.r
{lambda {:w}
{if {= {W.first :w} 0}
then {decimals.r {W.rest :w}}
else :w}}}
{lambda {:w}
{W.length
{decimals.r
{S.first
{W.reverse
{S.replace \. by space in :w}}}}}}}
-> decimals
 
{decimals 12.34560001230000}
-> 10
</lang>
Numbers can be of any size.
 
=={{header|Perl}}==