Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,25 @@
let popcount n =
let rec aux acc = function
| 0 -> acc
| x -> aux (succ acc) (x land pred x)
in
aux 0 n
let is_parity p x =
p = 1 land popcount x
(* test code *)
let powers3_seq () =
Seq.unfold (fun x -> Some (popcount x, x * 3)) 1
let parity_seq p =
Seq.(filter (is_parity p) (ints 0))
let print_seq_30 s =
Seq.(s |> take 30 |> map string_of_int)
|> List.of_seq |> String.concat " " |> print_endline
let () = print_seq_30 (powers3_seq ())
let () = print_seq_30 (parity_seq 0)
let () = print_seq_30 (parity_seq 1)