;;; binary.el --- Binary exercise (exercism) ;;; Commentary: ;;; Code: (require 'cl) (defun to-decimal-helper (str) (cl-loop with result = 0 for c across str do (setq result (+ (- c ?0) (* 2 result))) finally return result)) (defun to-decimal (str) (if (string-match "[01]+" str) (to-decimal-helper str) 0)) (provide 'binary) ;;; binary.el ends here