<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: There&#8217;s the nub (snippet in Perl and Haskell)</title>
	<atom:link href="http://greenokapi.net/blog/2009/01/27/theres-the-nub-snippet-in-perl-and-haskell/feed/" rel="self" type="application/rss+xml" />
	<link>http://greenokapi.net/blog/2009/01/27/theres-the-nub-snippet-in-perl-and-haskell/</link>
	<description>Perl, Haskell, stuff</description>
	<pubDate>Fri, 30 Jul 2010 18:16:16 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
		<item>
		<title>By: G. Wade Johnson</title>
		<link>http://greenokapi.net/blog/2009/01/27/theres-the-nub-snippet-in-perl-and-haskell/#comment-697</link>
		<dc:creator>G. Wade Johnson</dc:creator>
		<pubDate>Sat, 31 Jan 2009 23:42:17 +0000</pubDate>
		<guid isPermaLink="false">http://greenokapi.net/blog/?p=158#comment-697</guid>
		<description>A simpler change to fix the "/a" and "/aa" problem is to modify the regular expression in the longest method to

    /^\Q$last\E(?:\/&#124;$)/

That way it only matches a full directory name or the whole string.</description>
		<content:encoded><![CDATA[<br />
<b>Warning</b>:  preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: Unknown modifier '|' in <b>/var/www/blog/wp-content/plugins/text-control/text-control/markdown.php</b> on line <b>766</b><br />

]]></content:encoded>
	</item>
	<item>
		<title>By: More longest paths, and sick folds. - Just another lambdabananacamel,</title>
		<link>http://greenokapi.net/blog/2009/01/27/theres-the-nub-snippet-in-perl-and-haskell/#comment-689</link>
		<dc:creator>More longest paths, and sick folds. - Just another lambdabananacamel,</dc:creator>
		<pubDate>Fri, 30 Jan 2009 22:08:14 +0000</pubDate>
		<guid isPermaLink="false">http://greenokapi.net/blog/?p=158#comment-689</guid>
		<description>[...] paths, and sick folds.  31Jan2009  Filed under: Uncategorized Author: osfameron   This week's simple longest path exercise seems to have had more mileage in it than I expected. Thanks to everyone's comments and [...]</description>
		<content:encoded><![CDATA[<br />
<b>Warning</b>:  preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: Unknown modifier '|' in <b>/var/www/blog/wp-content/plugins/text-control/text-control/markdown.php</b> on line <b>766</b><br />

]]></content:encoded>
	</item>
	<item>
		<title>By: Jedai</title>
		<link>http://greenokapi.net/blog/2009/01/27/theres-the-nub-snippet-in-perl-and-haskell/#comment-685</link>
		<dc:creator>Jedai</dc:creator>
		<pubDate>Fri, 30 Jan 2009 17:47:15 +0000</pubDate>
		<guid isPermaLink="false">http://greenokapi.net/blog/?p=158#comment-685</guid>
		<description>Note that System.FilePath has convenient functions to explode and recompose a path, so you could write :

    longest6 :: [String] -&gt; [String]
    longest6 = map joinPath . uniqBy' isPrefixOf . sort . map splitDirectories</description>
		<content:encoded><![CDATA[<br />
<b>Warning</b>:  preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: Unknown modifier '|' in <b>/var/www/blog/wp-content/plugins/text-control/text-control/markdown.php</b> on line <b>766</b><br />

]]></content:encoded>
	</item>
	<item>
		<title>By: Anon</title>
		<link>http://greenokapi.net/blog/2009/01/27/theres-the-nub-snippet-in-perl-and-haskell/#comment-672</link>
		<dc:creator>Anon</dc:creator>
		<pubDate>Tue, 27 Jan 2009 21:01:28 +0000</pubDate>
		<guid isPermaLink="false">http://greenokapi.net/blog/?p=158#comment-672</guid>
		<description>### Ocaml:

    let longest l =
        let sl = List.sort String.compare l
        in 
        let isPrefixOf a b =
            try
                if ((String.compare a (String.sub b 0 (String.length a))) == 0) then true
            else false      
            with Invalid_argument e -&#62; false
        in 
        List.rev (List.fold_left (fun al b -&#62; 
            let a = List.hd al 
            in 
            if (isPrefixOf a b) then b::(List.tl al)
            else b::al
            ) [(List.hd sl)] sl)</description>
		<content:encoded><![CDATA[<br />
<b>Warning</b>:  preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: Unknown modifier '|' in <b>/var/www/blog/wp-content/plugins/text-control/text-control/markdown.php</b> on line <b>766</b><br />

]]></content:encoded>
	</item>
	<item>
		<title>By: x</title>
		<link>http://greenokapi.net/blog/2009/01/27/theres-the-nub-snippet-in-perl-and-haskell/#comment-669</link>
		<dc:creator>x</dc:creator>
		<pubDate>Tue, 27 Jan 2009 17:57:50 +0000</pubDate>
		<guid isPermaLink="false">http://greenokapi.net/blog/?p=158#comment-669</guid>
		<description>of course there is a bug here - run it on this testcase:
["/a", "/aa", "/aaa", "/aaaa"]</description>
		<content:encoded><![CDATA[<br />
<b>Warning</b>:  preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: Unknown modifier '|' in <b>/var/www/blog/wp-content/plugins/text-control/text-control/markdown.php</b> on line <b>766</b><br />

]]></content:encoded>
	</item>
	<item>
		<title>By: Will Boyce</title>
		<link>http://greenokapi.net/blog/2009/01/27/theres-the-nub-snippet-in-perl-and-haskell/#comment-666</link>
		<dc:creator>Will Boyce</dc:creator>
		<pubDate>Tue, 27 Jan 2009 12:44:30 +0000</pubDate>
		<guid isPermaLink="false">http://greenokapi.net/blog/?p=158#comment-666</guid>
		<description>### Python:

    l = ["/foo", "/qux/wibble", "/foo/bar/baz", "/qux", "/foo/bar"]
    l = sorted(l, reverse=True)
    r = []
    for p in l:
	if not any(re.startswith(p) for re in r):
		r.append(p)

### Erlang:

    start() -&gt;
        Paths = lists:reverse(lists:sort(["/foo", "/qux/wibble", "/foo/bar/baz", "/qux", "/foo/bar"])),
        Fun = fun(X, Acc) -&gt;
                case lists:any(fun(E) -&gt;
                        case string:str(E, X) of
                                0 -&gt; false;
                                _ -&gt; true
                        end end,
                Acc) of
                        false -&gt; lists:merge(Acc, [X]);
                        true -&gt; Acc
                end end,
        lists:foldl(Fun, [], Paths).</description>
		<content:encoded><![CDATA[<br />
<b>Warning</b>:  preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: Unknown modifier '|' in <b>/var/www/blog/wp-content/plugins/text-control/text-control/markdown.php</b> on line <b>766</b><br />

]]></content:encoded>
	</item>
	<item>
		<title>By: Programmer</title>
		<link>http://greenokapi.net/blog/2009/01/27/theres-the-nub-snippet-in-perl-and-haskell/#comment-665</link>
		<dc:creator>Programmer</dc:creator>
		<pubDate>Tue, 27 Jan 2009 08:58:12 +0000</pubDate>
		<guid isPermaLink="false">http://greenokapi.net/blog/?p=158#comment-665</guid>
		<description>"Penfold suggested splitting on "/" into a multilevel hash,"

Ugh, one of the absolute worst things with perl: nonsensical handling of nested data structures.  Every other modern language does this *vastly* better.

One of the many reasons Perl is obsolete.</description>
		<content:encoded><![CDATA[<br />
<b>Warning</b>:  preg_replace_callback() [<a href='function.preg-replace-callback'>function.preg-replace-callback</a>]: Unknown modifier '|' in <b>/var/www/blog/wp-content/plugins/text-control/text-control/markdown.php</b> on line <b>766</b><br />

]]></content:encoded>
	</item>
</channel>
</rss>
