praxis

Various programming exercises.
Log | Files | Refs

commit 2dca80dff754ec33b0b3476b693dad4dc8885a90
parent f20599606d97c531d260ce866980975d358cecb8
Author: Jared Tobin <jared@jtobin.ca>
Date:   Mon,  2 Jul 2018 11:22:17 +1200

-Wall.

Diffstat:
M20180629_length/Length.hs | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/20180629_length/Length.hs b/20180629_length/Length.hs @@ -1,3 +1,4 @@ +{-# OPTIONS_GHC -Wall -fno-warn-type-defaults #-} {-# LANGUAGE BangPatterns #-} {-# LANGUAGE LambdaCase #-} @@ -7,13 +8,13 @@ len :: [a] -> Int len = loop 0 where loop !acc = \case [] -> acc - (h:t) -> loop (succ acc) t + (_:t) -> loop (succ acc) t compare :: [a] -> [b] -> Ordering compare = loop where loop l r = case (l, r) of - (h : _, []) -> GT - ([], h : _) -> LT + (_ : _, []) -> GT + ([], _ : _) -> LT ([], []) -> EQ _ -> loop (drop 1 l) (drop 1 r)