This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!


By: a guest on Feb 22nd, 2014  |  syntax: Clojure  |  size: 0.36 KB  |  views: 111  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ; Uses clojure.math.combinatorics for permutations function
  2. (ns scratchpad.core
  3.   (:require [clojure.math.combinatorics :as combo]))
  5. (defn check-anagrams [a b]
  6.   (let [permutations (map #(apply str %) (combo/permutations a))]
  7.     (filter (fn [p] (.contains b p)) permutations)))
  9. (check-anagrams "cat" "actor"); ("act")
  10. (check-anagrams "car" "actor"); ()
clone this paste RAW Paste Data