4 ms·
gun `shoot` foot But there’s a side effect, so it doesn’t work. Try to use the state monad… get confused, so you write your own shooting monad, and then come up
by joejohnson 13y ago
gun `shoot` foot
But there’s a side effect, so it doesn’t work. Try to use the state monad… get confused, so you write your own shooting monad, and then come up with this code:
gun >= id foot
but this puts your gun in your foot. Then you write your data types
data Space = Empty | Gun| Foot deriving (Show, Eq, Ord)
–if you’re right-handed, this code should work
shootFoot = foldr (shoot bullet) Empty $ enumFromTo Gun Foot
–For southpaws
foldl’ (shoot bullet) Empty $ enumFromTo gun foot