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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:05:07+00:00 2026-05-14T01:05:07+00:00

I am just learning Clojure and am having trouble moving my code into different

  • 0

I am just learning Clojure and am having trouble moving my code into different files.

I keep detting this error from the appnrunner.clj –

Exception in thread "main" java.lang.Exception: Unable to resolve symbol: -run-application in this context

It seems to be finding the namespaces fine, but then not seeing the Vars as being bound… Any idea how to fix this?

Here’s my code:

APPLICATION RUNNER –

(ns src/apprunner
  (:use src/functions))

(def input-files [(resource-path "a.txt") (resource-path "b.txt") (resource-path "c.txt")])
(def output-file (resource-path "output.txt"))

(defn run-application []
  (sort-files input-files output-file))

(run-application)

APPLICATION FUNCTIONS –

(ns src/functions
  (:use clojure.contrib.duck-streams))

(defn flatten [x]
  (let [s? #(instance? clojure.lang.Sequential %)]
    (filter
      (complement s?)
      (tree-seq s? seq x))))

(defn resource-path [file]
  (str "C:/Users/Alex and Paula/Documents/SoftwareProjects/MyClojureApp/resources/" file))

(defn split2 [str delim]
  (seq (.split str delim)))

(defstruct person :first-name :last-name)

(defn read-file-content [file]
  (apply str
    (interpose "\n" (read-lines file))))

(defn person-from-line [line]
  (let [sections (split2 line " ")]
    (struct person (first sections) (second sections))))

(defn formatted-for-display [person]
  (str (:first-name person) (.toUpperCase " ") (:last-name person)))

(defn sort-by-keys [struct-map keys]
  (sort-by #(vec (map % [keys])) struct-map))

(defn formatted-output [persons output-number]
  (let [heading (str "Output #" output-number "\n")
        sorted-persons-for-output (apply str (interpose "\n" (map formatted-for-display (sort-by-keys persons (:first-name :last-name)))))]
    (str heading sorted-persons-for-output)))

(defn read-persons-from [file]
  (let [lines (read-lines file)]
    (map person-from-line lines)))

(defn write-persons-to [file persons]
  (dotimes [i 3]
    (append-spit file (formatted-output persons (+ 1 i)))))

(defn sort-files [input-files output-file]
  (let [persons (flatten (map read-persons-from input-files))]
    (write-persons-to output-file persons)))
  • 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-14T01:05:07+00:00Added an answer on May 14, 2026 at 1:05 am

    You’re not naming your namespaces correctly!

    You should do something like this instead:


    ;;; in file src/apprunner/core.clj
    ;;; (namespace names should contain at least one dot for things
    ;;; not to go into the default package... or some such thing)
    (ns apprunner.core
      (:use apprunner.functions)
    
    ;;; the rest of your code for this file follows unchanged
    

    ;;; in file src/apprunner/functions.clj
    (ns apprunner.functions
      (:use clojure.contrib.duck-streams))
    
    ;;; the rest of your code for this file follows unchanged
    

    Running the above at the REPL ((use 'apprunner.core) etc.) works fine for me.

    To summarise what was the problem here: Namespace names should contain dots where paths to files definining them contain slashes / backslashes (not that I mean relative paths — relative to some directory which is actually on the classpath). Also, the src/ directory is the one you put in your classpath, so you don’t include a src. part in your namespace names. See e.g. the src/foo/bar/baz.clj vs. foo.bar.baz example in my answer to your earlier question.

    Oh, and by the way, figuring out the classpath is difficult, period. So, be sure not to let yourself be discouraged by issues of this sort! 🙂 You might want to include info on how you run your code if you’ve got more namespace or classpath-related questions or if the above doesn’t solve the problem for you, though.

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

Sidebar

Ask A Question

Stats

  • Questions 380k
  • Answers 380k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What you describe is indeed integration testing (more or less).… May 14, 2026 at 9:44 pm
  • Editorial Team
    Editorial Team added an answer for (i in names(UNCA)) { UNCA[,paste(i,"F",sep='.')] <- as.factor(UNCA[,i]) } May 14, 2026 at 9:44 pm
  • Editorial Team
    Editorial Team added an answer Every browser has it's own default styles. You should un-apply… May 14, 2026 at 9:44 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.