Sum digits of an integer: Difference between revisions
Content added Content deleted
(Sum digits of an integer in Dart) |
(→{{header|Lambdatalk}}: adding lambdatalk task) |
||
Line 2,548: | Line 2,548: | ||
16xyz base 36 -> 109 |
16xyz base 36 -> 109 |
||
</pre> |
</pre> |
||
=={{header|Lambdatalk}}== |
|||
Following Javascript, with 10 digits + 26 alphabetics giving us glyphs for up to base 36 |
|||
<syntaxhighlight lang="scheme"> |
|||
{def sum_digits |
|||
{lambda {:n} |
|||
{if {W.empty? {W.rest :n}} |
|||
then {parseInt {W.first :n} 36} |
|||
else {+ {parseInt {W.first :n} 36} {sum_digits {W.rest :n}}}}}} |
|||
-> sum_digits |
|||
{S.map {lambda {:i} {div}:i sum to {sum_digits :i}} |
|||
1 12345 0xfe fe f0e 999ABCXYZ} |
|||
-> |
|||
1 sum to 1 |
|||
12345 sum to 15 |
|||
0xfe sum to 62 |
|||
fe sum to 29 |
|||
f0e sum to 29 |
|||
999ABCXYZ sum to 162 |
|||
</syntaxhighlight> |
|||
=={{header|Lasso}}== |
=={{header|Lasso}}== |