Equivalent of parse-integer in XLisp/Nyquist

In Common List there’s

(parse-integer "-64") ;; -64 and a 2nd return value, but that can be ignored

So what’s equivalent in XLisp/Nyquist? (I see there’s a read-int but that’s for a binary stream.)

Would be useful when reading e.g. numbers from Audacity labels, which are strings (I mean the labels themselves, not their times).

Nothing like that in Nyquist, so I added a helper function to Audacity’s version of Nyquist: “EVAL-STRING”

Example:

(+ (eval-string "-64") 4)  ;returns integer 60

EVAL-STRING can also be used with expressions.
Example:

(setf mystring "(+ 40 2)")
(eval-string mystring)  ;returns 42

Source: https://github.com/audacity/audacity/blob/master/nyquist/init.lsp

Also (discovered while you were writing the above)

(1+ (read (make-string-input-stream "64"))) ;; 65
(1+ (read (make-string-input-stream "-64"))) ;; -63

Which I see it’s exactly your implementation for eval-string :mrgreen:

Ok, no quite. You also have an eval in there, but that’s not needed to just get a number, only if you want an expression evaluator too.