Skip to content

Instantly share code, notes, and snippets.

View gupta82anish's full-sized avatar

Anish Gupta gupta82anish

  • Vinesia
  • Warsaw
  • 23:05 (UTC +02:00)
View GitHub Profile
-module(week227).
-compile([export_all]).
-include_lib("eunit/include/eunit.hrl").
join(Xs, Ys) ->
accumulate(shunt(Xs, []), Ys).
shunt([], Ys) ->
Ys;
@Joakineee
Joakineee / w2lists.erl
Last active May 16, 2020 09:37
Tail recursive lists
-module(w2lists).
-export([prod/1,mymax/1,test/0]).
%Moddified according Elbrujohalcon:
%Removed the "list is emty" function clause as we will let it crash.
%prod([]) ->
% "list is empty";
prod([H|T]) ->
prod(T,H).
@andrewhao
andrewhao / game.ex
Last active August 7, 2023 21:37
Dynamic Supervisors in Elixir
defmodule Game do
use GenServer
def init(game_id) do
{:ok, %{game_id: game_id}}
end
def start_link(game_id) do
GenServer.start_link(__MODULE__, game_id, name: {:global, "game:#{game_id}"})
end
@theaspect
theaspect / assignment1.erl
Last active May 13, 2020 08:46
Functional Erlang Assignment 1
-module(assignment1).
-include_lib("eunit/include/eunit.hrl").
-export([hypotenuse/2, area/1, perimeter/1, enclose/1, bits/1, bits_tail/1]).
% You can run test with:
% c(assignment1).
% assignment1:test().
% Available shapes:
% {circle, {X,Y}, R}
@lopspower
lopspower / README.md
Last active May 31, 2024 12:19
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@sdebnath
sdebnath / msort.erl
Created March 15, 2015 22:41
Mergesort in Erlang
%%==============================================================================
%% Mergesort implementation in Erlang
%%
%% Author: Shawn Debnath
%%==============================================================================
%%----------------------------------------------------------------------
%% msort/1
%%
%% Mergesort (recursive), implements split and merge.
@owickstrom
owickstrom / state.ex
Last active July 28, 2020 20:52
Exposing a synchronous API in Elixir. Inspired by http://elixir-lang.org/getting_started/mix_otp/3.html.
defmodule State.Counter do
use GenServer
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, :ok, opts)
end
## Client API
@doc "Gets the counter's current value."