Skip to content

Instantly share code, notes, and snippets.

View coder3112's full-sized avatar

Naitik Mundra coder3112

  • Buchs SG, Switzerland
View GitHub Profile
@coder3112
coder3112 / hashmap_bench.rs
Created July 30, 2025 12:57
Benchmarking problems.
// #![feature(box_as_ptr)]
use divan::AllocProfiler;
use divan::Bencher;
use divan::black_box;
use rand::rng;
use rand::seq::SliceRandom;
use hashbrown::HashMap as HashBrownHashMap;
@coder3112
coder3112 / filter.hs
Created July 2, 2022 19:19
Custom Implementation of filter
-- Custom Implementation of filter
filter' :: (a -> Bool) -> [a] -> [a]
filter' f [] = []
filter' f [x] = if (f x == True) then [x] else []
filter' f (x:xs) = filter' f [x] ++ filter' f xs
@coder3112
coder3112 / map.hs
Created July 2, 2022 19:07
Custom implementation of map in haskell (as practice)
-- Custom implementation of map
map' :: (a -> b) -> [a] -> [b]
map' f [] = []
map' f [x] = [f x]
map' f (x:xs) = map' f [x] ++ map' f xs
@coder3112
coder3112 / PrimeFactorization.hs
Created July 2, 2022 17:25
Prime Factorization in haskell to return a list of tuples giving the divisor as well as the power it is raised to.
-- Example:
-- > pf 120
-- [(2,3),(3,1),(5,1)] since 120 = 2^3 * 3^1 * 5^1
-- Thanks to leftaroundbot on stackoverflow for helping me out.
-- Tells us how many times a number can be divided by another
-- Eg: >dividerPower 120 5
-- 1
dividerPower :: Integer -> Integer -> Int
dividerPower n d