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
(function () { | |
var mrg = 0; | |
var id = 'slider'; | |
var klass = 'slider'; | |
var interval = 2000; | |
var mainEl = document.getElementById(id) | |
if (!mainEl) { | |
console.error('Failed to find El#' + id); | |
return; |
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
package main | |
import "fmt" | |
type IA interface { | |
methodA() | |
methodB() | |
} | |
type A struct {} |
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(main). | |
-export([join/2, concat/1, member/2, | |
merge_sort/1, qsort/1, insertion_sort/1, | |
perms/1]). | |
shunt([],Xs) -> | |
Xs; | |
shunt([X|Xs],Ys) -> | |
shunt(Xs,[X|Ys]). |
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(main). | |
-export([palindrome/1]). | |
-import(lists, [filter/2, map/2, reverse/1]). | |
is_between(X, A, B) -> | |
X >= A andalso B >= X. | |
is_lowercase_char(Ch) -> | |
is_between(Ch, $a, $z). |
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(main). | |
-export([nub/1, nub2/1, test/0]). | |
-import(lists, [reverse/1]). | |
nub(List) -> | |
Reversed = nub(List, sets:new(), []), | |
reverse(Reversed). | |
nub([], _, Result) -> Result; | |
nub([X|Xs], Set, Result) -> |
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(main). | |
-export([take/2, take_test/0]). | |
-spec take(integer(), [T]) -> [T]. | |
take(N, List) when N >= 0 -> take(N, List, []). | |
take(0, _List, Acc) -> Acc; | |
take(_N, [], Acc) -> Acc; | |
take(N, [X|Xs], Acc) -> take(N-1, Xs, Acc ++ [X]). |
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(main). | |
-export([double/1, evens/1, median/1, frequent/1]). | |
-import(my_lists, [map/2, filter/2, qsort/2, drop_first/1, drop_last/1]). | |
double(L) -> map(L, fun (X) -> 2*X end). | |
evens(L) -> filter(L, fun (X) -> (X rem 2) == 0 end). | |
% median value for sorted list | |
median_sorted([A]) -> A; |
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(recursion). | |
-export([reduce/3, max/1]). | |
reduce([], _Fn, I) -> I; | |
reduce([X|Xs],Fn,I) -> | |
reduce(Xs,Fn,Fn(I,X)). | |
max([X|Xs]) -> reduce(Xs, fun erlang:max/2, X). |
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(assignment). | |
-export([perimeter/1, area/1, enclose/1, bits/1, bits_direct/1, | |
test_perimeter/0, test_area/0, test_enclose/0, test_bits/0]). | |
% {circle, {X,Y}, R} | |
% Represents a circle. | |
% X,Y - center | |
% R - radius | |
% {rectangle, {X,Y}, H, W} |
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(recursion). | |
-export([fib/1, perfect/1]). | |
fib(N) when N > 0 -> | |
fib(N, 0, 1). | |
fib(1, First, _Second) -> | |
First; | |
fib(2, _First, Second) -> | |
Second; | |
fib(N, First, Second) -> |
NewerOlder