Quantcast
Channel: Does haskell have a conditional operator such as "x == y ? a : b" in C++ or ifelse(x==y, a, b) in R? - Stack Overflow
Browsing latest articles
Browse All 4 View Live

Answer by leftaroundabout for Does haskell have a conditional operator such...

Apart from if or Data.Bool.bool, which do indeed just what you want, you can also define such an operator yourself in Haskell!infixr 1 ?(?) :: Bool -> a -> a -> a(True ? a) _ = a(False ? _) b...

View Article



Answer by Lee for Does haskell have a conditional operator such as "x == y ?...

There is the bool function in Data.Bool:import Data.Boolbool b a (x == y)

View Article

Answer by madjar for Does haskell have a conditional operator such as "x == y...

Haskell's if performs exactly as you want.if x == y then a else bAs Lee mentioned, there is a bool function in Data.Bool that does the same thing. Also, thanks to Haskell's lazyness, bool...

View Article

Does haskell have a conditional operator such as "x == y ? a : b" in C++ or...

Does haskell have a conditional operator that performs asx == y ? a : bin C++ orifelse(x==y, a, b)in R ?

View Article
Browsing latest articles
Browse All 4 View Live




Latest Images