The code runs in REPL but is not saved in the file.

I am trying to create a text game Clojure (inspired by Lisp Earth).

(def *nodes* {:living-room "you are in the living-room. a wizard is snoring loudly on the couch."
              :garden "you are in a beautiful garden. there is a well in front of you."
              :attic "you are in the attic. there is a giant welding torch in the corner."})

(defn describe-location [location nodes]
    (nodes location))

The code works in REPL, but if I saved the code in a file and try to run:

(describe-location :attic *nodes*)

I got:

An exception in the "main" thread java.lang.IllegalArgumentException: Invalid number of arguments (1) passed: user $ describe-location (wizard-game.clj: 0)

What am I doing wrong?
Here is the file: http://dl.dropbox.com/u/3630641/wizard-game.clj

+3
source share
2 answers

You have too many parentheses. Instead (describe-location(:garden *nodes*))you want to (describe-location :garden *nodes*).

, , : (:garden *nodes*), describe-location , , describe-location , .

+3

, , repl , , , (load "wizard-game.clj") REPL. leiningen , , maven .


(ns com.me.myGame  ....)

repl,

(use 'com.me.myGame)

,

(com.me.myGame/describe-location :attic)

repl :

(in-ns 'com.me.myGame)
(describe-location :attic)


leiningen . leiningen , , . leiningen.
lein new wizard-game

src/wizard-game/core.clj. if,

0

Source: https://habr.com/ru/post/1796408/


All Articles