DEV Community

loading...

Discussion on: Daily Challenge #43 - Boardgame Fight Resolver

Collapse
avalander profile image
Avalander

Look ma, pattern matching!

fightResolve :: String -> String -> String
fightResolve "Swordsman" "Archer"  = "Archer"
fightResolve "Pikeman" "Swordsman" = "Swordsman"
fightResolve "Cavalry" "Pikeman"   = "Pikeman"
fightResolve "Archer" "Cavalry"    = "Cavalry"
fightResolve attacker _            = attacker
Collapse
thepeoplesbourgeois profile image
Josh

Ahh, pattern matches. So elegance, much match ( *-*)