How to resolve the algorithm CUSIP step by step in the zkl programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm CUSIP step by step in the zkl 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 zkl programming language

Source code in the zkl programming language

fcn cusipCheckDigit(cusip){
   var [const] vs=[0..9].chain(["A".."Z"],T("*","@","#")).pump(String);
   try{
      sum:=Walker.cycle(1,2).zipWith(fcn(n,c){ v:=vs.index(c)*n; v/10 + v%10 },
           cusip[0,8]).reduce('+);
      ((10 - sum%10)%10 == cusip[8].toInt()) and cusip.len()==9
   }catch{ False }
}

foreach cusip in (T("037833100", "17275R102",
		    "38259P508", "594918104", "68389X106", "68389X105")){
   println(cusip,": ",cusipCheckDigit(cusip));      
}

  

You may also check:How to resolve the algorithm Angle difference between two bearings step by step in the Mathematica/Wolfram Language programming language
You may also check:How to resolve the algorithm Generate lower case ASCII alphabet step by step in the Snobol programming language
You may also check:How to resolve the algorithm Associative array/Iteration step by step in the Stata programming language
You may also check:How to resolve the algorithm Variable size/Get step by step in the COBOL programming language
You may also check:How to resolve the algorithm Here document step by step in the Lingo programming language