Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

If that, then yes, of course. But does that hold?

For the Grimes dice, unless I've made an error, it would seem not. I get `(Sum {getSum = 1416},Sum {getSum = 2160},Sum {getSum = 2160},Sum {getSum = 1440},Sum {getSum = 600})` from the following program:

    {-# LANGUAGE LambdaCase #-}
    
    import Data.Monoid
    
    oneIf x = Sum $ if x then 1 else 0
    
    toRed = \case
          1 -> 4
          2 -> 4
          3 -> 4
          4 -> 4
          5 -> 4
          6 -> 9
    
    toYellow = \case
          1 -> 3
          2 -> 3
          3 -> 3
          4 -> 3
          5 -> 8
          6 -> 8
    
    toBlue = \case
          1 -> 2
          2 -> 2
          3 -> 2
          4 -> 7
          5 -> 7
          6 -> 7
    
    toMagenta = \case
          1 -> 1
          2 -> 1
          3 -> 6
          4 -> 6
          5 -> 6
          6 -> 6
    
    toOlive = \case
          1 -> 0
          2 -> 5
          3 -> 5
          4 -> 5
          5 -> 5
          6 -> 5
    
    main = print $ mconcat $ do
        red <- toRed <$> [1..6]
        yellow <- toYellow <$> [1..6]
        blue <- toBlue <$> [1..6]
        magenta <- toMagenta <$> [1..6]
        olive <- toOlive <$> [1..6]
    
        let first = maximum [red, yellow, blue, magenta, olive]
    
        [ ( oneIf $ first == red
          , oneIf $ first == yellow
          , oneIf $ first == blue
          , oneIf $ first == magenta
          , oneIf $ first == olive
          ) ]


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: