0 Members and 1 Guest are viewing this topic.
(numberp (read <str>))
(member (type (read <str>)) '(int real))
(distof <str> 2)
(wcmatch <str> "~*[~0-9]*")
(vl-every '(lambda ( x ) (< 47 x 58)) (vl-string->list <str>))
(eval (read <str>))
Comando: (setq astring ".2")".2"Comando: (numberp (read astring)); errore: punto in posizione non corretta nell'inputComando: (member (type (read astring)) '(int real)); errore: punto in posizione non corretta nell'inputComando: (distof astring 2)0.2Comando: (wcmatch astring "~*[~0-9]*")nilComando: (vl-every '(lambda ( x ) (< 47 x 58)) (vl-string->list astring))nilComando: (setq astring "0.2")"0.2"Comando: (numberp (read astring))TComando: (member (type (read astring)) '(int real))(REAL)Comando: (distof astring 2)0.2Comando: (wcmatch astring "~*[~0-9]*")nilComando: (vl-every '(lambda ( x ) (< 47 x 58)) (vl-string->list astring))nil
(defun IsnumericP (str) (numberp (distof str)))Comando: (IsnumericP "2")TComando: (IsnumericP "2.0")TComando: (IsnumericP ".2")T
Since any non-nil value will validate a conditional function, the expression need not explicitly return T....
Quote from: Lee Mac on April 20, 2015, 12:35:20 PMSince any non-nil value will validate a conditional function, the expression need not explicitly return T....Sorry, I do not understand what you mean, maybe the more correct name of the function was IsNumeric or NumericP?
...Since distof will return nil if the string content is not numerical.
Comando: (distof "1/1")1.0Comando: (numberp "1/1")nil
(setq str "7")(wcmatch str "#")
Quote from: Lee Mac on April 22, 2015, 05:08:59 PM...Since distof will return nil if the string content is not numerical.Grazie mille for the explanation, all okay... ...but there is at least one exception (that I know):Code: [Select]Comando: (distof "1/1")1.0Comando: (numberp "1/1")nil
Quote from: Marc'Antonio Alessi on April 23, 2015, 04:03:55 AMQuote from: Lee Mac on April 22, 2015, 05:08:59 PM...Since distof will return nil if the string content is not numerical.Grazie mille for the explanation, all okay... ...but there is at least one exception (that I know):Code: [Select]Comando: (distof "1/1")1.0Comando: (numberp "1/1")nilI think you are confused here. The numberp function will return nil for any string.Note that both of Lee's last examples retain a call to the distof function.
Comando: (numberp 1/1)nil
; Rel. 1.1(defun NumericP (str) (and (distof str) (numberp (read (strcat "0" str))) ))(NumericP "1/1a") => nil(NumericP "1/1" ) => nil(NumericP "1.0" ) => T(NumericP ".1" ) => T