From c5a839b3093b78f4e1c1b8fae5acd3b404f8b8fb Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 26 Mar 2014 11:15:04 -0700 Subject: [PATCH] 3/4/5-tuple accessors --- hledger-lib/Hledger/Utils.hs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hledger-lib/Hledger/Utils.hs b/hledger-lib/Hledger/Utils.hs index 96b18e818..442b12bdd 100644 --- a/hledger-lib/Hledger/Utils.hs +++ b/hledger-lib/Hledger/Utils.hs @@ -215,6 +215,23 @@ fitto w h s = intercalate "\n" $ take h $ rows ++ repeat blankline fit w = take w . (++ repeat ' ') blankline = replicate w ' ' +-- tuples + +first3 (x,_,_) = x +second3 (_,x,_) = x +third3 (_,_,x) = x + +first4 (x,_,_,_) = x +second4 (_,x,_,_) = x +third4 (_,_,x,_) = x +fourth4 (_,_,_,x) = x + +first5 (x,_,_,_,_) = x +second5 (_,x,_,_,_) = x +third5 (_,_,x,_,_) = x +fourth5 (_,_,_,x,_) = x +fifth5 (_,_,_,_,x) = x + -- math difforzero :: (Num a, Ord a) => a -> a -> a