Code/paper from tonight's meeting.

27 views
Skip to first unread message

Chris Ball

unread,
Sep 16, 2009, 10:59:43 PM9/16/09
to boston...@googlegroups.com
Hi all,

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

Seth Gordon

unread,
Sep 17, 2009, 9:46:58 AM9/17/09
to boston...@googlegroups.com
Chris Ball wrote:
> And the version we came up with together tonight:
> http://chris.printf.net/card.hs

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)

R. Greayer

unread,
Sep 17, 2009, 11:58:01 AM9/17/09
to BostonHaskell
Not to beat it (further) to death, but a modest improvement to the
decode occurred to me:
Eliminate the Size data type, replace 'encodings' with a version based
on the (Prelude
defined) Ordering type, replace 'map3' with 'cmp3' (below), and thus
simplify
(and allow easy pointless representation) of decodeDelta (no zipping
or sorting
or lookup-ing). QuickCheck tells me it works...
------------------------------------------------------------------------------------------------------
encodings :: [(Ordering,Ordering,Ordering)]
encodings = [(LT,LT,GT),(LT,GT,GT),(GT,LT,GT),(LT,GT,LT),(GT,LT,LT),
(GT,GT,LT)]

cmp3 :: Ord a => (a,a,a) -> (Ordering,Ordering,Ordering)
cmp3 (a,b,c) = (compare a b, compare b c, compare c a)

decodeDelta :: (Card,Card,Card) -> Int
decodeDelta = (1+) . fromJust . flip elemIndex encodings . cmp3
------------------------------------------------------------------------------------------------------
Clearly, too much time on my hands!

R. Greayer

unread,
Sep 17, 2009, 12:15:03 PM9/17/09
to BostonHaskell
That'll teach me to let 2hrs go by between typing an email and hitting
'send'!

Ravi Nanavati

unread,
Sep 24, 2009, 8:40:24 AM9/24/09
to boston...@googlegroups.com
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.

Please feel free to reply to the list (or to me directly) with your feedback.

Thanks,

- Ravi

Nirav Dave

unread,
Sep 24, 2009, 9:37:38 PM9/24/09
to boston...@googlegroups.com
Ravi, I don't suppose this event was recorded for those of us too far to participate.

-Nirav

Edward Kmett

unread,
Sep 24, 2009, 9:52:55 PM9/24/09
to boston...@googlegroups.com
On Thu, Sep 24, 2009 at 8:40 AM, Ravi Nanavati <rav...@alum.mit.edu> wrote:

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.
 
I had a blast with the joint programming exercise. Although, as I spent most of the session as the interface between the group mind and the compiler, I suspect I had a different experience than most. The feedback I've received from talking to folks has been overall quite positive though.

-Edward

Joe Fredette

unread,
Sep 24, 2009, 10:07:12 PM9/24/09
to boston...@googlegroups.com
Man, it sounds like you guys had fun. Joint programming, parallel
parsers, group minds?
I want to be a BAHUG Borg!
Hopefully I'll be able to come out for the next one, any info on when
that will be?

Edward Kmett

unread,
Sep 24, 2009, 10:50:05 PM9/24/09
to boston...@googlegroups.com
On Thu, Sep 24, 2009 at 10:07 PM, Joe Fredette <jfre...@gmail.com> wrote:

Man, it sounds like you guys had fun. Joint programming, parallel
parsers, group minds?
I want to be a BAHUG Borg!

Resistance is futile. You will be assimilated -- as soon as you find transportation.

-Edward

Joe Fredette

unread,
Sep 24, 2009, 10:51:48 PM9/24/09
to boston...@googlegroups.com
We ah Borgs, now let's go to the Dunkie...

Mike Burns

unread,
Sep 25, 2009, 6:28:07 PM9/25/09
to boston...@googlegroups.com
On 2009-09-24 08.40.24 -0400, Ravi Nanavati wrote:
> As I mentioned in the meeting, I'd love to hear from people about how
> they think the joint programming exercise went.

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

Reply all
Reply to author
Forward
0 new messages