Here's the paper that describes the card trick from tonight:
http://www.apprendre-en-ligne.net/crypto/magie/card.pdf
And Mark Carroll's literate-Haskell program:
http://www.inference.phy.cam.ac.uk/cjb/CardTrick.lhs
And the version we came up with together tonight:
http://chris.printf.net/card.hs
Thanks to everyone for contributing, it was fun!
- Chris.
--
Chris Ball <c...@laptop.org>
One Laptop Per Child
It occurred to me after the meeting that instead of having a separate
"Size" data type, we could have done this:
> encodings :: [(Ordering, Ordering, Ordering)]
> encodings = [(LT, LT, LT), (LT, LT, GT), (GT, LT, LT),
> (LT, GT, LT), (GT, GT, LT), (GT, GT, GT)]
>
> decodeDelta :: (Card, Card, Card) -> Int
> decodeDelta abc@(a,b,c) = 1 + (fromJust $ elemIndex encoding encodings)
> where
> encoding = (a `compare` b, a `compare` c, b `compare` c)
As I mentioned in the meeting, I'd love to hear from people about how
they think the joint programming exercise went. In my opinion, I think
we wandered over a lot of interesting, practical ground and came up
with an unexpected solution to the problem, but since this was the
first time we tried this (and it was organized at the last minute) I'm
sure we could do better in the future, so I'd like to eagerly solicit
suggestions, comments and other feedback.
Man, it sounds like you guys had fun. Joint programming, parallel
parsers, group minds?
I want to be a BAHUG Borg!
Hearing a problem discussed and solved by Haskell programmers was immensely
useful. The "everyone makes mistakes" aspect of it was reassuring, and
seeing solutions from a Haskell point of view provided the right mindset.
My only gripe is that fewer "best practices" were used than discussions
would have me believe, and it's unclear whether this is just how things
really work or if it's because of the group. I felt like there was too much
pressure to solve the problem and not enough interest in exploring the
non-Haskell parts of Haskell (testing, program structure, optimizations,
etc).
But maybe it doesn't make sense to explore such nuances as a group. The
amount of re-writing we did was fantastic and lead to a very fun solution.
--
Mike Burns mi...@mike-burns.com http://mike-burns.com