Ethiopian multiplication: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) (Rename Perl 6 -> Raku, alphabetize, minor clean-up) |
No edit summary |
||
Line 2,492: | Line 2,492: | ||
99 x 99 = 9801 |
99 x 99 = 9801 |
||
</pre> |
</pre> |
||
=={{header|Lambdatalk}}== |
|||
A translation from the javascript entry. |
|||
<lang Scheme> |
|||
{def halve {lambda {:n} {floor {/ :n 2}}}} |
|||
-> halve |
|||
{def double {lambda {:n} {* 2 :n}}} |
|||
-> double |
|||
{def isEven {lambda {:n} {= {% :n 2} 0}}} |
|||
-> isEven |
|||
{def mult |
|||
{def mult.r |
|||
{lambda {:a :b} |
|||
{if {= {A.first :a} 1} |
|||
then {+ {S.map {{lambda {:a :b :i} |
|||
{if {isEven {A.get :i :a}} |
|||
then else {A.get :i :b}}} :a :b} |
|||
{S.serie {- {A.length :a} 1} 0 -1}}} |
|||
else {mult.r {A.addfirst! {halve {A.first :a}} :a} |
|||
{A.addfirst! {double {A.first :b}} :b}}}}} |
|||
{lambda {:a :b} |
|||
{mult.r {A.new :a} {A.new :b}}}} |
|||
-> mult |
|||
{mult 17 34} |
|||
-> 578 |
|||
</lang> |
|||
=={{header|Limbo}}== |
=={{header|Limbo}}== |