How to resolve the algorithm CUSIP step by step in the PicoLisp programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm CUSIP step by step in the PicoLisp programming language
Table of Contents
Problem Statement
A CUSIP is a nine-character alphanumeric code that identifies a North American financial security for the purposes of facilitating clearing and settlement of trades. The CUSIP was adopted as an American National Standard under Accredited Standards X9.6.
Ensure the last digit (i.e., the check digit) of the CUSIP code (the 1st column) is correct, against the following:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm CUSIP step by step in the PicoLisp programming language
Source code in the picolisp programming language
(de cusip (Str)
(let (Str (mapcar char (chop Str)) S 0)
(for (I . C) (head 8 Str)
(let V
(cond
((<= 48 C 57) (- C 48))
((<= 65 C 90) (+ 10 (- C 65)))
((= C 42) 36)
((= C 64) 37)
((= C 35) 38) )
(or
(bit? 1 I)
(setq V (>> -1 V)) )
(inc
'S
(+ (/ V 10) (% V 10)) ) ) )
(=
(- (last Str) 48)
(% (- 10 (% S 10)) 10) ) ) )
(println
(mapcar
cusip
(quote
"037833100"
"17275R102"
"38259P508"
"68389X106"
"68389X105" ) ) )
You may also check:How to resolve the algorithm Draw a clock step by step in the Red programming language
You may also check:How to resolve the algorithm Zig-zag matrix step by step in the K programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the LOLCODE programming language
You may also check:How to resolve the algorithm Mertens function step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Towers of Hanoi step by step in the Rascal programming language