the badger, the mushroom, the snake and the haskell

marți, 22 dec. 2009, 22:10

How they all fit together:

1
2
3
4
5
6
7
8
module Badger where
 
badger :: Int -> Int -> [String]
badger mushroom snake = badger' mushroom snake mushroom snake
    where
    badger' m s 0 s' = "Mushroom" : "Mushroom" : badger' m s m s'
    badger' m s m' 0 = "Snaaaaaaaaake" : badger' m s m s
    badger' m s m' s' = "Badger" : badger' m s (m' - 1) (s' - 1)

A Haskell 8-liner based on this short made by Weebl.