Created
December 20, 2018 14:49
-
-
Save lissahyacinth/fca966d8302af3206ef8c05a55019f11 to your computer and use it in GitHub Desktop.
This file contains 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 reducable a b = | |
{code for aA reducing to nothing etc} | |
let rec solve a x = | |
if a.length = 0 | |
then match x with | |
# a :: b indicates that x is being split into a - the head and b - the tail of the list. | |
# [] indicates an empty element | |
elem :: list_of_elems -> (solve elem list_of_elems) | |
# If there's nothing left in the list, just return the element. | |
| elem :: [] -> elem | |
else | |
match x with | |
elem :: list_of_elems -> ( | |
match reducable a elem with | |
# There's no reduction, leave a in the list and work on the rest | |
(a, b) -> (a :: (solve b list_of_elems)) | |
# There's a reduction to 0, so just let the upper function deal with it | |
| (a when a.length = 0 ) -> (solve '' x) | |
| elem :: None -> elem | |
# This is the end of the list, so only return the element we were using for comparison | |
| [] -> a | |
solve '' x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment