title: Scheme - How do I use a function in 'map/filter' if it has multiple arguments?
body: <p>I have been trying to create a subset?,member? and intersection function by using the predefined filter function and some variations of the map function (ormap, andmap).</p>
  
  <p>The "member?" function is supposed to check if a element is a member of a list:</p>
  
  <pre><code>(define member?
   (lambda (e s)
    (ormap (curry same-elem? e) s)))
  </code></pre>
  
  <p>It is using a function called "same-elem?" that looks like this:</p>
  
  <pre><code>(define same-elem?
   (lambda (e1 e2)
    (cond ((and (set? e1) (set? e2)) (same-set? e1 e2))
          ((and (number? e1) (number? e2)) (= e1 e2))
          (else (equal? e1 e2)))))
  </code></pre>
  
  <p>The "subset?" checks if the elements in one set are part of another set:</p>
  
  <pre><code>(define subset?
   (lambda (s2 s1)
    (andmap (curry member? s2) s1)))
  </code></pre>
  
  <p>The 'intersection' function is supposed to return the intersection of two sets:</p>
  
  <pre><code>(define intersection
   (lambda (s2 s1)
    (filter (curry member? s2) s1)))
  </code></pre>
  
  <p>The reason I am using the 'curry' function is because I tried to follow the solution in this stackoverflow thread:<a href="https://stackoverflow.com/questions/32728131/scheme-racket-filter-map-multiple-arguments">Scheme/Racket filter/map multiple arguments</a> in an attempt to pass a second argument into my called function. It doesn't work though.</p>
  
  <p>Whenever I call any of these functions it outputs an error that says it expected a list in my ormap call in my member? function but got an element. The weird part is that my member? function worked fine until like a couple of minutes ago... I haven't even touched anything!</p>
  
  <p>I am kind of a newbie in programming and I am completely new to Scheme. I know how to use a map/filter function if the called function in map/filter only has one argument... but how do I handle this if I have multiple arguments? Please help.</p>
  
  <p>EDIT: The solution I picked below DOESN'T work with curry. It does work however if you remove the curry function and write a anonymous function instead.</p>
  
  <p>Like this:</p>
  
  <pre><code>(define member?
   (lambda (e s)
    (ormap (lambda (x)
             (same-elem? e x)) s)))
  </code></pre>