title: Writing a Between Numbers Function in Haskell
body: <p>I'm currently working through The Craft of Functional Programming 2nd Edition and I have been presented with a task to write a between function which has stumped me.</p>
  
  <p>The function takes three numbers as arguments and returns a boolean result i.e.</p>
  
  <pre><code>between :: Int -&gt; Int -&gt; Int -&gt; Bool
  </code></pre>
  
  <p>It is defined so that between m n p is true if n is between n and p. For the sake of simplicity given between 2 2 2, the function would return true, also between 3 3 5 would return true.</p>
  
  <p>Mathematically, x&lt;=y and y&lt;=z</p>
  
  <p>The question also recommended that I could write a weakAscendingOrder function which checks that the number sequence doesn't go down at any point. I have written this function and my code is shown below:</p>
  
  <pre><code>weakAscendingOrder :: Int -&gt; Int -&gt; Int -&gt; Bool
  weakAscendingOrder x y z = (x &lt;= y) &amp;&amp; (y &lt;= z)
  </code></pre>
  
  <p>How can I write a between function, either with or without using weakAscendingOrder, while preserving the function signatures since they have been provided by the book?</p>