## prime-sizes.pkg
# Compiled by:
#
src/lib/std/standard.lib# A list of prime numbers for sizing hashtables, etc.
### "Everyone is entitled to his own opinion,
### but not his own facts."
###
### -- Daniel Moynihan
package prime_sizes: (weak) api {
pick: Int -> Int;
}
{
# This is a sequence of prim numbers; each number is approx. sqrt (2)
# larger than the previous one in the series. The list is organized
# into sublists to make searches faster.
primes = [
(47, [11, 13, 17, 23, 37, 47]),
(367, [67, 97, 131, 191, 257, 367]),
(2897, [521, 727, 1031, 1451, 2053, 2897]),
(23173, [4099, 5801, 8209, 11587, 16411, 23173]),
(185369, [32771, 46349, 65537, 92683, 131101, 185369]),
(1482919, [262147, 370759, 524309, 741457, 1048583, 1482919]),
(2097169, [2097169])
];
fun pick i
=
f primes
where
fun f [] => raise exception DIE "PrimeSizes::pick: out of sequences";
f [(p, _)] => p;
f ((hi, l) ! r) => if (i < hi ) g l; else f r; fi;
end
also
fun g [] => raise exception DIE "PrimeSizes::pick: out of primes in sequence";
g [p] => p;
g (p ! r) => if (i < p) p;
else g r;
fi;
end;
end;
};
## COPYRIGHT (c) 2001 Bell Labs, Lucent Technologies
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.