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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T00:42:23+00:00 2026-06-02T00:42:23+00:00

I have a sequence of sequences, output from clojure-csv. (def s1 [[:000-00-0000 SMITH JOHN

  • 0

I have a sequence of sequences, output from clojure-csv.

(def s1 [[:000-00-0000 "SMITH" "JOHN" 27][:000-00-0001 "FARMER" "FANNY" 28]])

I have a vector of column numbers [0 3] that I want to use to extract data from each sequence.

Rather than writing a function to zip together a variable number of map forms, I thought a macro might do the trick. But, I am having trouble.

This macro accepts a sequence and a column “mask”

   (defmacro map-cols [seq & columns]
    (for [col# columns
        :let [mc# `(map #(nth % ~col# nil) ~seq)]]
        mc#))

(map-cols s1 cols)
ClassCastException clojure.lang.LazySeq cannot be cast to clojure.lang.IFn  bene-csv.core/eval2168 

I was hoping to generate the multiple map forms that show up in
the following:

(zipmap (map #(nth % 0 nil) s1) (map #(nth % 1 nil) s1))
{:000-00-0001 "FARMER", :000-00-0000 "SMITH"}

I would appreciate some ideas of what I am doing wrong. I can, of course, just tailor the a function to the number of columns I need to extract.

Thank You.

Edit:

Modified macro

(defmacro map-cols [seq & columns]
    (vec (for [col columns
        :let [mc `(map #(nth % ~col nil) ~seq)]]
        mc)))


(apply zipmap (map-cols s1 cols))

ArityException Wrong number of args (1) passed to: core$zipmap  clojure.lang.AFn.throwArity
  • 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-02T00:42:24+00:00Added an answer on June 2, 2026 at 12:42 am

    You are mixing up code that will execute at macro expansion with code that the macro will output. Until you enter a syntax-quote, you don’t need to use auto-gensym (col#, mc# in your example). As for the macro output, it must always produce exactly one form. It seems that you are expecting it to produce several forms (one for each col), but that’s not how this can work. Your macro output will currently look like

    ((map #(nth % 0 nil) s1) (map #(nth % 1 nil) s1))
    

    This is a form with two members. The member in the head position is expected to be a function, and the whole form is supposed to be evaluated as a function call.

    The way to salvage this is to wrap your for in the macro with a vec and then use (apply zipmap (map-cols s1 cols)).

    That answers your immediate question, but the solution will still not make sense: zipmap wants exactly two args, not a variable number of them as you said you want, and the output is a map, not a sequence that zips together your fields. Zipping is achieved using (map vector seq1 seq2 ...).

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

Sidebar

Related Questions

I have to create a CSV file from webservice output and the CSV file
I have a BLAST output file in XML format. It is 22 query sequences
If I have an executable that generates an output from multiple files at a
I have created a string from connectString = 'D:\Database\10.2.0\BIN\sqlplus.exe -L sys/PASSWORD' output = str(call(connectstring))
I have an XML string which is output from a Visual Fox Pro based
I have a sequence. a1 = 1 - cos(x); ai = a1 + (-1)^(i-1)
suppose i have a sequence, called TEST_SEQ what would be the correct way of
Suppose I have a sequence x1,x2,x3.....xn, and I want to find the longest continuous
I was wondering if this was possible... I have a sequence of variables that
I have an xts sequence of stock trade events that I want to process

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.