Avatar of joaofnds

joaofnds's solution

to Isogram in the Common Lisp Track

Published at Oct 27 2019 · 0 comments
Test suite

Determine if a word or phrase is an isogram.

An isogram (also known as a "nonpattern word") is a word or phrase without a repeating letter, however spaces and hyphens are allowed to appear multiple times.

Examples of isograms:

  • lumberjacks
  • background
  • downstream
  • six-year-old

The word isograms, however, is not an isogram, because the s repeats.


Check out Installing Common Lisp for instructions to get started or take a look at the guides available in the track's side bar.


While Common Lisp doesn't care about indentation and layout of code, nor whether you use spaces or tabs, this is an important consideration for submissions to exercism.io. Excercism.io's code widget cannot handle mixing of tab and space characters well so using only spaces is recommended to make the code more readable to the human reviewers. Please review your editors settings on how to accomplish this. Below are instructions for popular editors for Common Lisp.


Use the following commands to ensure VIM uses only spaces for indentation:

:set tabstop=2
:set shiftwidth=2
:set expandtab

(or as a oneliner :set tabstop=2 shiftwidth=2 expandtab). This can be added to your ~/.vimrc file to use it all the time.


Emacs is very well suited for editing Common Lisp and has many powerful add-on packages available. The only thing that one needs to do with a stock emacs to make it work well with exercism.io is to evaluate the following code:

(setq-default indent-tabs-mode nil)

This can be placed in your ~/.emacs (or ~/.emacs.d/init.el) in order to have it set whenever Emacs is launched.

One suggested add-on for Emacs and Common Lisp is SLIME which offers tight integration with the REPL; making iterative coding and testing very easy.


Wikipedia https://en.wikipedia.org/wiki/Isogram

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.


(ql:quickload "lisp-unit")
#-xlisp-test (load "isogram")

(defpackage #:isogram-test
  (:use #:common-lisp #:lisp-unit))

(in-package #:isogram-test)

(define-test empty-string
  (assert-true (isogram:is-isogram "")))

(define-test isogram-with-only-lower-case-characters
  (assert-true (isogram:is-isogram "isogram")))

(define-test word-with-one-duplicated-character
  (assert-false (isogram:is-isogram "eleven")))

(define-test longest-reported-english-isogram
  (assert-true (isogram:is-isogram "subdermatoglyphic")))

(define-test word-with-duplicated-character-in-mixed-case
  (assert-false (isogram:is-isogram "Alphabet")))

(define-test hypothetical-isogrammic-word-with-hyphen
  (assert-true (isogram:is-isogram "thumbscrew-japingly")))

(define-test isogram-with-duplicated-hyphen
  (assert-true (isogram:is-isogram "six-year-old")))

(define-test made-up-name-that-is-an-isogam
  (assert-true (isogram:is-isogram "Emily Jung Schwartzkopf")))

(define-test duplicated-character-in-the-middle
  (assert-false (isogram:is-isogram "accentor")))

(let ((*print-errors* t)
      (*print-failures* t))
  (run-tests :all :isogram-test))
(defpackage #:isogram
  (:use #:cl)
  (:export #:is-isogram))

(in-package #:isogram)

(defun is-isogram (string)
  "Is string an Isogram?"
  (loop :for char :across string
        :for i :from 1
        :never (and (alpha-char-p char)
                    (find char string :start i :test #'char-equal))))

Community comments

Find this solution interesting? Ask the author a question to learn more.

What can you learn from this solution?

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.

  • What compromises have been made?
  • Are there new concepts here that you could read more about to improve your understanding?