User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:digit-char-p [2019/09/14 05:00]
cl:functions:digit-char-p [2019/09/20 08:00] (current)
Line 1: Line 1:
 +====== Function DIGIT-CHAR-P ======
 +
 +====Syntax====
 +  * **digit-char-p** //char ''&​optional''​ radix// → //weight//
 +
 +====Arguments and Values====
 +  * //char// - a //​[[CL:​Glossary:​character]]//​.
 +  * //radix// - a //​[[CL:​Glossary:​radix]]//​. The default is ''​10''​.
 +  * //weight// - either a non-negative //​[[CL:​Glossary:​integer]]//​ less than //radix//, or //​[[CL:​Glossary:​false]]//​.
 +
 +====Description====
 +Tests whether //char// is a digit in the specified //radix// (i.e. with a weight less than //radix//). If it is a digit in that //radix//, its weight is returned as an //​[[CL:​Glossary:​integer]]//;​ otherwise **[[CL:​Constant Variables:​nil]]** is returned.
 +
 +====Examples====
 +<​blockquote> ​
 +(digit-char-p #\5) <​r>​5</​r>​
 +(digit-char-p #\5 2) <​r>//​[[CL:​Glossary:​false]]//​ </r>
 +(digit-char-p #\A) <​r>//​[[CL:​Glossary:​false]]//​ </r>
 +(digit-char-p #\a) <​r>//​[[CL:​Glossary:​false]]//​ </r>
 +(digit-char-p #\A 11) <r>10 </r>
 +(digit-char-p #\a 11) <r>10 </r>
 +
 +([[CL:​Functions:​mapcar]] #'​([[CL:​Symbols:​lambda]] (radix) ([[CL:​Functions:​map]] '​[[CL:​Types:​list]] #'​([[CL:​Symbols:​lambda]] (x) (digit-char-p x radix)) "​059AaFGZ"​)) ​
 +       '​(2 8 10 16 36)) 
 +<​r>​((0 NIL NIL NIL NIL NIL NIL NIL) 
 + (0 5   NIL NIL NIL NIL NIL NIL) 
 + (0 5   ​9 ​  NIL NIL NIL NIL NIL) 
 + (0 5   ​9 ​  ​10 ​ 10  15  NIL NIL) 
 + (0 5   ​9 ​  ​10 ​ 10  15  16  35 ))</​r>​
 +</​blockquote>​
 +
 +====Affected By====
 +None. (In particular, the results of this predicate are independent of any special syntax which might have been enabled in the //​[[CL:​Glossary:​current readtable]]//​.)
 +
 +====Exceptional Situations====
 +None.
 +
 +====Editor Notes====
 +The output of **digit-char-p** might be confusing, as this function'​s [[CL:​Glossary:​return value]] also serves a different purpose. **digit-char-p**,​ aside from being a [[CL:​Glossary:​predicate]],​ is also a converting function: it converts a [[CL:​Glossary:​digit]] in a given [[CL:​Glossary:​radix]] to its corresponding [[CL:​Glossary:​integer]] value.
 +
 +====See Also====
 +**[[CL:​Functions:​alphanumericp|Function ALPHANUMERICP]]**
 +
 +====Notes====
 +
 +Digits are //​[[CL:​Glossary:​graphic]]//​ //​[[CL:​Glossary:​character|characters]]//​.
 +