Created
June 6, 2023 15:58
-
-
Save mralfarrakhan/4461eeae91b5c8d56f75ff72b9d7cd7f to your computer and use it in GitHub Desktop.
doubling rotate or something
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
| (* input *) | |
| let q = ['A'; 'B'; 'C'; 'D'; 'E'];; | |
| let pos = 20;; | |
| let rec list_print queue = | |
| match queue with | |
| | [] -> () | |
| | h :: t -> | |
| Printf.printf "%c " h; | |
| list_print t;; | |
| let rec doubling queue n = | |
| match n with | |
| | 0 -> queue | |
| | _ -> | |
| let r = | |
| match queue with | |
| | h :: t -> t @ [h; h] | |
| | _ -> queue | |
| in | |
| doubling r (n - 1);; | |
| let () = | |
| let v = | |
| doubling q (pos - 1) | |
| in | |
| list_print v;; | |
| let () = | |
| Printf.printf "\n";; | |
| let () = | |
| let v = | |
| doubling q (pos - 1) | |
| in | |
| let head = | |
| match v with | |
| | h :: t -> h | |
| | [] -> ' ' | |
| in Printf.printf "#%d in queue: %c" pos head;; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment