Multiple cases with the same instructions in Haskell -


well code:

fct 1 b = a+b  fct 3 b = a+b fct 8 b = a+b fct x b = a-b  `for rest : 2,4,5,6,7,9..16` 

my question is, there way combine 3 first lines, same thing, "case x of" ? multiple values. appreciated

you can use guard syntax different matching functions:

fct' x b   | x `elem` [1, 3, 8] = + b   | otherwise = - b 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -