Hi @bobbypriambodo.
Can’t say that there was a particular resource I drew on for this example, although as I mentioned I’m reading my way through realworldocaml.org. Also I try to make sure when programming to explore a problem by iterating over different implementations, particularly important I find when learning a new language.
For the second implementation I just tried using pattern matching combined with recursive iteration that I had previously been introduced to through that book, something that the OCmal makes extremely easy therefore attractive to do.
I may also be of interest is to say what I was trying to do with the first implementation. I what I was trying to do was compare a list of n items form a stream selected with Stream.npeek to a list of expected items showing where they diverge, so actually the Embarrassing implementation wasn’t even the first, just the first where I had abstracted out some of that functionality that I had found I needed, and generalised it so that it wasn’t taking some of the shortcuts that I was taking as I knew that one of my lists would never be zero length, and actually it was probably trying to implement the more general case that helped highlight that there was probably a much simpler solution to be found.
Another thing that I was also trying to do with the embarrassing example was look at how the standard library (or in this case I was using Core.Std) could be leveraged to tackle problems in a new way (for me) by stepping up the level of abstraction of the code. This was an approach that I had seen in a YouTube video on functional programming (which if I recall directly is actually introducing Haskell for C# programmers). Also I should say that I’m not sure that how that approach is used in that video is actually a benefit to the problem he is trying to solve, as he does quite a number of steps that decrease code verbosity at the cost of increased abstraction away from the original problem. Still I’m interested I what can be achieved, however, through this approach, but in this case I obviously didn’t have much success, mainly because there didn’t seem to be a function for zipping lists that would accommodate lists of different lengths without having to introduce a completely separate code path to handle those cases. I guess no one’s felt the need for that as - as it turns out - it’s pretty trivial to do with recursive pattern matching.