dimanche 19 février 2017

How can I check if character belongs to a group of symbols in Haskell?

The task is to count all the punctuation signs in a string. How can I check if character belongs to this group ".,!?;:". I'm doing it this way

signs' curSgn ('.':list) = (signs' (curSgn + 1) list)
signs' curSgn (',':list) = (signs' (curSgn + 1) list)
signs' curSgn ('?':list) = (signs' (curSgn + 1) list)
signs' curSgn ('!':list) = (signs' (curSgn + 1) list)
signs' curSgn (':':list) = (signs' (curSgn + 1) list)
signs' curSgn (';':list) = (signs' (curSgn + 1) list)

But is there a way to do it in one line of code?

Aucun commentaire:

Enregistrer un commentaire