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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T03:35:32+00:00 2026-05-29T03:35:32+00:00

I am looking for a concise way to map a variadic function across multiple

  • 0

I am looking for a concise way to map a variadic function across multiple lists, but instead of passing the lists as separate arguments as with MAPCAR, I want to pass a single list consisting of any number of lists, and map through those contained lists. I don’t know beforehand how many lists are in the enclosing list, so I can’t destructure it.

I’ve tried combining MAPCAR and APPLY in all sorts of ways, but can’t figure it out. Must I give up on using MAP and just write the iteration explicitly?

Here’s a function that does what I want:

(defun map-within (fn list-of-lists &optional(maptype #'mapcar))
  "Map FN on the lists contained in LIST-OF-LISTS"
  (cond ((null list-of-lists) nil)
    ((null (cdr list-of-lists)) (car list-of-lists))
    (t
     (funcall maptype fn
         (car list-of-lists)
         (map-within fn (cdr list-of-lists) maptype)))))

where

(map-within #'+ '((1 2 3) (10 20 30) (100 200 300))) => (111 222 333)

Is there some magical application of a lambda made from a map that could express this with just one line?

  • 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-29T03:35:33+00:00Added an answer on May 29, 2026 at 3:35 am

    You can use apply like this:

    (apply #'mapcar #'+ '((1 2 3) (10 20 30) (100 200 300)))
    => (111 222 333)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a concise and functional style way to apply a function to
I am looking for a concise way to check a value to see if
I'm looking for a concise way to compare two arrays for any match. I
What's the most concise (but safe) way to remove a drive name, network path,
I'm looking for a clear, concise and accurate answer. Ideally as the actual answer,
I'm just looking for a simple, concise explanation of the difference between these two.
I've tried looking everywhere for a concise list of the advantages and disadvantages of
Is there a more concise way of writing this CSS? .vertical > a:link, .vertical
I'm looking for a way (in JavaScript) to collect a set of objects into
I am looking for ways of making the following more concise. public class MyTests

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.