This file contains hidden or 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
// #![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; |
This file contains hidden or 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
-- 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 |
This file contains hidden or 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
-- 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 |
This file contains hidden or 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
-- 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 |