Determine if a sentence is a pangram. A pangram (Greek: παν γράμμα, pan gramma, "every letter") is a sentence using every letter of the alphabet at least once. The best known English pangram is:
The quick brown fox jumps over the lazy dog.
The alphabet used consists of ASCII letters
z, inclusive, and is case
insensitive. Input will not contain non-ASCII symbols.
It's possible to submit an incomplete solution so you can see how others have completed the exercise.
;;; pagram-test.el --- Tests for Pangram (exercism) ;;; Commentary: ;; Common test data version: 1.3.0 d79e13e ;;; Code: (load-file "pangram.el") (ert-deftest sentence-empty () (should (equal nil (is-pangram "")))) (ert-deftest recognizes-a-perfect-lower-case-pangram () (should (equal t (is-pangram "abcdefghijklmnopqrstuvwxyz")))) (ert-deftest pangram-with-only-lower-case () (should (equal t (is-pangram "the quick brown fox jumps over the lazy dog")))) (ert-deftest missing-character-x () (should (equal nil (is-pangram "a quick movement of the enemy will jeopardize five gunboats")))) (ert-deftest missing-another-character-eg-h () (should (equal nil (is-pangram "five boxing wizards jump quickly at it")))) (ert-deftest pangram-with-underscores () (should (equal t (is-pangram "the_quick_brown_fox_jumps_over_the_lazy_dog")))) (ert-deftest pangram-with-numbers () (should (equal t (is-pangram "the 1 quick brown fox jumps over the 2 lazy dogs")))) (ert-deftest missing-letters-replaced-by-numbers () (should (equal nil (is-pangram "7h3 qu1ck brown fox jumps ov3r 7h3 lazy dog")))) (ert-deftest pangram-with-mixed-case-and-punctuation () (should (equal t (is-pangram "\"Five quacking Zephyrs jolt my wax bed.\"")))) (ert-deftest upper-and-lower-case-versions-of-the-same-character-should-not-be-counted-separately () (should (equal nil (is-pangram "the quick brown fox jumps over with lazy FX")))) (provide 'pangram-test) ;;; pagram-test.el ends here
;;; pangram.el --- Pangram (exercism) ;;; Commentary: ;; Once again, the `thread-last' macro comes to the ;; rescue here, making the function a lot more ;; understandable, and readable from top to bottom. ;; The `seq' module has lots of useful functions. ;; ;; I'm creating the alphabet string using the function ;; `number-sequence', because in Elisp, there is no ;; difference between a char and an int. ;;; Code: (require 'subr-x) (require 'seq) (defun is-pangram (str) "Tell whether STR is a pangram." (thread-last str (replace-regexp-in-string "[^[:alpha:]]" "") (downcase) (string-to-list) (seq-sort #'<) (seq-uniq) (equal (number-sequence ?a ?z)))) (provide 'pangram) ;;; pangram.el ends here
A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.
Here are some questions to help you reflect on this solution and learn the most from it.