OCaml: Match expression inside another one?

Quick Solution You just need to add parentheses, or begin/end, around the inner match: Simplifications In your particular case there is no need for a nested match. You can just use bigger patterns. You can also eliminate the duplication in the nested rules using “|” (“or”) patterns: You can make it even more readable by replacing … Read more

Haskell pattern matching – what is it?

In a nutshell, patterns are like defining piecewise functions in math. You can specify different function bodies for different arguments using patterns. When you call a function, the appropriate body is chosen by comparing the actual arguments with the various argument patterns. Read A Gentle Introduction to Haskell for more information. Compare: with the equivalent Haskell: Note … Read more

tech