Sha256: 79fb9a433d679d8e0bfeb088a9e47d48d835e98e8078fe869b4bc6049103447b

Contents?: true

Size: 563 Bytes

Versions: 396

Compression:

Stored size: 563 Bytes

Contents

(defmodule anagram
  (export (find 2)))

(defun find (word candidates)
  (let ((normed-word (normalize word)))
    (lists:filter
      (lambda (candidate) (anagram? normed-word (normalize candidate)))
      candidates)))

(defun anagram?
  ([`#(,word-lowered ,word-sorted) `#(,candidate-lowered ,candidate-sorted)]
   (when (andalso (=/= word-lowered candidate-lowered)
                  (=:= word-sorted  candidate-sorted)))
   'true)
  ([_ _]
   'false))

(defun normalize (str)
  (let ((lowered (string:to_lower str)))
    `#(,lowered ,(lists:sort lowered))))

Version data entries

396 entries across 396 versions & 1 rubygems

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