rosetta/luhn_test_of_credit_card_numbers.bruijn

Problem description

: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]])