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

  • SEARCH
  • Home
  • 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 8886299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:31:33+00:00 2026-06-14T21:31:33+00:00

it’s my first time posting and i have a doubt on scheme. I have

  • 0

it’s my first time posting and i have a doubt on scheme.
I have to remove all occurrences of an element from a list, passed both as an arguments,
when entering parameters like that:

]=> (rmobject '(1 2 3 5 0 2 3 5 3) 3)

I’m getting an error:

The object (3 5 3 2 3 6 3) is not applicable

I suppose it’s because of the second lambda, that is not working properly but why?

(define (rmobject list1 obj)
  (if (null? list1)
      '() 
       (if (= obj (car list1))
           ((lambda (list1) (cdr list1)) list1)
           ((lambda (list1) (list1)) list1)))
        (cons (car list1) (rmobject (cdr list1) obj)))

I rewrote the code and this works properly on removing the elements but the proper doesn’t, and both are suppose the same. Thanks in advance

(define (rmobject list1 obj)
  (if (null? list1)
     '() 
  (if (= obj (car list1))
      (rmobject (cdr list1) obj)
      (cons (car list1) (rmobject (cdr list1) obj)))))
  • 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-06-14T21:31:34+00:00Added an answer on June 14, 2026 at 9:31 pm

    The first version in your code doesn’t make much sense. Why use lambdas in this way? you’re supposed to recursively call the same procedure being defined, not creating a one-shot anonymous procedure, that won’t work for solving the problem at hand. And this part: (list1) is causing the error The object is not applicable: you’re trying to invoke the list as if it were a procedure – because it’s surrounded by parenthesis. Remember that in Scheme, a syntax such as this one: (foo) indicates that the foo procedure is to be called.

    The second version of your code is fine, that’s the simple way to implement a remove-all procedure. A bit of nitpicking, though: when you find yourself nesting ifs, it’s a sure sign that a cond would be more appropriate. Also notice that it’s a good idea to use equal? instead of =, in that way your procedure will work for more than just numbers:

    (define (rmobject list1 obj)
      (cond ((null? list1)
             '())
            ((equal? obj (car list1))
             (rmobject (cdr list1) obj))
            (else
             (cons (car list1)
                   (rmobject (cdr list1) obj)))))
    

    For future reference: the procedure you’re implementing it’s generally included as part of the interpreter. For example, in Racket we have remove*, which uses equal? as the default procedure for testing equality:

    (define (rmobject list1 obj)
      (remove* (list obj) list1))
    

    Also, you can use filter as in @Maxwell’s answer. Another way to write it:

    (define (rmobject list1 obj)
      (filter (negate (curry equal? obj)) list1))
    

    Anyway, this works:

    (rmobject '(1 2 3 5 0 2 3 5 3) 3)
    => '(1 2 5 0 2 5)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a text area in my form which accepts all possible characters from
I am currently running into a problem where an element is coming back from
I have a view passing on information from a database: def serve_article(request, id): served_article
I have a bunch of posts stored in text files formatted in yaml/textile (from
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and

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.