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 3357982
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:41:52+00:00 2026-05-18T02:41:52+00:00

I am trying to remove members which exists in a string from a list

  • 0

I am trying to remove members which exists in a string from a list consisting of those members.

Example:

String: "ABC"

List: ('A 'B 'C 'D)

To do: Remove first element of string from the list

To remove the the element from the string:

I am converting it to a list using:

(car (string->list"ABC") 

This gives me character list and first element: #\A

But I do not get how I can remove it from the list as both values do not compare: the character and list values.

Tried this weird approach which did not work:

((eq? (make-string 1 (car (string->list"ABC"))) (car (list 'A 'B 'C 'D))))

Does not work as string value does not compare with the first list value.

How I can compare & remove the first string alphabet from the original list??

  • 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-18T02:41:52+00:00Added an answer on May 18, 2026 at 2:41 am

    Error as list cannot have string element values:

    This is not true. A list can have strings as well as characters as its elements, no problem. You’re getting the error because you’re using car on a string, not a list.

    (car (list->string(list(car (string->list "ABC")))))
    

    Ok, here you’re calling (string->list "ABC") which gives you a list containing the character A, B and C. Now you’re calling car on that and get the character A back. Up to here there’s no problem.

    But then you’re calling list on that character getting a list which only contains the character A and then use list-string to turn this into the string "A". This is still perfectly legal. But then you’re calling car on the string "A" and that’s the error because you’re calling car on a string, but car only accepts a list (well, any pair actually) as its argument.

    Since you’re trying to compare A against that first element of ('A 'B 'C 'D), i.e. 'A, which is a symbol, you probably want to convert the string "A" into the symbol 'A (or the symbol 'A into the string "A"). To do this, you can use the function string->symbol instead of car.

    Once you have the symbol A, you can easily remove it from the list using the filter function:

    (let ((a (string->symbol (list->string (list (car (string->list "ABC")))))))
      (filter (lambda (x) (not (eq? x a))) '(A B C)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to remove an element from a vector using std::remove and std::erase.
I'm trying to remove part of the path in a string. I have the
I'm trying to remove scrollbar from my facebook app. I tried js solution, that
I'm trying to remove wiki formatting from some text so it can be parsed.
I'm trying to remove a specific graph object from the zedgraph, is it possible....?
I am trying to remove everything between curly braces in a string, and trying
I am trying to remove an object from an ArrayList and here is the
Hello I was trying to remove objects from object array that I have and
I am trying to create an example, which would check the existence of the
I have a vector that I am trying to remove an object from. The

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.