title: Getting the median of 3 values using scheme's
body: <p>The problem this time is to get the median of three values (easy)</p>
  
  <p>I did this:</p>
  
  <pre><code>(define (med x y z) (car(cdr(x y z)))
  </code></pre>
  
  <p>and it was accepted but when testing it:</p>
  
  <pre><code>(med 3 4 5)
  </code></pre>
  
  <p>I get this error:</p>
  
  <blockquote>
    <p>Error: attempt to call a non-procedure<br>
           (2 3 4)</p>
  </blockquote>
  
  <p>And when entering letters instead of number i get:</p>
  
  <pre><code>(md x y z)
  </code></pre>
  
  <blockquote>
    <p>Error: undefined varia<br>
              y<br>
              (package user)</p>
  </blockquote>
  
  <p>Using something besides x y z I get:</p>
  
  <pre><code>(md d l m)
  </code></pre>
  
  <blockquote>
    <p>Error: undefined variable<br>
              d<br>
              (package user)</p>
  </blockquote>
  
  <p>the question was deleted dont know how anyway</p>
  
  <p><strong><em>write a function that return the median of 3 values</em></strong></p>
  
  <p>Sorry for editing the question I got that I should put the values in order first not just a sill car and cdr thing so I did so</p>
  
  <pre><code>33&gt; (define (med x y z)
     (if(and(
  
        (&lt;x y) (&lt;y z) y
  
                 if(and(
  
                      (&lt;y x) (&lt;x z) x z)))))
  
  Warning: invalid expression
           (if (and&lt; (&lt;x y) (&lt;y z) y if (and ((&lt;y x) (&lt;x z) x z))))
  </code></pre>
  
  <p>but as u see Im getting a warning so what is wronge ? </p>