Sha256: 7dbc506745c351e08d336bf1b536345bf186ac7c7166acae43b34ccb8ea5b0ee

Contents?: true

Size: 716 Bytes

Versions: 312

Compression:

Stored size: 716 Bytes

Contents

module SecretHandshake (handshake) where

import Data.Bits (testBit)

data Action = Wink
            | DoubleBlink
            | CloseYourEyes
            | Jump
            | Reverse
            deriving (Show, Eq, Enum, Bounded)

handshake :: Int -> [String]
handshake = foldr f [] . toActions
  where f Reverse acc = reverse acc
        f action acc = toString action:acc
        toString action = case action of
          Wink          -> "wink"
          DoubleBlink   -> "double blink"
          CloseYourEyes -> "close your eyes"
          Jump          -> "jump"
          Reverse       -> undefined

toActions :: Int -> [Action]
toActions n = [act | act <- Reverse:[Wink .. Jump], n `testBit` fromEnum act]

Version data entries

312 entries across 312 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.179 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.178 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.177 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.176 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.175 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.174 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.173 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.172 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.171 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.170 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.169 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.167 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.166 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.165 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.164 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.163 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.162 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.161 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs
trackler-2.2.1.160 tracks/haskell/exercises/secret-handshake/examples/success-standard/src/SecretHandshake.hs