Code Snippets Reason

Short texts Reason 🧑‍💻 Code snippets Reason ✍️ Reading lists Reason 👀

.re functions

//########################### Main and run for data columns################################# let rec run = (index, size) => { let data = Array.of_list(String.split_on_char(‘ ‘, input_line(stdin))); print_string(generateChessBoard(data[0], data[1]) ++ ” “); if (index < (size - 1)) { run(index + 1, size) } } let main = () => { let size = int_of_string(input_line(stdin)); run(0, size); } main(); //############################ Main […]

GroupWhile for Rescript/Reason using Belt lib

type nonrec t(‘a) = list(‘a); let rec dropWhile = (t, ~f) => switch (t) { | [] => [] | [x, …rest] => if (f(x)) { dropWhile(rest, ~f); } else { t; } }; let takeWhile = (t, ~f) => { let rec takeWhileHelper = (acc, t) => switch (t) { | [] => Belt.List.reverse(acc) […]