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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:32:33+00:00 2026-05-19T09:32:33+00:00

I currently am having an issue where I have to read a text file

  • 0

I currently am having an issue where I have to read a text file from the command line containing at least one integer. I’m reading the file, doing a regular-expression match to ignore whitespace.

(re-seq #"[0-9]+" (slurp (first *command-line-args*)))

After this I have to write a whole function just to convert this sequence of strings into a sequence of integers. Apparently I cannot map Integer. to the sequence (unless I am using map incorrectly).

Is there some elegant way of handling this, something similar to map? Or do I have to go through recursively popping off first and casting it to Integer. to get this to work?

I am currently learning Clojure, and as I learn bits I am going back and doing little programmer quizzes I used to pick up other languages.

  • 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-19T09:32:34+00:00Added an answer on May 19, 2026 at 9:32 am

    You’re looking for Integer/parseInt.

    user=> (map #(Integer/parseInt %) ["1" "2" "3" "4"])
    (1 2 3 4)
    

    You have to wrap Integer/parseInt in an anonymous function because Java methods aren’t functions.

    read-string would also work in this case:

    user=> (map read-string ["1" "2" "3" "4"])
    (1 2 3 4)
    

    read-string reads any object from a string, not just integers. So, if you did (read-string "1.0") you’d get back a double. When reading from outside sources, it’s usually better to limit what can be read to precisely what you need, which is an integer in this case. Therefore, I recommend using my first example.

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

Sidebar

Related Questions

I'm having an issue with multiple markers on google maps - I currently have
Hi All I am currently having an issue calling a WCF service from a
I am currently having an issue with BackgroundWorker running on Windows Server 2003. I
I'm currently having an issue wrapping my brain around the notion of converting my
I'm currently having a major issue with a python script. The script runs arbitrary
Hopefully someone can shed a little light on an issue that I'm currently having
I'm having an issue with a query that currently uses LEFT JOIN weblog_data AS
I'm currently using this jQuery validate plugin and having an issue in IE where
Definitions: Files: Having the localization phrases stored in a physical file that gets read
I just recently read about Mocking objects for unit testing and currently I'm having

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.