Jump to content

Damm algorithm: Difference between revisions

m
No edit summary
Line 473:
=={{header|Arturo}}==
 
<lang rebol>table:; [by @Krenium
 
table: [
[0 3 1 7 5 9 8 6 4 2]
[7 0 9 2 1 5 4 8 6 3]
Line 486 ⟶ 488:
]
 
digitsdamm?: function [xz][mapzero? splitfold xdigits => [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][
1,532

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.