How to determine signed integer?

Started by Jeremy Dunn, December 14, 2007, 07:56:15 PM

Previous topic - Next topic

Jeremy Dunn

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?

newdep

#1
I think that only 'format is able to distinguish those..
-- (define? (Cornflakes))

cormullion

#2
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...?