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.159 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.158 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.157 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.156 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.155 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.154 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.153 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.152 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.151 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.150 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.149 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.148 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.147 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.146 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.145 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.144 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.143 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.142 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.141 tracks/ocaml/exercises/anagram/example.ml
trackler-2.2.1.140 tracks/ocaml/exercises/anagram/example.ml