title: Scala — negation of a predicate
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/12681616/how-to-use-refer-to-the-negation-of-a-boolean-function-in-scala">How to use / refer to the negation of a boolean function in Scala?</a>  </p>
  </blockquote>
  
  
  
  <p>I'm currently taking Martin Odersky's Scala course in coursera. In one of the assignments, I need to work with the negation of a function (which represents a predicate).</p>
  
  <pre><code>def fun1 (p: Int =&gt; Boolean): Boolean = {
  /* some code here */
  }
  </code></pre>
  
  <p>Assume the function literal <code>p: Int =&gt; Boolean</code> represents some kind of a predicate like <code>x =&gt; x &gt; 0</code> </p>
  
  <pre><code>def fun2 (p: Int =&gt; Boolean): Boolean = {
  val x = fun1 (p)
  val y = ???
  /* How can I call the negation of the predicate 'p' here? */
  return x &amp;&amp; y
  }
  </code></pre>
  
  <p>For example, If I call <code>fun2</code> as <code>fun2 (x =&gt; x &gt; 0)</code></p>
  
  <p>I gave it a lot of thought, but I'm not making any progress with it. I'm not asking for the solution to any of the assignment problems (I'm sticking to the honor code, I believe), but any explanation of what I'm missing here will be of great help.</p>