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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:37:25+00:00 2026-05-22T12:37:25+00:00

In Scheme, the function (map fn list0 [list1 .. listN]) comes with the restriction

  • 0

In Scheme, the function (map fn list0 [list1 .. listN]) comes with the restriction that the lists must have the same number of elements. Coming from Python, I’m missing the freedom of Python list comprehensions, which look a lot like map above, but without this restriction.

I’m tempted to implement an alternative “my-map”, which allows for lists of differing size, iterating through the first N elements of all lists, where N is the length of the shortest list.

For example, let num be 10 and lst be (1 2 3). With my-map, I hope to write expressions like:

(my-map + (circular-list num) lst)))

And get:

(11 12 13)

I have an easier time reading this than the more conventional

(map + (lambda (arg) (+ num arg)) lst)

or

(map + (make-list (length lst) num) lst) 

Two questions:

  • As a Scheme newbie, am I overlooked important reasons for the restriction on `map`?
  • Does something like `my-map` already exist in Scheme or in the SRFIs? I did take a look at srfi-42, but either it’s not what I’m looking for, or it was, and it wasn’t obvious.
  • 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-22T12:37:26+00:00Added an answer on May 22, 2026 at 12:37 pm

    First, note that map does allow empty lists, but of course if there’s one empty list then all of them should be empty.

    Second, have a look at the srfi-1 version of map — it is specifically different from the R5RS version as follows:

    This procedure is extended from its R5RS specification to allow the arguments to be of unequal length; it terminates when the shortest list runs out.

    Third, most Scheme programmers would very much prefer

    (map (lambda (arg) (+ num arg)) lst)
    

    My guess is that Scheme is different from Python in a way that makes lambda expressions become more and more readable as you get used to the language.

    And finally, there are some implementations that come with some form of a list comprehension. For example, in Racket you can write:

    (for/list ([arg lst]) (+ num arg))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm mocking about with plt-scheme's ffi and I have a C-function that returns a
I have a Scheme macro and a long list, and I'd like to map
I am trying to write a scheme function that takes a list of the
Python, C++, Scheme, and others all let you define functions that take a variable
I have been using PLT Scheme , but it has some issues. Does anyone
I use a non-default Windows colour scheme on most of my machines, and have
I am writing a Scheme-like in interpreter. It seems natural that the Scheme-like interpreter
$(function() { var availableTags = [ActionScript, AppleScript, Scheme]; $(#tags).autocomplete({ source: availableTags }); I don
Common LISP and Emacs LISP have the atom type predicate. Scheme and Clojure don't
If I have an unknown amount of identifiers sharing a specific naming-scheme, is there

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.