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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:50:18+00:00 2026-06-12T15:50:18+00:00

Given a predicate that tests a single item, such as positive? , I am

  • 0

Given a predicate that tests a single item, such as positive?, I am trying to create an all-are version of it for testing whether all elements of the list satisfy the predicate

Ex:
((all-are positive?) '(1 2 3 4)) => #t
((all-are even?) '(2 4 5 6 8)) => #f

all-are should take a predicate as an argument and return a new function that can be applied to the list of elements

  • 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-12T15:50:19+00:00Added an answer on June 12, 2026 at 3:50 pm

    That’s quite simple to express in terms of an existing procedure: andmap – which returns #t if a given predicate, when applied to all the elements in a list, evaluates to true for all of them:

    (define ((all-are predicate) lst)
      (andmap predicate lst))
    

    I’m using a bit of syntactic sugar for returning a curried procedure, because the question states that a function must be returned. It works as expected:

    ((all-are positive?) '(1 2 3 4))
    > #t
    
    ((all-are even?) '(2 4 5 6 8))
    > #f
    

    I’m guessing that you have to implement the procedure from scratch, and not using existing procedures as in my solution. A good exercise would be to turn the short version above (which demonstrates the general idea of what needs to be done) into something simpler using only basic forms – that’s probably what your teacher expects from you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a predicate that given a list of lists (matrix) removeElementM(Line,Column,List,NewList) removes the
I am trying to create a simple WF4 activity that accepts a string that
Is there an STL/boost algorithm that will test if all the elements between two
Hello I have a predicate that returns example equalisation for given list equalisation([1,2,3,4,12],L). L
Does Haskell standard library have a function that given a list and a predicate,
I want a simple predicate that returns me all the groups which have mode
I've been given the question: Define a predicate ordered/1, which checks if a list
Given that the web application doesn't have su privileges, I'd like to execute a
Given the following code: $(.force-selection).blur(function() { var value = $('matched-item').val(); //check if the input's
Given that an input String may be specified as follows: read(xpath(‘...’)) or xpath(‘...’) or

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.