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