News for hackers. Stuff that matters.
Re:If-then-else had to be invented by eat_veggies on Sunday December 13, 2020 @09:31AM (#25406771)
Is pattern matching a generalization of if/then/else, a reframing of it, or something else entirely?
Re:If-then-else had to be invented by colejohnson66 on Sunday December 13, 2020 @09:33AM (#25406794)
I see it as a cross between a switch and if statement. You’re saying based on what `x` is (a switch), do these things that a switch can’t do (an if).
Re:If-then-else had to be invented by alew1 on Sunday December 13, 2020 @01:03PM (#25408557)
If-then-else is pattern matching on a value of type Bool. I think of general pattern matching on algebraic data types as a generalization.