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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:11:27+00:00 2026-06-04T04:11:27+00:00

This is homework, so I don’t want the answer. I only need a push

  • 0

This is homework, so I don’t want the answer. I only need a push in the right direction. I am required to map multiple functions onto a list. For instance:

(map-multi (list plus-one square) '(4 5 6)) => (25 36 49)

I am able to have it map the first function to the elements of the list, however, I get very lost after that. Also, since this is introductory, I am limited to introductory functions (const, append, car, cdr, member, etc.)

(define (map-multi f l)  
    (cond  
        ((null? l)  
            l)  
        (else (cons ((car f) (car l))  
            (map-multi f (cdr l))))))  
  • 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-04T04:11:28+00:00Added an answer on June 4, 2026 at 4:11 am

    You need to compose the functions you receive in the f parameter. For simplicity’s sake, let’s say that there are only two functions in the list – then you need to apply the first function to the current element in the list of numbers and then apply the second function to the result of that. If you can use the compose procedure go ahead with it and change this line in your code:

    ((car f) (car l)) ; you're applying only the 1st function! what about the 2nd?
    

    … with this one:

    ((compose (cadr f) (car f)) (car l))       ; now we're applying both functions
    

    If you can’t use compose, then replace the same line with this one:

    ((cadr f) ((car f) (car l)))               ; now we're applying both functions
    

    Now, if the problem is more general and you’re required to map a list of functions with more than two elements, then once more replace the same line in your code with this:

    ((compose-multi f) (car l))
    

    And implement a helper function that composes and returns all the functions in the list, by successive calls to compose. This one is left as an exercise for you, given that it’s homework – but if you understand how the above code works for just two functions, it should be easy enough to extend the result for a list of multiple functions:

    (define (compose-multi flist)      ; procedure for composing a list of functions
      (if (null? flist)                ; if the list is empty then
          <???>                        ; return the identity function
          (<???> (compose-multi <???>) ; else compose the result of recursive call
                 <???>)))              ; with the current element in the list
    

    Notice that the identity function is required for handling the case where there are no elements in the list of functions; it’s very simple to define, it just returns the same value that was passed as parameter.

    Also be aware that compose-multi returns a function, the result of composing all the functions in the list – compose does this for you, but if you’re not allowed to use it just remember that this:

    (compose x y)
    

    … is equivalent to this:

    (lambda (n) (x (y n)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is homework, so I don't expect the answer, just a point in the
Considering this is only for my homework I don't expect much help but I
I have this homework, I have only 1 problem, and I don't know the
This is a homework assignment so I don't want to post any code, but
This is not homework, I need this for my program :) I ask this
Alright, i had this homework recently (don't worry, i've already done it, but in
I'll start by admitting this is for my homework and I don't expect anything
First of all, this is not homework, so please don't tag it as homewrok
This is a homework, and we don't learn the structs in C# (and I
Okay this is a homework question, and I just don't have a clue how

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.