newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Jeremy Dunn on December 14, 2007, 07:56:15 PM

Title: How to determine signed integer?
Post by: Jeremy Dunn on December 14, 2007, 07:56:15 PM
I have a situation where I want to determine if my function received +2 vs just 2 from the user. If I use "integer?" as my test both versions return true. If I try using "string" both values return "2". Is there any way to identify a positive signed integer versus a positive unsigned integer? If not, could "string" be modified to return the input literally?
Title:
Post by: newdep on December 14, 2007, 11:32:42 PM
I think that only 'format is able to distinguish those..
Title:
Post by: cormullion on December 15, 2007, 12:39:06 AM
A thought: if r is "+2" and s is "2", then the following is true:


(and (= (eval-string r) (eval-string s)) (!= (length r) (length s)))

ie they're the same thing but different lengths. Trouble is, it might be true for other pairs of strings...?