From 9dcf1e30f9f305810c8f887009b7fb41c30adff8 Mon Sep 17 00:00:00 2001 From: hasufell Date: Mon, 13 Oct 2014 22:30:57 +0200 Subject: [PATCH] PRELUDE: add if' function to simplify if-then-else --- MyPrelude.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MyPrelude.hs b/MyPrelude.hs index d4b0bf2..a3a1326 100644 --- a/MyPrelude.hs +++ b/MyPrelude.hs @@ -72,3 +72,9 @@ seqList = tail. inits dupLast :: [a] -> [a] dupLast [] = [] dupLast xs = xs ++ [last xs] + + +-- |Simpler version of if-then-else. +if' :: Bool -> a -> a -> a +if' True x _ = x +if' False _ y = y