It's all about mastering inductive reasoning.
someFunc n = if n == 0 then -- do something when n IS zero (base case) else -- do something where n is (by inductive reasoning) NOT zero
Or
someFunc list = if List.isEmpty list then -- handle the empty list (base case) else -- the list (by inductive reasoning) has at least one element
Pattern matching streamlines this for us by allowing us to express the base case and any induction steps using a nice syntax
someFunc n = case n of 0 -> -- base case _ -> -- induction step
someFunc list = case list of [] -> -- base case first :: more -> -- induction step
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
It's all about mastering inductive reasoning.
Or
Pattern matching streamlines this for us by allowing us to express the base case and any induction steps using a nice syntax
Or