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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:36:04+00:00 2026-05-17T00:36:04+00:00

I am trying to write a scheme function that takes a list of the

  • 0

I am trying to write a scheme function that takes a list of the form:

((#f ((1 1) (2 1)))
 (#f ((1 3) (5 1)))
 (#f ((1 4) (7 1)))
)

and removes all the #f to give a list like:

( ((1 1) (2 1))
  ((1 3) (5 1))
  ((1 4) (7 1))
)

I have tried the following code but cannot get it to work:

(define meth
  (lambda lst
    (if (equal? (cdr lst) '())
      (cdr (car lst))
      (cons (list-ref (car lst) 1) (meth (cdr lst))))))

Does anyone know how to do this? Thanks.

  • 1 1 Answer
  • 1 View
  • 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-17T00:36:04+00:00Added an answer on May 17, 2026 at 12:36 am

    You can just use map to apply the cdr function to each sublist in the list, like this: (map cdr lst). However this will give you

    ( (((1 1) (2 1)))
      (((1 3) (5 1)))
      (((1 4) (7 1)))
    )
    

    for your sample input, which is one level of nesting more than your sample output. So to get your sample output, use list-ref to get the second element of each sublist:

    (define (meth lst) (map (lambda (x) (list-ref x 1)) lst))
    

    Edit: As Eli Barzilay helpfully pointed out, there is the cadr function to get the second element of a list, so this can be shortened to:

    (define (meth lst) (map cadr lst))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get a list of product id's that do not have
I am trying to write an app that does a person search of my
I'm trying to create a simple stored procedure which I can use to write
I've been trying to create a PLSQL package that will post into SharePoint through
I am trying to complete a seemingly simple task that has turned into a
Currently my application takes in a text file/files, parses them into another file type
I am trying to integrate some new code I wrote for programmatically interacting with
INITIAL NOTE: This is just for a personal tinkering project; I'm not writing enterprise
Is there a way to attach a piece of metadata to a MySQL database?

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.