Posts tagged “haskell”

Coin Tricks

Derren Brown recently claimed he would predict the UK lottery numbers, live on television, and then explain how he did it. It’s doubtful that he did either — the alternative explanation that he’d actually committed a massive and improbably daring fraud is vastly more likely than the bullshit he spun out, as it’s actually possible… […]

Is currying monadic?

Here’s a question that came up while I’ve been trying to implement currying in Perl: is Currying monadic? I’ve tried a couple of times, but not managed to explain what I mean very well on #haskell, so let’s see if a longer writeup explains it better. My simplistic understanding of monads is that they take […]

Currying in Perl

“Currying” is a simple idea that is surprisingly powerful on the one hand, and which was surprisingly hard (at least for me) to get my head around – possibly because the concept didn’t exist natively in the languages I learnt first. When you declare a function in currying style, each argument is taken one at […]

(rough) Grids in Haskell

(This isn’t a full blog post, but a note of a few things about implementing game grids in Haskell). A [[Cell]] structure seems to make sense for a lot of boards. In fact, even the problems I’m looking at might be approached simply indexing into row then col each time you want to access a […]

More longest paths, and sick folds.

This week’s simple longest path exercise seems to have had more mileage in it than I expected. Thanks to everyone’s comments and suggestions, I’ve updated with a number of times with, among other things, an improved Haskell version that acts on path elements instead of just characters. But I had intended to do a version […]

There’s the nub (snippet in Perl and Haskell)

Here’s a simple problem, with solutions in Perl and Haskell. @joel: suppose I have a list of strings (they happen to be paths) – how might I find only the longest instance of each path? @joel: that is give /foo /foo/bar /foo/bar/baz /qux I only want back /foo/bar/baz and /qux @joel: do I need to […]

Crossword puzzles in Haskell

Every year or so I come back to the problem of writing a crossword puzzle compiler/player. I think Javascript would be the most promising for a web-based player, though I’ve given it a go in Java and Perl too. Modeling the problem is interesting in an Object Oriented language – I would find myself getting […]

Countdown words game solver in Haskell

Will on #geekup has been working on a Countdown letters and numbers game solver written in Python. I thought it'd be fun to try to do it in Haskell, and started with the letters game (anagram) solver. Starting with a string of jumbled letters, the goal is to make the longest possible anagram. I remember […]

Monads in Perl (take 1)

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 […]

Haskell 'words' and Perl 'split'

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 […]