[erlang-questions] Idiom for multiple case matches

mats cronqvist <>
Tue Nov 11 22:49:57 CET 2008


Kevin Scaldeferri <> writes:


>         Well, if you want to be pedantic, that's completely wrong.  There's  
>         nothing list-like about the collection of vowels.  It's a set.
>
>      i believe a list without duplicates is a set. no?
>
> Almost, but not exactly.

  i guess "almost" is a lot better than "completely wrong"...

>  But since your goal was to eschew obfuscation, why would you rely
> on the maintainer of the code noticing there are no duplicates, when
> instead you could express the constraint explicitly by using the
> proper data structure?

  i certainly think that using the set module is a lot better than the
  hardcoded function head match approach. and if the set was larger,
  it would be the only sensible solution.

  otoh, the literal "aeiou" is a perfectly fine representation of the
  set of "proper" vowels (as long as one ignores its orderedness).
  hardcoding it is comparable to hardcoding 3.14159 instead of using
  math:pi().

  as far as obfuscation goes; since text is traditionally represented
  as lists of small integers, it makes sense to express sets of
  characters that way too.

  mats



More information about the erlang-questions mailing list