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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:20:38+00:00 2026-05-26T05:20:38+00:00

I am writing a text game in Clojure. I want the player to type

  • 0

I am writing a text game in Clojure. I want the player to type lines at the console, and the game to respond on a line-by-line basis.

Research showed me that (read-line) is the way one is meant to get text lines from standard input in Clojure, but it is not working for me.

I am in a fresh Leiningen project, and I have added a :main clause to the project.clj pointing to the only source file:

(ns textgame.core)

(defn -main [& args]
  (println "Entering -main")
;  (flush)                      ;makes no difference if flush are commented out
  (let [input (read-line)]
    (println "ECHO:" input))
;  (flush)
  (println "Exiting -main"))

using lein run yields:

Entering -main
ECHO: nil
Exiting -main

In other words, there is no opportunity to enter text at the console for (read-line) to read.

How should I get Clojure to wait for characters and newline to be entered and return the corresponding string?

(I am using GNOME Terminal 2.32.1 on Linux Mint 11, Leiningen 1.6.1.1 on Java 1.6.0_26 Java HotSpot(TM) 64-Bit Server VM, Clojure version 1.2.1.)

Update: If I run lein repl, I can (println (read-line)), but not when I have a -main function and run using lein run.

  • 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-26T05:20:39+00:00Added an answer on May 26, 2026 at 5:20 am

    I have had similar problems and resorted to building a jar file and then running that.

    lein uberjar
    java -jar project-standalone.jar
    

    It’s a bit slower, though it got me unstuck. An answer that works from the repl would
    be better

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

Sidebar

Related Questions

I'm writing an app to view an online web text-based game. I want to
I am currently writing a text-adventure type game in Malbolge. Can anyone tell me
I'm writing a short text-adventure game and that game is ready, but now I
I'm writing a text adventure game in Prolog, and I am printing out room
I'm writing a game in python with pygame and need to render text onto
I am writing a text editor and right now if I type very quickly
I'm tinkering with writing a simple text-based role-playing game. I would like to use
I am writing a high-score sub-routine for a text-based game. Here's what I have
I'm writing XNA game and want my game to support 5 different languages and
I started writing a super-simple text adventure game a few months ago, and I

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.