undefined
プログラムをコンパイルしてテストするために何かを記入することになっています。ここで symdiff が何をすることになっているのかよくわからないので、 に何を入力すればよいかわかりませんundefined
。誰かが私に何を挿入できるか、ヒントを教えてもらえますかundefined
?
ところで、コードを ghci 7.6.3 でコンパイルしようとすると、エラーが発生します。
Could not find module 'Test.SmallCheck.Series'
どうすれば修正できますか?
コードは次のとおりです。
{-# language FlexibleInstances #-}
{-# language MultiParamTypeClasses #-}
{-# language NoMonomorphismRestriction #-}
module Blueprint where
import Test.SmallCheck
import Test.SmallCheck.Series
data N = Z | S N deriving (Show , Eq)
symdiff :: N -> N -> N
symdiff x y = undefined
-- for testing in ghci: smallCheck 10 spec1
spec1 = \ (x,y) -> symdiff x y == symdiff y x
spec2 = \ (x,y) -> symdiff x (plus x y) == y
plus :: N -> N -> N
plus x y = case x of
Z -> y
S x' -> S (plus x' y)
test :: Bool
test = and
[ null $ failures 10 1000 $ spec1
, null $ failures 10 1000 $ spec2
]
instance Monad m => Serial m N where series = cons0 Z \/ cons1 S
-- | first f failures from t testcases for property p
failures f t p = take f
$ filter ( \ x -> not $ p x )
$ take t
$ do d <- [ 0 .. ] ; list d series
ありがとう、それはとても役に立ちました!これはどうですか:
symdiff :: N -> N -> N
symdiff x y = case x of
Z -> y
S x' -> case y of
Z -> x
S y' -> ???
これらの行は正しいですか(???の行を除いて、私はすでに考えています)
これは最後の行で機能します。
S y' -> symdiff x' y'