Logo

Programming-Idioms

  • Lisp
  • Go
  • JS
uses SysUtils;
i := StrToInt(S);

The function StrToInt will raise an exception of type EConvertError if the string is not a proper representation of an integer.
(setf i (parse-integer s))
import "strconv"
i, err  := strconv.Atoi(s) 

Atoi(s) is shorthand for ParseInt(s, 10, 0). It yields type int.
import "strconv"
i, err := strconv.ParseInt(s, 10, 0)

Radix 10. The third argument 0 means "fit in implementation-specific int". But the result type is always int64.
Don't ignore the potential error err !
const i = +s
const i = Number(s);
let i = parseInt(s, 10)

parseInt(string, radix);
The radix is an integer between 2 and 36.
I : Integer := Integer'Value (s);

New implementation...