Skip to content

Instantly share code, notes, and snippets.

View aialferov's full-sized avatar

Anton I Alfёrov aialferov

View GitHub Profile
@aialferov
aialferov / number_to_text
Created October 8, 2014 13:41
Converts number to its text representation.
-module(number_to_text).
-export([convert/1]).
-define(Part(N), case N of
2 -> "thousand";
3 -> "million";
4 -> "billion";
5 -> "trillion"
end).
@aialferov
aialferov / upper_lower
Last active December 23, 2015 03:39
Cyrillic (utf8) to_lower/to_upper in erlang.
to_upper(S) -> to_upper(S, []).
to_upper([H1,H2|T], Acc) -> to_upper(T, case {H1,H2} of
{209,145} -> [H2 - 16,208|Acc];
{208,191} -> [H2 - 31,208|Acc];
{209,128} -> [H2 + 31,208|Acc];
{208,X} when 176 =< X, X =< 190 -> [X - 32,208|Acc];
{209,X} when 129 =< X, X =< 143 -> [X + 32,208|Acc];
_ -> [H2,H1|Acc]
end);
to_upper([H], Acc) -> lists:reverse([H|Acc]);