Skip to content

Instantly share code, notes, and snippets.

View sushant12's full-sized avatar
😎
Focusing

Suss Buzz sushant12

😎
Focusing
  • Kathmandu
View GitHub Profile
Mix.install([:nimble_csv, :geo])
# defmodule DefinedZones do
# defstruct [:country, :city, :zone, :sub_zone, :priority, :geo]
# end
defmodule Converter do
alias NimbleCSV.RFC4180, as: CSV
def run() do
"demo.csv"
@sushant12
sushant12 / .iex.exs
Last active November 7, 2023 17:53
list or search through your iex history
# The bash command `history | grep abc` is a neat tool. I abuse it alot.
# So, I wrote a module that would list or search through iex history.
# https://dev.to/sushant12/list-all-history-in-iex-408b
# I prefer to put this module in my .iex.exs file and then import the .iex.exs file into my project.
defmodule History do
def search do
load_history()
|> Enum.with_index(1)
|> Enum.each(fn {value, index} ->
-module(palindrome).
-export([palindrome/1]).
palindrome(Xs) ->
Filtered = lists:filter(
fun(T) -> ((T >= $a) and (T =< $z)) or ((T >= $A) and (T =< $Z)) end,
string:to_lower(Xs)
),
Filtered == lists:reverse(Filtered).
-module(nub).
-export([nub/1]).
nub([]) -> [];
nub(Xs) -> nub(Xs, []).
nub([], C) -> lists:reverse(C);
nub([X | Xs], C) ->
Ret = case lists:member(X, C) of
true -> C;
-module(list).
-export([take/2]).
take(0, _L) -> [];
take(_N, []) -> [];
take(N, [X|Xs]) when is_integer(N) andalso N > 0 ->
[X | take(N-1, Xs)].
-module(assignment5).
-export([perimeter/1]).
perimeter({"square", Length}) ->
4 * Length;
perimeter({"triangle", SideA, SideB, SideC}) ->
SideA + SideB + SideC.
-module(assignment4).
-export([fib/1, perfect/1]).
fib(N) -> fib_tail(N, 0, 1).
fib_tail(0, X,_Y) -> X;
fib_tail(N, X, Y) when N > 0 -> fib_tail(N - 1, X + Y, X).
perfect(N) when N > 0 -> sum_divisors(N div 2, N, 0).
-module(assignment3).
-export([fib/1, pieces/1]).
fib(0) ->
0;
fib(1) ->
1;
fib(N) when N > 1 ->
-module(assignment2).
-export([maxThree/3, howManyEqual/3]).
maxThree(X,Y,Z) ->
case lists:sort([X,Y,Z]) of
[_,_,M] -> M;
_ -> 0
end.
-module(first).
-export([double/1,mult/2,area/3,square/1,trebel/1]).
mult(X,Y) ->
X*Y.
double(X) ->
mult(2,X).
area(A,B,C) ->