This file contains hidden or 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(join). | |
-import(lists,[foldr/3,foldl/3,filter/2,split/2,flatmap/2,map/2,seq/2]). | |
-export([join/2,concat/1,member/2,qsort/1,msort/1,isort/1,perms/1]). | |
join_([X|Xs],Ys) -> | |
join_(Xs, [X | Ys]); | |
join_([], Ys) -> | |
Ys. |
This file contains hidden or 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
nub([]) -> | |
[]; | |
nub([X|Xs]) -> | |
[X | nub (lists:filter(fun (E) -> E =/= X end, Xs)]. |
This file contains hidden or 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(bits). | |
-export([bits/1, bits2/1, bits3/1]). | |
bits_tail_rec(<<B:1, Rest/bitstring>>, A) -> | |
bits_tail_rec(Rest,B + A); | |
bits_tail_rec(<<>>, A) -> | |
A. | |
bits(N) -> |
This file contains hidden or 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(main). | |
-define(WINDOW_SIZE, 200000). | |
-define(MSG_COUNT, 1000000). | |
-define(MSG_SIZE, 1024). | |
-export([main/0]). | |
push_message(N, Tab) -> | |
Start = erlang:monotonic_time(), | |
Bin = list_to_binary(lists:duplicate(?MSG_SIZE, N rem 255)), |
This file contains hidden or 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(main). | |
-define(WINDOW_SIZE, 200000). | |
-define(MSG_COUNT, 1000000). | |
-define(MSG_SIZE, 1024). | |
-export([main/0]). | |
push_message(N) -> | |
Start = erlang:monotonic_time(), | |
Bin = list_to_binary(lists:duplicate(?MSG_SIZE, N rem 255)), |
This file contains hidden or 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
isSorted :: Tree -> Bool | |
isSorted t = isSortedTree t minBound maxBound | |
insert :: Tree -> Int -> Tree | |
insert Leaf e = Node e Leaf Leaf | |
insert n@(Node v l r) e | |
| v < e = Node v l (insert r e) | |
| v > e = Node v (insert l e) r | |
| otherwise = n |
This file contains hidden or 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
(setq inferior-erlang-machine "rebar3") | |
(setq inferior-erlang-machine-options '("shell")) | |
(setq inferior-erlang-shell-type nil) |
This file contains hidden or 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
#lang racket | |
(define (mlist . elem) | |
(mcons (car elem) | |
(if (null? (cdr elem)) | |
'() | |
(apply mlist (cdr elem))))) | |
;; has-cycle |
This file contains hidden or 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
(define-syntax (aif stx) | |
(syntax-case stx () | |
[(_ expr then else) | |
(with-syntax ([it (datum->syntax stx 'it)] ) | |
#'(let ((it expr)) | |
(if it then else)))])) |
This file contains hidden or 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
(define-syntax thread-first | |
(syntax-rules () | |
[(_ expr (fn args ...)) | |
(fn expr args ...)] | |
[(_ expr fn) | |
(fn expr)])) | |
(define-syntax cond-> | |
(syntax-rules () | |
[(_ expr test fn) |