Skip to content

Instantly share code, notes, and snippets.

View i7an's full-sized avatar

Ivan Yurchanka i7an

  • Railsware
  • Kraków
View GitHub Profile
@i7an
i7an / slider.js
Last active January 16, 2018 19:30 — forked from anonymous/slider.js
(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;
@i7an
i7an / main.go
Last active November 10, 2017 12:19
package main
import "fmt"
type IA interface {
methodA()
methodB()
}
type A struct {}
-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]).
-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).
-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) ->
-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]).
-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;
-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).
-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}
-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) ->