elixir-lang/elixir — pull request #1717 by pminten (2013-09-19 17:21:15+00:00)
Title: Add String.category function

It looks up the Unicode general category of a codepoint (whether it is a letter,
space, etc).

Unlike other functions in String.Unicode this uses a binary tree with ranges. Not sure whether that's the right approach but it seems better than having a huge list of cases because the tree only uses two comparisons per continuous range of categories and has the usual binary tree lookup complexity (O(log2 n)). I'd expect the clauses to be checked one by one (though I could be wrong and Elixir or Erlang compiles them to very efficient code).