Skip to main content
deleted 1 character in body
Source Link
gigiair
  • 2.3k
  • 1
  • 11
  • 15

the read function can be applied to a string and then the numberp function tests whether the read object represents a number or not, integer, or float.

(mapcar (lambda(x)(numberp(read x))) (list "123" "1.23" "sqrt(123)" "12e-3" "12ab3")) 

=>

 (t t nil t nil) 

You catch any error with this function

(defun string-numberp(s) (condition-case 'invalidinvalid-read-syntax (numberp(read s)) (error nil))) 

Test :

(mapcar #'string-numberp (list "12345" "12.345" "#12345" "." "," "\n")) 

=>

(t t nil nil nil nil) 

the read function can be applied to a string and then the numberp function tests whether the read object represents a number or not, integer, or float.

(mapcar (lambda(x)(numberp(read x))) (list "123" "1.23" "sqrt(123)" "12e-3" "12ab3")) 

=>

 (t t nil t nil) 

You catch any error with this function

(defun string-numberp(s) (condition-case 'invalid-read-syntax (numberp(read s)) (error nil))) 

Test :

(mapcar #'string-numberp (list "12345" "12.345" "#12345" "." "," "\n")) 

=>

(t t nil nil nil nil) 

the read function can be applied to a string and then the numberp function tests whether the read object represents a number or not, integer, or float.

(mapcar (lambda(x)(numberp(read x))) (list "123" "1.23" "sqrt(123)" "12e-3" "12ab3")) 

=>

 (t t nil t nil) 

You catch any error with this function

(defun string-numberp(s) (condition-case invalid-read-syntax (numberp(read s)) (error nil))) 

Test :

(mapcar #'string-numberp (list "12345" "12.345" "#12345" "." "," "\n")) 

=>

(t t nil nil nil nil) 
added 13 characters in body
Source Link
gigiair
  • 2.3k
  • 1
  • 11
  • 15

the read function can be applied to a string and then the numberp function tests whether the read object represents a number or not, integer, or float.

(mapcar (lambda(x)(numberp(read x))) (list "123" "1.23" "sqrt(123)" "12e-3" "12ab3")) 

=>

 (t t nil t nil) 

You catch any error with this function

(defun string-numberp(s) (condition-case invalid'invalid-read-syntax (numberp(read s)) (error nil))) 

Test :

(mapcar #'string-numberp (list "12345" "12.345" "#12345" "." "," "\n")) 

=>

(t t nil nil nil nil) 

the read function can be applied to a string and then the numberp function tests whether the read object represents a number or not, integer, or float.

(mapcar (lambda(x)(numberp(read x))) (list "123" "1.23" "sqrt(123)" "12e-3" "12ab3")) 

=>

 (t t nil t nil) 

You catch any error with this function

(defun string-numberp(s) (condition-case invalid (numberp(read s)) (error nil))) 

Test :

(mapcar #'string-numberp (list "12345" "12.345" "#12345" "." "," "\n")) 

=>

(t t nil nil nil nil) 

the read function can be applied to a string and then the numberp function tests whether the read object represents a number or not, integer, or float.

(mapcar (lambda(x)(numberp(read x))) (list "123" "1.23" "sqrt(123)" "12e-3" "12ab3")) 

=>

 (t t nil t nil) 

You catch any error with this function

(defun string-numberp(s) (condition-case 'invalid-read-syntax (numberp(read s)) (error nil))) 

Test :

(mapcar #'string-numberp (list "12345" "12.345" "#12345" "." "," "\n")) 

=>

(t t nil nil nil nil) 
Correcting a bug.
Source Link
gigiair
  • 2.3k
  • 1
  • 11
  • 15

the read function can be applied to a string and then the numberp function tests whether the read object represents a number or not, integer, or float.

(mapcar (lambda(x)(numberp(read x))) (list "123" "1.23" "sqrt(123)" "12e-3" "12ab3")) 

=>

 (t t nil t nil) 

You catch any error with this function

(defun string-numberp(s) (condition-case invalid (numberp(read s)) (error nil))) 

Test :

(mapcar #'string-numberp (list "12345" "12.345" "#12345" "." "," "\n")) 

=>

(t t nil nil nil nil) 

the read function can be applied to a string and then the numberp function tests whether the read object represents a number or not, integer, or float.

(mapcar (lambda(x)(numberp(read x))) (list "123" "1.23" "sqrt(123)" "12e-3" "12ab3")) 

=>

 (t t nil t nil) 

the read function can be applied to a string and then the numberp function tests whether the read object represents a number or not, integer, or float.

(mapcar (lambda(x)(numberp(read x))) (list "123" "1.23" "sqrt(123)" "12e-3" "12ab3")) 

=>

 (t t nil t nil) 

You catch any error with this function

(defun string-numberp(s) (condition-case invalid (numberp(read s)) (error nil))) 

Test :

(mapcar #'string-numberp (list "12345" "12.345" "#12345" "." "," "\n")) 

=>

(t t nil nil nil nil) 
Source Link
gigiair
  • 2.3k
  • 1
  • 11
  • 15
Loading