;;; -*- Mode:LISP; Base:10; Readtable:CL -*- ;;; Given the list of 1-800 phone exchanges, crank out the combinations of numbers (defvar fourdigits "LISP") (defvar nls '((1 1 1 1) (2 a b c) (3 d e f) (4 g h i) (5 j k l) (6 m n o) (7 p r s) (8 t u v) (9 w x y))) (defconst ex '(223 227 248 255 262 322 323 327 332 338 342 346 356 422 426 445 451 458 521 522 528 527 533 537 541 542 543 544 548 553 622 624 634 635 637 638 642 648 722 752 782 822 832 852 872 922 942 962 992)) (defun charnum(c) (- c #\0)) (defun chardigits(c) (cdr(assoc c nls :test #'(lambda(a b)(equal (charnum a) b))))) (defun combs1(n) (let((x (format nil "~d" n))) (let((x1 (aref x 0)) (x2 (aref x 1)) (x3 (aref x 2))) (format t "~&N=~s" n) (dolist (a (chardigits x1)) (dolist (b (chardigits x2)) (dolist (c (chardigits x3)) (format t "~& 1-800-~a~a~a-~a" a b c fourdigits))))))) (defun combs(&optional (l ex)) (mapcar #'combs1 l))