Sha256: 43f073c293956201caf6f9218199a3be053febe558ad0e630d72e63133ed0e46

Contents?: true

Size: 430 Bytes

Versions: 42

Compression:

Stored size: 430 Bytes

Contents

open Base

let to_sorted_list s = String.to_list s |> List.sort ~compare:Char.compare

let anagrams target candidates =
  let target_lc = String.lowercase target in
  let target_sorted = to_sorted_list target_lc in
  List.map ~f:(fun c -> (c, String.lowercase c)) candidates
  |> List.filter ~f:(fun (_, lc) ->
      List.equal ~equal:Char.equal (to_sorted_list lc) target_sorted && String.(lc <> target_lc))
  |> List.map ~f:fst

Version data entries

42 entries across 42 versions & 1 rubygems

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