Skip to content

Instantly share code, notes, and snippets.

View shubhamkumar13's full-sized avatar
๐Ÿ˜‘
is existing

shubham shubhamkumar13

๐Ÿ˜‘
is existing
View GitHub Profile
@shubhamkumar13
shubhamkumar13 / opam.export
Created September 21, 2020 20:08
Tezos 4.10.0+multicore opam
opam-version: "2.0"
compiler: [
"base-bigarray.base"
"base-threads.base"
"base-unix.base"
"ocaml.4.10.0"
"ocaml-secondary-compiler.4.10.0"
"ocaml-variants.4.10.0+multicore+no-effect-syntax"
]
roots: [
@shubhamkumar13
shubhamkumar13 / turing-trunk.md
Last active September 28, 2020 12:15
turing-trunk
name time_secs gc.major_collections gc.major_words
0 lu-decomposition. 1.32719 11 7775014
1 levinson-durbin. 2.74204 1894 250063925
2 menhir.sql-parser 6.98978 23 59727559
3 fft. 4.37065 41 140412857
4 setrip.-enc_-rseed_1067894368 1.52092 9 13301
5 yojson_ydump.sample.json 0.76486 17 2979936
6 revcomp2. 2.9139 25 49759392
7 test_decompress.64_524_288 4.1468 555 105774397
@shubhamkumar13
shubhamkumar13 / sherwood-trunk.md
Last active September 28, 2020 12:16
sherwood-trunk
name time_secs gc.major_collections gc.major_words
0 menhir.sql-parser 4.95038 23 59727559
1 spectralnorm2.5_500 5.02338 5 121482
2 test_decompress.64_524_288 2.55676 555 105774397
3 minilight.roomfront 13.6939 68 10648042
4 sequence_cps.10000 1.25108 777 219410
5 lexifi-g2pp. 7.1579 8 183441
6 durand-kerner-aberth. 0.0961349 92 237481
7 cpdf.blacktext 3.01654 14 27976325
@shubhamkumar13
shubhamkumar13 / permute_arr.ml
Last active October 23, 2020 03:58
Heap's algorithm
let generate (a : int array) : int array list =
let acc = ref [] in
let swap a i j = let tmp = a.(i) in a.(i) <- a.(j); a.(j) <- tmp in
let rec generate' (k : int) (a : int array) =
match k with
| 1 -> acc := (Array.copy a) :: !acc
| _ ->
for i=0 to pred k do
generate' (k - 1) a;
match k mod 2 with
diff --git a/orun/dune b/orun/dune
index 7020053..fe7d328 100644
--- a/orun/dune
+++ b/orun/dune
@@ -1,20 +1,31 @@
(library
(name wait4)
- (c_names wait4)
- (modules ))
+ (foreign_stubs
@shubhamkumar13
shubhamkumar13 / transpose.ml
Created October 12, 2020 00:44
Transpose in ocaml
let matrix_hd = fun matrix -> List.fold_left (fun acc x -> (List.hd x) :: acc) [] matrix |> List.rev
let matrix_tl = fun matrix -> List.fold_left (fun acc x -> (List.tl x) :: acc) [] matrix |> List.rev
let transpose = fun matrix ->
let rec loop = fun acc matrix ->
match matrix with
| hd :: tl when (List.length hd) = 0 -> acc
| x -> loop ((matrix_hd x) :: acc) (matrix_tl x) in
loop [] matrix |> List.rev
@shubhamkumar13
shubhamkumar13 / str_to_strlst.ml
Created October 12, 2020 00:51
Convert string to string list
let str_to_strlst = fun str ->
let rec loop = fun acc str ->
match String.head str with
| Some(x) when x = ',' -> loop acc (tail str)
| Some(x) -> loop (x :: acc) (tail str)
| None -> acc in
loop [] str |> List.map (Printf.sprintf "%c") |> List.rev
@shubhamkumar13
shubhamkumar13 / fft.md
Created October 12, 2020 11:12
fft results

| | name | command | time_secs | user_time_secs | sys_time_secs | maxrss_kB | codesize | ocaml_url | ocaml.version | ocaml.c_compiler | ocaml.architecture | ocaml.word_size | ocaml.system | ocaml.function_sections | ocaml.supports_shared_libraries | gc.allocated_words | gc.minor_words | gc.promoted_words | gc.major_words | gc.minor_collections | gc.major_collections | gc.heap_words | gc.heap_chunks | gc.top_heap_words | gc.compactions | gc.forced_major_collections | variant | ocaml.linear_magic_number | display_name | |---:|:-------|:-------------------------------|------------:|-----------------:|----------------:|------------:|-----------:|:--------------------------------------------------------------------------------|:-----------------------|:-------------------|:---------------------|------------------:|:---------------|:--------------------

| | name | command | time_secs | user_time_secs | sys_time_secs | maxrss_kB | codesize | ocaml_url | ocaml.version | ocaml.c_compiler | ocaml.architecture | ocaml.word_size | ocaml.system | ocaml.function_sections | ocaml.supports_shared_libraries | gc.allocated_words | gc.minor_words | gc.promoted_words | gc.major_words | gc.minor_collections | gc.major_collections | gc.heap_words | gc.heap_chunks | gc.top_heap_words | gc.compactions | gc.forced_major_collections | variant | |---:|:-------|:-------------------------------|------------:|-----------------:|----------------:|------------:|-----------:|:---------------------------------------------------------------------------------------|:-----------------------|:-------------------|:---------------------|------------------:|:---------------|:--------------------------|:-------------------------

@shubhamkumar13
shubhamkumar13 / csv_to_html_table.ml
Created October 12, 2020 17:02
Convert as csv to an html table
module String = struct
include Astring.String
let tail str = with_index_range ~first:1 ~last:(length str) str
end
let create_thead str =
let rec loop acc_lst acc_str str =
match String.head str with
| Some ch when ch = ',' -> loop (acc_str :: acc_lst) "" (String.tail str)