> How does “pattern matching in langauges like Haskell and OCaml” differ from Perl-style regular expressions?

It's an unfortunate doubling of terminology.

In Haskell you are free to "redefine“ a functions body multiple times for different argument "constellations"

Those args have to "match a pattern", not (necessarily) a regular expressions!

IIRC does Perl 6 have something very similar just named differently... ehm ...

Multi-subs ? ? ?

Cheers Rolf

PS: Je suis Charlie!

update

yes it's called multi-subs in Perl 6, but from the examples I saw so far, I'd say that Haskell is more powerful.

update

see also http://en.wikibooks.org/wiki/Haskell/Pattern_matching

Note

Pattern matching on what?

Some languages like Perl and Python use the term pattern matching for matching regular expressions against strings. The pattern matching we refer to in Haskell is something completely different. In fact, you're probably best off forgetting what you know about pattern matching for now


In reply to Re^2: rough approximation to pattern matching using local (Multi Subs) by LanX
in thread rough approximation to pattern matching using local by gregory-nisbet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.