RosettaCodeData/Task/Luhn-test-of-credit-card-numbers/YAMLScript/luhn-test-of-credit-card-numbers.ys
2025-08-12 11:43:10 -07:00

10 lines
206 B
Text

!YS-v0
defn main(*nums):
each cc nums:
say: "$cc - $if(cc:luhn? 'valid' 'invalid')"
defn luhn?(cc):
map(mul cc:digits:reverse [1 2]:cycle)
.map(\(I(_ / 10) + (_ % 10))):sum
.mod(10):zero?