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

Version Path
trackler-2.2.1.180 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.179 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.178 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.177 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.176 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.175 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.174 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.173 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.172 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.171 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.170 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.169 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.167 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.166 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.165 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.164 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.163 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.162 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.161 tracks/elisp/exercises/phone-number/example.el
trackler-2.2.1.160 tracks/elisp/exercises/phone-number/example.el