Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting Char to Integer in Common Lisp

What is the proper way to convert the character #\1 to the integer 1? I coerced a number into a list and got this: (#\1 #\2 #\3)

and want to convert that into

(1 2 3)
like image 546
H44 Avatar asked Dec 31 '22 22:12

H44


1 Answers

CL-USER > (digit-char-p #\1)
1

digit-char-p returns

  • the numeric value of the character, if it is a digit char
  • NIL otherwise

Thus it is both:

  • a predicate, since numbers are true
  • a conversion function
like image 68
Rainer Joswig Avatar answered Jan 05 '23 15:01

Rainer Joswig