Would you (or someone else) be willing to explain the Haskell code to me or P5ers who don't know Haskell?

With license:

=== haskell === --data type Tree is --either -- a Leaf containing a single item (of type a) -- or -- a Node containing two subtrees (that can have leaves of type a) data Tree a = Leaf a | Node (Tree a) (Tree a) -- and it inherits 'methods' / 'roles' from types Show and Eq, deriving (Show, Eq) -- Fringe is a function that extracts a list of type a from a tree con +taining type a fringe :: Tree a -> [a] -- If its argument is of type leaf -- it returns a single element list containing the element held in the + leaf fringe (Leaf x) = [x] -- If its argument is a Node -- it returns the list returned by the left subtree -- concatenated to the list returned by the right subtree fringe (Node n1 n2) = fringe n1 ++ fringe n2 -- sameFringe takes two Trees as its arguments -- and uses the == method inherited/included from the Eq role -- to compare the lists returned from the two trees for equality -- returning true if they are the same. sameFringe :: (Eq a) => Tree a -> Tree a -> Bool sameFringe t1 t2 = fringe t1 == fringe t2

Personally, I find the Perl6 far easier to read. I'd be very happy to use Perl6 if it had threading and ran at perl5 speed.

In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re: Haskell vs Perl 6 (was Re: Capturing parenthesis and grouping square brackets) by BrowserUk
in thread Capturing parenthesis and grouping square brackets by Eily

and:  <code> code here </code>

  • Please read these before you post! —
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;