Skip to content

Instantly share code, notes, and snippets.

@beleon
beleon / FastPrimes.hs
Created December 17, 2020 18:38
Fast purely functional primes in Haskell without dependencies
data PriorityQueue k a = Nil
| Branch k a (PriorityQueue k a) (PriorityQueue k a)
primes :: [Int]
primes = 2 : 3 : 5 : 7 : sieve (spin wheel2357 11)
where
wheel2357 = 2:4:2:4:6:2:6:4:2:4:6:6:2:6:4:2:6:4:6:8:4:2:4:2:4:8:6:4:6
:2:4:6:2:6:6:4:2:4:6:2:6:4:2:4:2:10:2:10:wheel2357
sieve [] = []
sieve (x:xs) = x : sieve' xs (insertprime x xs empty)
@beleon
beleon / shortstat_today.sh
Created January 14, 2019 11:50 — forked from loganlinn/shortstat_today.sh
git shortstat for self in last 24 hours
git log --author=`git config user.name` --shortstat --since=yesterday | grep 'files changed' | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "", files, "files changed,", inserted, "insertions(+),", deleted, "deletions(-)"}'