Anonymous user
Ethiopian multiplication: Difference between revisions
m
→{{header|Ursala}}
Line 1,555:
=={{header|Ursala}}==
check
the sake of completeness.
<lang Ursala>
odd = ~&ihB▼
double = ~&iNiCB▼
half = ~&itB▼
</lang>
The functions above are defined in terms of bit manipulations exploiting the concrete representations
of natural numbers. The remaining code treats natural numbers instead as abstract types by way of the library API, and
and filtering (*~) among others.
<lang Ursala>
Line 1,572:
emul = sum:-0@rS+ odd@l*~+ ^|(~&,double)|\+ *-^|\~& @iNC ~&h~=0->tx :^/half@h ~&
</lang>
▲The program above makes use of the functions odd, double, and half, which respectively
▲check for whether or not a number is even, double a given number, or perform truncating
▲division by two. These functions are imported from the nat library and would not be
▲odd = ~&ihB
▲double = ~&iNiCB
▲half = ~&itB
test program:
<lang Ursala>
|