Using guards in let .. in expressions

后端 未结 2 2140
[愿得一人]
[愿得一人] 2021-02-18 15:35

Sometimes I write code like this

solveLogic :: Int -> Int -> Int
solveLogic a b =
    let 
        x = 1
        brainiac
            | a >= x     = 1
          


        
2条回答
  •  北海茫月
    2021-02-18 16:27

    When I want guards as an expression I use this somewhat ugly hack

    case () of
    _ | a >= x     -> 1
      | a == b     -> 333
      | otherwise  -> 5
    

提交回复
热议问题