Skip to content

Commit

Permalink
Remove use of head and tail.
Browse files Browse the repository at this point in the history
  • Loading branch information
chungyc committed Jun 2, 2024
1 parent bb9a7c7 commit c3245ef
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions test/Problems/P09Spec.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{-# OPTIONS_GHC -Wno-x-partial -Wno-unrecognised-warning-flags #-}

{-|
Copyright: Copyright (C) 2023 Yoo Chung
License: GPL-3.0-or-later
Expand All @@ -22,11 +20,13 @@ properties pack name = describe name $ do
pack xs `shouldSatisfy` all (\l -> and [ x == y | x <- l, y <- l])

prop "identical elements do not span consecutive sublists" $
\xs (Positive k) x ys ->
null xs || last xs /= x ==>
null ys || head ys /= x ==>
pack (xs ++ replicate k x ++ ys)
`shouldBe` pack xs ++ [replicate k x] ++ pack ys
\xs x z y ys (Positive k) ->
x /= z && z /= y ==>
let xs' = xs ++ [x]
ys' = [y] ++ ys
vs = xs' ++ replicate k z ++ ys'
in counterexample (show vs) $
pack vs `shouldBe` pack xs' ++ [replicate k z] ++ pack ys'

examples :: Spec
examples = describe "Examples" $ do
Expand Down

0 comments on commit c3245ef

Please sign in to comment.