diff options
author | Marvin Borner | 2024-03-10 14:18:17 +0100 |
---|---|---|
committer | Marvin Borner | 2024-03-10 14:18:17 +0100 |
commit | e4dc5918cdfc231bee29ca5808e37ee23f33712e (patch) | |
tree | b73f9384964f96fe92ad6a08d393ba73b942a73c /samples/rosetta/luhn_test_of_credit_card_numbers.bruijn | |
parent | 6ae44d09faa0ae353c0818705503cad42127d102 (diff) |
Samples and std additions
Diffstat (limited to 'samples/rosetta/luhn_test_of_credit_card_numbers.bruijn')
-rw-r--r-- | samples/rosetta/luhn_test_of_credit_card_numbers.bruijn | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/samples/rosetta/luhn_test_of_credit_card_numbers.bruijn b/samples/rosetta/luhn_test_of_credit_card_numbers.bruijn new file mode 100644 index 0000000..e52011e --- /dev/null +++ b/samples/rosetta/luhn_test_of_credit_card_numbers.bruijn @@ -0,0 +1,14 @@ +:import std/Combinator . +:import std/Math . +:import std/List . + +luhn number→list → reverse → check → (\mod (+10)) → zero? + check y [[[[0 [[[6 \5 (4 + (5 odd even)) 1]]] 1]]]] k (+0) + odd 2 + even digit-sum (2 ⋅ (+2)) + +:test (luhn (+61789372994)) ([[1]]) +:test (luhn (+49927398716)) ([[1]]) +:test (luhn (+49927398717)) ([[0]]) +:test (luhn (+1234567812345678)) ([[0]]) +:test (luhn (+1234567812345670)) ([[1]]) |