Skip to content
Advertisement

Tag: structural-pattern-matching

Structural pattern matching and infinity

I am computing the Lp distance functions for non-negative p’s. For all but p = 0 and p = ∞ a built-in pow() function serves well. Before I learned about a structural pattern matching, I had used a dictionary and exception handling: Some people didn’t want exceptions here. So I rewrote the snippet into the following one: Why case inf:

Advertisement