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

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -