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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:09:54+00:00 2026-05-28T08:09:54+00:00

I completed exercise 43 on 4clojure the other day and checked some of the

  • 0

I completed exercise 43 on 4clojure the other day and checked some of the other solutions. One in particular has confused me.

The challenge asks you to write a function which satisfies all of these:

(= (__ [1 2 3 4 5 6] 2) '((1 3 5) (2 4 6)))
(= (__ (range 9) 3) '((0 3 6) (1 4 7) (2 5 8)))
(= (__ (range 10) 5) '((0 5) (1 6) (2 7) (3 8) (4 9)))

My solution was this:

(fn [l n] 
    (map #(map second %) (vals (group-by #(mod (first %) n) 
    (map vector (iterate inc 0) l)))))

User himself had this solution:
#(apply map list (partition %2 %1))
and I couldn’t work out how it worked.

Let’s work through the first problem:

(= (__ [1 2 3 4 5 6] 2) '((1 3 5) (2 4 6)))

well the (#(partition %2 %1) [1 2 3 4 5 6] 2) would give us ((1 2) (3 4) (5 6)) now how does apply map list on that produce (1 3 5) (2 4 6)

  • 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-28T08:09:55+00:00Added an answer on May 28, 2026 at 8:09 am

    apply is using the ((1 2) (3 4) (5 6)) as a variable length list of additional arguments. Then iteration of the map is applying the list function to all three of these additional lists.

    As a result it expands as follows:

       (apply map list '((1 2) (3 4) (5 6)))
    => (map list '(1 2) '(3 4) '(5 6))
    => (list 1 3 5) and (list 2 4 6)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've completed Chapter 5 and all the exercises. As part of the final exercise,
I am trying to write a Spider Solitaire player as an exercise in learning
I'm trying to complete an exercise to write a program that takes the following
I've completed the Graham's exercise Chapter 5.8,and my code is: (defun max-min (vec &key
I'm trying to complete an exercise for a JavaScript class and I'm confused about
I have recently completed the following interview exercise: 'A robot can be programmed to
I just completed an exercise for this text and was wondering if this could
I trying to complete this exercise; Write a Lisp function that takes as input
I’m trying to complete the second exercise on IO day 2 in the book
Recently I've studied the backpropagation network and have done some manual exercise. After that,

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.