Data update

This commit is contained in:
Ingy dot Net 2024-04-19 16:56:29 -07:00
parent 0df55f9f24
commit aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions

View file

@ -0,0 +1,30 @@
:import luhn_test_of_credit_card_numbers .
:import std/Number/Conversion .
:import std/Combinator .
:import std/String .
:import std/Char .
:import std/Logic .
:import std/Number .
# verifies ISIN format
format? [len ⋀? country ⋀? security ⋀? checksum]
len (length 0) =? (+12)
country all? uppercase? (take (+2) 0)
security all? (φ or? uppercase? numeric?) (take (+9) (drop (+2) 0))
checksum numeric? _0
# performs luhn test
checksum? (map (from-base36 → number→string)) → concat → string→number → luhn
from-base36 binary→ternary → [(0 - (0 ≥? (+65) ((+65) - (+10)) (+48)))]
# performs format and checksum test
validate φ and? format? checksum?
:test (validate "US0378331005") (true)
:test (validate "US0373831005") (false)
:test (validate "U50378331005") (false)
:test (validate "US03378331005") (false)
:test (validate "AU0000XVGZA3") (true)
:test (validate "AU0000VXGZA3") (true)
:test (validate "FR0000988040") (true)

View file

@ -1,15 +1,19 @@
val .luhntest = f(.s) {
val .luhntest = fn(.s) {
val .t = [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
val .numbers = s2n .s
val .oddeven = len(.numbers) rem 2
for[=0] .i of .numbers {
_for += if(.i rem 2 == .oddeven: .numbers[.i]; .t[.numbers[.i]+1])
_for += if .i rem 2 == .oddeven {
.numbers[.i]
} else {
.t[.numbers[.i]+1]
}
} div 10
}
val .isintest = f(.s) {
matching(re/^[A-Z][A-Z][0-9A-Z]{9}[0-9]$/, .s) and
val .isintest = fn(.s) {
.s -> re/^[A-Z][A-Z][0-9A-Z]{9}[0-9]$/ and
.luhntest(join s2n .s)
}