This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ erl | |
Erlang/OTP 20 [erts-9.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:10] [hipe] [kernel-poll:false] | |
Eshell V9.1 (abort with ^G) | |
1> c(tail_vs_direct). | |
{ok,tail_vs_direct} | |
2> tail_vs_direct:compare(). | |
[{5000, | |
{tail_c,{812,{total_heap_size,35462}}}, | |
{direct,{519,{total_heap_size,28689}}}}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(rps). | |
-export([beats/1]). | |
-export([result/2]). | |
-export([tournament/2]). | |
beats(rock) -> scissors; | |
beats(paper) -> rock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(test). | |
-compile(export_all). | |
%% API | |
-compile({inline, [ insert/2 | |
, merge/2 | |
]}). | |
insert(E, []) -> [E]; | |
insert(E, [E2|_] = H) when E =< E2 -> [E, H]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(test). | |
-compile(export_all). | |
%% API | |
-compile({inline, [ insert/2 | |
, merge/2 | |
]}). | |
insert(E, []) -> [E]; | |
insert(E, [E2|_] = H) when E =< E2 -> [E, H]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Power function (X ^ Y) and root function (X ^ (1/Y)) for | |
%% integers in Erlang | |
%% by Kenji Rikitake <[email protected]> 26-JAN-2010 | |
%% modified by Hynek Vychodil <[email protected]> 2-FEB-2010 | |
%% modified by Kenji Rikitake <[email protected]> 3-FEB-2010 | |
%% modified by Hynek Vychodil <[email protected]> 24-JUL-2016 | |
%% Distributed under MIT license at the end of the source code. | |
-module(bignum_root). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ erl -pa eministat/ebin | |
Erlang/OTP 18 [erts-7.3] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false] | |
Eshell V7.3 (abort with ^G) | |
1> {ok, Bin} = file:read_file("/home/hynek/Downloads/words.txt"), L = string:tokens(binary_to_list(Bin), "\s\r\n"), length(L). | |
113809 | |
2> length(lists:filter(fun stopwords_clause:is_stopword/1, L)). | |
122 | |
3> length(lists:filter(fun stopwords_map:is_stopword/1, L)). | |
122 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(test). | |
-export([bench_all/1, bench/2, bench/3]). | |
-export([ unique_monotonic_integer/0 | |
, update_counter/0 | |
]). | |
iters() -> 1000000. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <stdio.h> | |
#include <stdint.h> | |
// fast int | |
#if __WORDSIZE == 64 | |
typedef unsigned long int uint_fast_t; | |
#define UINT_FAST(c) c ## UL | |
#else | |
typedef unsigned int uint_fast_t; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Fibonacci number generator in Erlang | |
%% by Hynek Vychodil <[email protected]> 3-JAN-2014 | |
%% Distributed under MIT license at the end of the source code. | |
-module(fib). | |
-export([fib/1]). | |
% NOTE: Native compilation (HiPE) doesn't improve efficiency due heavy integer | |
% bignum computations as observed in R16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module(vertical_tree). | |
-export([draw/1, get_verical_lines/1]). | |
-record(node, { | |
value, | |
left = nil, | |
right = nil | |
}). |
NewerOlder