X-Git-Url: https://git.stderr.nl/gitweb?a=blobdiff_plain;ds=sidebyside;f=c%CE%BBash.lhs;h=9ec58f1248b54babada9374f6ba49bab47062829;hb=d2b5f23b4cb1f6c78b43a5dbfd785b10901bb6b6;hp=16608ab610ef2455d2a8172cb8f0889b4b8e09d4;hpb=09a5bf4c0b4a912d47a4ca83bd112ef6e7e5581a;p=matthijs%2Fmaster-project%2Fdsd-paper.git diff --git "a/c\316\273ash.lhs" "b/c\316\273ash.lhs" index 16608ab..9ec58f1 100644 --- "a/c\316\273ash.lhs" +++ "b/c\316\273ash.lhs" @@ -370,6 +370,7 @@ \usepackage{paralist} %include polycode.fmt +%include clash.fmt \begin{document} % @@ -540,27 +541,24 @@ mac a b c = add (mul a b) c expression, one using only case expressions and one using pattern matching and guards. -\begin{verbatim} -sumif pred a b = if pred == Eq && a == b || pred == Neq && a != b - then a + b - else 0 -\end{verbatim} +\begin{code} +sumif pred a b = + if pred == Eq && a == b || pred == Neq && a != b + then a + b + else 0 -\begin{verbatim} sumif pred a b = case pred of - Eq -> case a == b of - True -> a + b - False -> 0 - Neq -> case a != b of - True -> a + b - False -> 0 -\end{verbatim} - -\begin{verbatim} -sumif Eq a b | a == b = a + b -sumif Neq a b | a != b = a + b -sumif _ _ _ = 0 -\end{verbatim} + Eq -> case a == b of + True -> a + b + False -> 0 + Neq -> case a != b of + True -> a + b + False -> 0 + +sumif Eq a b | a == b = a + b +sumif Neq a b | a != b = a + b +sumif _ _ _ = 0 +\end{code} TODO: Pretty picture