;; octal r/w package: otoi & itoo

;;AUTOLOAD: otoi
;;AUTODOC: otoi "octal to decimal integer conversion"
;;(otoi string)
;;
;; Returns a decimal number built by reading its base 8
;;representation as a string or number
;;(otoi "145") ==> 101

(defun otoi (s &aux
    (n 0)
  )
  (map ()
    (lambda (c)
      (setq n (+ (* n 8) (- c #\0)))
    )
    (coerce (String s) List)
  )
  n
)

;;AUTOLOAD: itoo
;;AUTODOC: itoo "decimal to octal integer conversion"
;;(itoo number)
;;
;; Returns a number representing number in base 8
;;(itoo 101) ==> 145

(defun itoo (n &aux
    (s (copy ""))
  )
  (while (/= n 0)
    (setq s (+ (coerce (mod n 8) String) s))
    (setq n (/ n 8))
  )
  (setq s (+ "0" s))
  (Int s)
)
