Tuesday, 15 May 2012

functional programming - How to use 'oneof' in quickCheck (Haskell) -


I am trying to write a support that changes Sudoku and then checks that it is still valid.

However, I'm not sure how to use the "one" - function. Can you give me some hint, please?

  prop_candidates :: Sudoku - & gt; Child Prospects Su = Sudoku New SU & amp; IsOkay newSu where newSu = update su aBlank aCandidate aCandidate = oneof [return x | X & lt; - Candidates su aBank] aBlank = oneof [return x | X & lt;  

Here's more information ...

 Type  POS = (Int, Int) Update: Sudoku - & Gt; Status - & gt; Maybe int -> Sudoku Spaces :: Sudoku - & gt; [POS] Candidate :: Sudoku - & gt; Status - & gt; [IT] [return x | X & LT; - (empty example)] :: (Monad M) => [M POS]  

I have a core with this support for 3 hours, so any idea is welcome!

What I was running is that you have a type of mixture i.e., aBlank is not a POS , but there is a gene poos , so update a blank aCandidate does not make any sense! In fact, what you want is a way to make an early Sudoku a new Sudoku; In other words, a function

  similarly Sudoku :: Sudoku -> General Sudoku  

Now we can write it:

  Similar Sudoku su = a bulk & lt; - element (emptyness) - simple than one [back x |  

Or even simple:

  Similar sudoku    
< P> and looks like property

  prop_similar:: sudoku - & gt; Gen Bool prop_similar su = do newSu & lt; - Sasadudoki Suvata (Sudoku Nsu & amp; Ike Oi Nsu)  

Due to the example

  Testable Bull Testable Prop = & gt; Testable (General prop) (arbitrary A, show, testable prop) = & gt; Testable (a -> Sahara)  

Sudoku -> General Bull is testable as well (to handle example unchecked sudoku ).


No comments:

Post a Comment