mrluka / software-testing-2013 Goto Github PK
View Code? Open in Web Editor NEWSoftware Testing UVA 2013 Group Christian König & Luka Hale
Software Testing UVA 2013 Group Christian König & Luka Hale
Task 3
merge :: (Ord a) => [a] -> [a] -> [a] -- The merge function is a highly-specialized function that merges two infinite, sorted lists
merge xs@(x:xt) ys@(y:yt) =
case compare x y of
LT -> x : (merge xt ys)
EQ -> x : (merge xt yt)
GT -> y : (merge xs yt)
diff :: (Ord a) => [a] -> [a] -> [a] -- diff, in short, removes all of the elements of the second list passed to it from the first.
diff xs@(x:xt) ys@(y:yt) =
case compare x y of
LT -> x : (diff xt ys)
EQ -> diff xt yt
GT -> diff xs yt
composites :: [Integer]
composites = foldr1 f $ map g $ tail primes
where
f (x:xt) ys = x : (merge xt ys)
g p = [ n * p | n <- [p, p + 2 ..]]
The function composites is not correct.
See
*Week6> take 10 composites
[9,15,21,25,27,33,35,39,45,49]
Where are the multiples of 2?
What are the values of the function parameters in the following fragment?
Task 6
Use the list from the previous exercise to test the Miller-Rabin primality check.
The Miller-Rabin test returns 172947529 as prime, but it is a Carmichael pseudo prime.
To get results with a higher chance to be right, the test should be executed multiple times but with different (random) parameters.
This was tested with the function checkMillerRabin. It showed that the results are more precise by repeating the test with different random values.
(This was tested by modifying the functions parameters, not auto-test present yet).
Opg3
testIntersectionA1 :: Ord a => Set a -> Set a -> Bool
testIntersectionA1 x y = testIntersectionA2 x y (intersection x y)
testIntersectionA2 :: Ord a => Set a -> Set a -> Set a -> Bool
testIntersectionA2 (Set []) y z = True
testIntersectionA2 (Set (x:xs)) y z = inSet x y == inSet x z
&& testIntersectionA2 (Set xs) y z
Better not using the internal representation of the abstract data type Set
( intersection x y ).
Opg4
trClos ::Ord a => Rel a -> Rel a
trClos rel = do trans1 <- return (nub (rel ++ (rel @@ rel)))
if length trans1 == length rel
then rel
else trClos trans1
I don't understand the return here. There is no monad involved here. Further OK.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.