Common functions
Summary
Functions
Get modification time of file, or Unix epoch on error
Uniformly allocate data to one of a fixed set of buckets.
Get nth element from reversed list
Functions
@spec file_mtime(Path.t()) :: :calendar.datetime()
Get modification time of file, or Unix epoch on error
@spec hash_to_bucket(term(), pos_integer()) :: pos_integer()
Uniformly allocate data to one of a fixed set of buckets.
https://stats.stackexchange.com/questions/26344/how-to-uniformly-project-a-hash-to-a-fixed-number-of-buckets https://en.wikipedia.org/wiki/MurmurHash https://hex.pm/packages/murmur
def hash_to_bucket(e, B):
i = murmurhash3.to_long128(str(e))
p = i / float(2**128)
for j in range(0, B):
if j/float(B) <= p and (j+1)/float(B) > p:
return j+1
return B
@spec rnth(non_neg_integer(), list()) :: term()
Get nth element from reversed list
@spec rnth(non_neg_integer(), list(), non_neg_integer()) :: term()