Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6318943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T15:43:03+00:00 2026-05-24T15:43:03+00:00

The code in question is this: (define multirember&co (lambda (a lat col) (cond ((null?

  • 0

The code in question is this:

(define multirember&co
  (lambda (a lat col)
    (cond
     ((null? lat)
      (col (quote ()) (quote ())))
     ((eq? (car lat) a)
      (multirember&co a
                      (cdr lat)
                      (lambda (newlat seen)
                        (col newlat
                             (cons (car lat) seen)))))
     (else
      (multirember&co a
                      (cdr lat)
                      (lambda (newlat seen)
                        (col (cons (car lat) newlat)
                             seen))))))

I’ve stared at this all day but I can’t quite seem to understand it. When you recur on the function you are re-defining col but in the examples they seem to use the original definition. Why wouldn’t it change. How can you recur on it without passing in the parameters newlat and seen.

It’s hard to explain my question because I seem to just be missing a piece. If perhaps someone could give a more explicit walk-through than the book I may be able to understand how it works.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T15:43:04+00:00Added an answer on May 24, 2026 at 3:43 pm

    Let’s step through an example; maybe that will help. 🙂 For simplicity, I’m just going to use list as the collector/continuation, which will just return a list with the arguments to the continuation.

    (multirember&co 'foo '(foo bar) list)
    

    At the start,

    a = 'foo
    lat = '(foo bar)
    col = list
    

    At the first iteration, the (eq? (car lat) a) condition matches, since lat is not empty, and the first element of lat is 'foo. This sets up the next recursion to multirember&co thusly:

    a = 'foo
    lat = '(bar)
    col = (lambda (newlat seen)
            (list newlat (cons 'foo seen))
    

    At the next iteration, the else matches: since lat is not empty, and the first element of lat is 'bar (and not 'foo). Thus, for the next recursion, we then have:

    a = 'foo
    lat = '()
    col = (lambda (newlat seen)
            ((lambda (newlat seen)
               (list newlat (cons 'foo seen)))
             (cons 'bar newlat)
             seen))
    

    For ease of human reading (and avoid confusion), we can rename the parameters (due to lexical scoping), without any change to the program’s semantics:

    col = (lambda (newlat1 seen1)
            ((lambda (newlat2 seen2)
               (list newlat2 (cons 'foo seen2)))
             (cons 'bar newlat1)
             seen1))
    

    Finally, the (null? lat) clause matches, since lat is now empty. So we call

    (col '() '())
    

    which expands to:

    ((lambda (newlat1 seen1)
       ((lambda (newlat2 seen2)
          (list newlat2 (cons 'foo seen2)))
        (cons 'bar newlat1)
        seen1))
     '() '())
    

    which (when substituting newlat1 = '() and seen1 = '()) becomes

    ((lambda (newlat2 seen2)
       (list newlat2 (cons 'foo seen2)))
     (cons 'bar '())
     '())
    

    or (evaluating (cons 'bar '()))

    ((lambda (newlat2 seen2)
       (list newlat2 (cons 'foo seen2)))
     '(bar)
     '())
    

    Now, substituting the values newlat2 = '(bar) and seen2 = '(), we get

    (list '(bar) (cons 'foo '()))
    

    or, in other words,

    (list '(bar) '(foo))
    

    to give our final result of

    '((bar) (foo))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note : The code in this question is part of deSleeper if you want
This isn't a code question for once, but it definitely has me confused. Basically,
I've read this question mentioning Code Bubbles and I've watched their video presentation. The
This is more of a licencing issue than a code question. I really like
In answering this code golf question , I ran across a problem in my
Reading this question I found this as (note the quotation marks) code to solve
This is a code review question more then anything. I have the following problem:
Expanding this question on how I learnt to pass from problem description to code
Similar to this question , after running the following code the browser dialog does
Following on from this question I now have code that can attach to a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.