Sha256: eb86642e5d643b0c13a9f04207b282dd21bb19b8790fe32e586b6c62461c9c5e

Contents?: true

Size: 512 Bytes

Versions: 13

Compression:

Stored size: 512 Bytes

Contents

let wordCount = (input: string) =>
  input
  |> Js.String.toLowerCase
  |> Js.String.replaceByRe([%re "/[^'a-zA-Z0-9]+/g"], " ")
  |> Js.String.trim
  |> Js.String.splitByRe([%re "/'?\\s+'?/"])
  |> Js.Array.reduce(
       (dict, word) => {
         let count = Js.Dict.get(dict, word);

         switch (count) {
         | Some(value) => Js.Dict.set(dict, word, value + 1)
         | None => Js.Dict.set(dict, word, 1)
         };

         dict;
       },
       Js.Dict.empty(),
     )
  |> Js.Dict.entries;

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.179 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.178 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.177 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.176 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.175 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.174 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.173 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.172 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.171 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.170 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.169 tracks/reasonml/exercises/word-count/src/Example.re
trackler-2.2.1.167 tracks/reasonml/exercises/word-count/src/Example.re