Validate International Securities Identification Number: Difference between revisions
Content deleted Content added
m →{{header|Haskell}}: (Tidied) |
No edit summary |
||
Line 1,802: | Line 1,802: | ||
AU0000VXGZA3 true |
AU0000VXGZA3 true |
||
FR0000988040 true</pre> |
FR0000988040 true</pre> |
||
=={{header|Mathematica}} / {{header|Wolfram Language}}== |
|||
<lang Mathematica>ClearAll[LuhnQ, VakudISINQ] |
|||
LuhnQ[n_Integer] := Block[{digits = Reverse@IntegerDigits@n}, Mod[Total[{digits[[;; ;; 2]], IntegerDigits[2 #] & /@ digits[[2 ;; ;; 2]]}, -1], 10] == 0] |
|||
VakudISINQ[sin_String] := Module[{s = ToUpperCase[sin]}, |
|||
If[StringMatchQ[s, |
|||
LetterCharacter ~~ LetterCharacter ~~ |
|||
Repeated[DigitCharacter | LetterCharacter, {9}] ~~ |
|||
DigitCharacter], |
|||
s = StringJoin[ |
|||
Characters[s] /. |
|||
Thread[CharacterRange["A", "Z"] -> ToString /@ Range[10, 35]]]; |
|||
LuhnQ[ToExpression[s]] |
|||
, |
|||
False |
|||
] |
|||
] |
|||
VakudISINQ /@ {"US0378331005", "US0373831005", "U50378331005", "US03378331005", "AU0000XVGZA3", "AU0000VXGZA3", "FR0000988040"}</lang> |
|||
{{out}} |
|||
<pre>{True, False, False, False, True, True, True}</pre> |
|||
=={{header|Nim}}== |
=={{header|Nim}}== |