perl Category

Schwartzian transform in Haskell

In: perl
In the last post, I mentioned that we might be able to improve the performance of our sort using a "http://en.wikipedia.org/wiki/Schwartzian_transform". This basically involves precaching the expensive calculation (in this case, length), sorting by the cached value, then taking just the original values. Let's test with a list of words: words "If on a winter's night a traveller" So instead of [...]

Monads in Perl (take 1)

In: perl
I've been away for a while from Haskell so I thought I should do some revision and really get my head around Monads. While I plodded through the wonderful "meet the monads" tutorial, I decided that the best way to learn would be to do. By implementing Monads in Perl. I'd highly recommend trying to implement [...]

"Readable Perl" talk slides up

In: perl
Thanks to Chris and Thom for organising the recent GeekUp Liverpool talks.  The evening started well with Martin Owen's very interesting talk on justifying Erlang, and why FP is going to become a major factor in tomorrow's concurrency-oriented world.  I demonstrated the wisdom of always saving a copy of your talk in PDF to a [...]

More Liverpool talks: Perl, Erlang

In: perl
Thom has posted the details of the next Liverpool geekup, Tuesday May 27th at 3345 Parr Street. Last time, I admitted to programming in Perl and got ribbed about it being unreadable.  Fueled by the fervour of the righteous (and maybe a pint or two of Cains bitter) I volunteered to do a talk on [...]

Perl snippet - repeated arrays

In: perl
On #moose, the channel for a popular modern dialect of Object Oriented Perl, Debolaz asked: <Debolaz> Is there a simple way to produce an array of array like [[1..4],[1..4]] without having to specify the [...]

Common roots

In: perl
This morning, Ranguard asked an interesting question on #london.pm: 11:27 <@ranguard> What's the best way of finding the common root of two paths, e.g. for /a/b/c/d/e, /a/b/c/1/2/3 I want /a/b/c/ returned, [...]

Haskell snippet - recursive average

In: perl
Greg confessed on #london.pm to having written a average function in Perl in FP style... recursively. I asked him about this, as a perfectly good average function (using List::Util would be: sub avg { sum(@_) / @_ } which is perfectly fine FP style too. As far as I could understand it, he was reducing [...]

Perl snippet for getPrefixMap

In: perl
Some interesting comments on yesterday's Haskell post.  I thought I'd write this in Perl to compare.  Of course, we don't have an "inits" function in the standard library, but that's easily written:#!/usr/bin/perluse strict; use warnings;use Data::Dumper;my %hash = ( "key1" => 1, "key2" => 2, [...]

Haskell 'words' and Perl 'split'

In: haskell, perl
Haskell's prelude has a function words that splits a string by spaces. Prelude> words "nice cup of tea" ["nice","cup","of","tea"] Apparently the question comes up quite regularly on irc or haskell-cafe as to why this function is specialised to split only on whitespace. Perl's split, for example, can split on any character, or indeed string or regular expression. As quicksilver [...]

The Red Black Moose

In: perl
For some time I've been wanting to implement the Enfilade, a really cool data structure discovered by the Xanadu people among others. It's like a balanced tree, except that it's indexed relatively rather than absolutely - making it ideal for things like text editor buffers, as you can insert and delete with impunity, knowing that the changes to the address [...]

About this blog

Osfameron's blog on Haskell, Perl programming, stuff.


Categories