Validate International Securities Identification Number: Difference between revisions

Content added Content deleted
No edit summary
(Added Quackery.)
Line 2,176: Line 2,176:


# [True, False, False, False, True, True, True]</lang>
# [True, False, False, False, True, True, True]</lang>

=={{header|Quackery}}==

<code>luhn</code> is defined at [[Luhn test of credit card numbers#Quackery]].

<lang Quackery> [ 2 split drop do
char A char z 1+ within
swap
char A char z 1+ within
and ] is 2chars ( $ --> b )
[ dup size 12 != iff
[ drop false ] done
dup 2chars not iff
[ drop false ] done
[] swap
witheach
[ 36 base put
char->n
base release
number$ join ]
$->n drop luhn ] is isin ( n --> b )

[ dup echo$
say " is "
isin not if
[ say "not " ]
say "valid." cr ] is task ( n --> )

$ "US0378331005" task
$ "US0373831005" task
$ "U50378331005" task
$ "US03378331005" task
$ "AU0000XVGZA3" task
$ "AU0000VXGZA3" task
$ "FR0000988040" task
</lang>

{{out}}

<pre>US0378331005 is valid.
US0373831005 is not valid.
U50378331005 is not valid.
US03378331005 is not valid.
AU0000XVGZA3 is valid.
AU0000VXGZA3 is valid.
FR0000988040 is valid.</pre>


=={{header|Racket}}==
=={{header|Racket}}==