package forester
A tool for tending mathematical forests
Install
Dune Dependency
Authors
Maintainers
Sources
2.3.tar.gz
md5=00fff94216aacd334351c2b1741d5246
sha512=724770d12a91674da76cc7842020ce7af2d37950d4429fe1ffac3b05d73a2079648f00c8eb33595e3dfa4874b2cd6b6a8c9d1f9034276a00b44d302091630cdb
doc/src/forester.core/BaseN.ml.html
Source file BaseN.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
module type I = sig val alphabet : string end module type S = sig val base : int val int_of_string : string -> int option val string_of_int : int -> string end module Make (I : I) : S = struct let base = String.length I.alphabet let int_of_string digits = let rec loop sum place r = if r < 0 then sum else let x = String.get digits r in let digit_value = String.index I.alphabet x in let sum' = sum + (place * digit_value) in let place' = place * base in loop sum' place' (r - 1) in let len = String.length digits in match loop 0 1 (len - 1) with | sum -> Some sum | exception _ -> None let string_of_int n = let len = max 4 @@ Int.succ @@ int_of_float @@ floor @@ log (float_of_int n) /. log (float_of_int base) in let bytes = Bytes.init len @@ fun _ -> '0' in let rec loop r i = if i <= 0 then Bytes.unsafe_to_string bytes else let x = String.get I.alphabet (i mod base) in Bytes.set bytes r x; loop (r - 1) (i / base) in loop (len - 1) n end module Base36 = Make (struct let alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" end)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>