Created
November 24, 2021 23:35
-
-
Save ebresafegaga/6a2acfca88b866445341fa94d6d54ecc to your computer and use it in GitHub Desktop.
Random Code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let subsequence longer shorter = | |
let rec inner l s = | |
match l, s with | |
| l :: ls, s :: ss when l = s -> inner ls ss | |
| _ :: ls , _ :: _ -> inner ls shorter | |
| [], _ -> false | |
| _, [] -> true | |
in | |
inner longer shorter | |
let rec rot list = | |
match list with | |
| [] -> [] | |
| x :: xs -> | |
let almost = rot xs in | |
match almost with | |
| [] -> [x] | |
| head :: tail -> head :: x :: tail | |
let rec rotn list = function | |
| n when n <= 0 -> list | |
| n -> rotn (rot list) (pred n) | |
let foldl op list = List.fold_right (fun elem f -> fun arg -> f @@ op arg elem) list (fun x -> x) | |
let rec incremnt y = | |
if y = 0 then 1 | |
else if y mod 2 = 1 then 2 * incremnt (y / 2) | |
else y + 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment