mirror of
https://github.com/iritmaximus/haskell.git
synced 2026-10-12 19:13:39 +03:00
@@ -5,8 +5,8 @@ import Data.Char
|
|||||||
import Data.List
|
import Data.List
|
||||||
|
|
||||||
rev :: [a] -> [a]
|
rev :: [a] -> [a]
|
||||||
rev [] = []
|
rev (x:y:xs) = y:x:xs
|
||||||
rev (x:xs) = xs ++ [x]
|
rev xs = xs
|
||||||
|
|
||||||
propRevSmall :: Property
|
propRevSmall :: Property
|
||||||
propRevSmall = rev [1,2] === [2,1]
|
propRevSmall = rev [1,2] === [2,1]
|
||||||
|
|||||||
+2
-2
@@ -6329,8 +6329,8 @@ the file <a
|
|||||||
href="https://github.com/moocfi/haskell-mooc/blob/master/exercises/Examples/QuickCheck.hs"><code>exercises/Examples/QuickCheck.hs</code></a>.</p>
|
href="https://github.com/moocfi/haskell-mooc/blob/master/exercises/Examples/QuickCheck.hs"><code>exercises/Examples/QuickCheck.hs</code></a>.</p>
|
||||||
<div class="sourceCode" id="cb395"><pre
|
<div class="sourceCode" id="cb395"><pre
|
||||||
class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb395-1"><a href="#cb395-1" aria-hidden="true" tabindex="-1"></a><span class="ot">rev ::</span> [a] <span class="ot">-></span> [a]</span>
|
class="sourceCode haskell"><code class="sourceCode haskell"><span id="cb395-1"><a href="#cb395-1" aria-hidden="true" tabindex="-1"></a><span class="ot">rev ::</span> [a] <span class="ot">-></span> [a]</span>
|
||||||
<span id="cb395-2"><a href="#cb395-2" aria-hidden="true" tabindex="-1"></a>rev [] <span class="ot">=</span> []</span>
|
<span id="cb395-2"><a href="#cb395-2" aria-hidden="true" tabindex="-1"></a>rev (x<span class="op">:</span>y<span class="op">:</span>xs) <span class="ot">=</span> y<span class="op">:</span>x<span class="op">:</span>xs</span>
|
||||||
<span id="cb395-3"><a href="#cb395-3" aria-hidden="true" tabindex="-1"></a>rev (x<span class="op">:</span>xs) <span class="ot">=</span> xs <span class="op">++</span> [x]</span></code></pre></div>
|
<span id="cb395-3"><a href="#cb395-3" aria-hidden="true" tabindex="-1"></a>rev xs <span class="ot">=</span> xs</span></code></pre></div>
|
||||||
<p>We can write an individual test case using the <code>===</code>
|
<p>We can write an individual test case using the <code>===</code>
|
||||||
operator from QuickCheck:</p>
|
operator from QuickCheck:</p>
|
||||||
<div class="sourceCode" id="cb396"><pre
|
<div class="sourceCode" id="cb396"><pre
|
||||||
|
|||||||
Reference in New Issue
Block a user