Sha256: 80d57169fe4810d0c9888c93cfde7d331479174c3632c673416a08079d22e007

Contents?: true

Size: 628 Bytes

Versions: 396

Compression:

Stored size: 628 Bytes

Contents

#lang racket

(provide
 ;; String [Listof String] -> [Listof String]
 ;; pick candidates for anagrams from the given list
 ;; def. a candidate consists of the same letters as subject
 anagrams-for)

;; -----------------------------------------------------------------------------
(define (anagrams-for subject candidates)
  (filter (lambda (w) (anagram? w subject)) candidates))

;; String String -> Boolean
;; is a an anagram for b?
(define (anagram? a b)
  (define (sorted-string s)
    (list->string (sort (string->list s) char-ci<?)))
  (and
   (string-ci=? (sorted-string a) (sorted-string b))
   (not (string-ci=? a b))))

Version data entries

396 entries across 396 versions & 1 rubygems

Version Path
trackler-2.2.1.159 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.158 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.157 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.156 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.155 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.154 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.153 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.152 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.151 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.150 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.149 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.148 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.147 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.146 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.145 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.144 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.143 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.142 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.141 tracks/racket/exercises/anagram/example.rkt
trackler-2.2.1.140 tracks/racket/exercises/anagram/example.rkt