Damm algorithm: Difference between revisions

Content added Content deleted
No edit summary
Line 473: Line 473:
=={{header|Arturo}}==
=={{header|Arturo}}==


<lang rebol>table: [
<lang rebol>; by @Krenium

table: [
[0 3 1 7 5 9 8 6 4 2]
[0 3 1 7 5 9 8 6 4 2]
[7 0 9 2 1 5 4 8 6 3]
[7 0 9 2 1 5 4 8 6 3]
Line 486: Line 488:
]
]


digits: function [x][map split x => [to :integer]]
damm?: function [z][zero? fold digits to :integer z .seed: 0 [x y]-> table\[x]\[y] ]

damm?: function [z][zero? fold digits z .seed: 0 => [get get table]]
; Or, being more explicit:
digits2: function [str][
chars: split str
result: map chars 'ch -> to :integer ch
return result
]

damm2?: function [str][
d: digits2 str
r: fold d .seed: 0 [x y] -> get get table x y
return r = 0
]


test: function [str][
test: function [str][