Sha256: dc5aa35db3de0056eb683e61e965121e256a8969245fdea945413a30305a7e71
Contents?: true
Size: 673 Bytes
Versions: 216
Compression:
Stored size: 673 Bytes
Contents
;;; phone-number.el --- phone-number Exercise (exercism) ;;; Commentary: ;;; Code: (defun numbers (num) (let ((number (replace-regexp-in-string "[^0-9]+" "" num))) (cond ((= (length number) 10) number) ((and (= (length number) 11) (string-equal (substring number 0 1) "1")) (substring number 1)) (t "0000000000")))) (defun area-code (num) (substring (numbers num) 0 3)) (defun prefix (num) (substring (numbers num) 3 6)) (defun line-number (num) (substring (numbers num) 6)) (defun pprint (num) (format "(%s) %s-%s" (area-code num) (prefix num) (line-number num))) (provide 'phone-number) ;;; phone-number.el ends here
Version data entries
216 entries across 216 versions & 1 rubygems