Solucionado (ver solução)
Solucionado
(ver solução)
1
resposta

CompilerException java.lang.RuntimeException: No such namespace: forca, compiling:()

Não estou conseguindo progredir no curso devido a este erro:

D:\Leinigen\forca\src\forca>lein repl
#error {
 :cause Unable to resolve symbol: =vidas in this context
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message java.lang.RuntimeException: Unable to resolve symbol: =vidas in this context, compiling:
(forca/core.clj:24:9)
   :at [clojure.lang.Compiler analyze Compiler.java 6688]}
  {:type java.lang.RuntimeException
   :message Unable to resolve symbol: =vidas in this context
   :at [clojure.lang.Util runtimeException Util.java 221]}]
 :trace
 [[clojure.lang.Util runtimeException Util.java 221]
  [clojure.lang.Compiler resolveIn Compiler.java 7164]
  [clojure.lang.Compiler resolve Compiler.java 7108]
  [clojure.lang.Compiler analyzeSymbol Compiler.java 7069]
  [clojure.lang.Compiler analyze Compiler.java 6648]
  [clojure.lang.Compiler analyze Compiler.java 6625]
  [clojure.lang.Compiler$InvokeExpr parse Compiler.java 3766]
  [clojure.lang.Compiler analyzeSeq Compiler.java 6870]
  [clojure.lang.Compiler analyze Compiler.java 6669]
  [clojure.lang.Compiler analyze Compiler.java 6625]
  [clojure.lang.Compiler$IfExpr$Parser parse Compiler.java 2792]
  [clojure.lang.Compiler analyzeSeq Compiler.java 6868]
  [clojure.lang.Compiler analyze Compiler.java 6669]
  [clojure.lang.Compiler analyzeSeq Compiler.java 6856]
  [clojure.lang.Compiler analyze Compiler.java 6669]
  [clojure.lang.Compiler analyze Compiler.java 6625]
  [clojure.lang.Compiler$BodyExpr$Parser parse Compiler.java 6001]
  [clojure.lang.Compiler$FnMethod parse Compiler.java 5380]
  [clojure.lang.Compiler$FnExpr parse Compiler.java 3972]
  [clojure.lang.Compiler analyzeSeq Compiler.java 6866]
  [clojure.lang.Compiler analyze Compiler.java 6669]
  [clojure.lang.Compiler analyzeSeq Compiler.java 6856]
  [clojure.lang.Compiler analyze Compiler.java 6669]
  [clojure.lang.Compiler access$300 Compiler.java 38]
  [clojure.lang.Compiler$DefExpr$Parser parse Compiler.java 589]
  [clojure.lang.Compiler analyzeSeq Compiler.java 6868]
  [clojure.lang.Compiler analyze Compiler.java 6669]
  [clojure.lang.Compiler analyze Compiler.java 6625]
  [clojure.lang.Compiler eval Compiler.java 6931]
  [clojure.lang.Compiler load Compiler.java 7379]
  [clojure.lang.RT loadResourceScript RT.java 372]
  [clojure.lang.RT loadResourceScript RT.java 363]
  [clojure.lang.RT load RT.java 453]
  [clojure.lang.RT load RT.java 419]
  [clojure.core$load$fn__5677 invoke core.clj 5893]
  [clojure.core$load invokeStatic core.clj 5892]
  [clojure.core$load doInvoke core.clj 5876]
  [clojure.lang.RestFn invoke RestFn.java 408]
  [clojure.core$load_one invokeStatic core.clj 5697]
  [clojure.core$load_one invoke core.clj 5692]
  [clojure.core$load_lib$fn__5626 invoke core.clj 5737]
  [clojure.core$load_lib invokeStatic core.clj 5736]
  [clojure.core$load_lib doInvoke core.clj 5717]
  [clojure.lang.RestFn applyTo RestFn.java 142]
  [clojure.core$apply invokeStatic core.clj 648]
  [clojure.core$load_libs invokeStatic core.clj 5774]
  [clojure.core$load_libs doInvoke core.clj 5758]
  [clojure.lang.RestFn applyTo RestFn.java 137]
  [clojure.core$apply invokeStatic core.clj 648]
  [clojure.core$require invokeStatic core.clj 5796]
  [clojure.core$require doInvoke core.clj 5796]
  [clojure.lang.RestFn invoke RestFn.java 408]
  [user$eval5 invokeStatic form-init2222869101223381304.clj 1]
  [user$eval5 invoke form-init2222869101223381304.clj 1]
  [clojure.lang.Compiler eval Compiler.java 6927]
  [clojure.lang.Compiler eval Compiler.java 6916]
  [clojure.lang.Compiler eval Compiler.java 6916]
  [clojure.lang.Compiler load Compiler.java 7379]
  [clojure.lang.Compiler loadFile Compiler.java 7317]
  [clojure.main$load_script invokeStatic main.clj 275]
  [clojure.main$init_opt invokeStatic main.clj 277]
  [clojure.main$init_opt invoke main.clj 277]
  [clojure.main$initialize invokeStatic main.clj 308]
  [clojure.main$null_opt invokeStatic main.clj 342]
  [clojure.main$null_opt invoke main.clj 339]
  [clojure.main$main invokeStatic main.clj 421]
  [clojure.main$main doInvoke main.clj 384]
  [clojure.lang.RestFn invoke RestFn.java 421]
  [clojure.lang.Var invoke Var.java 383]
  [clojure.lang.AFn applyToHelper AFn.java 156]
  [clojure.lang.Var applyTo Var.java 700]
  [clojure.main main main.java 37]]}
nREPL server started on port 58385 on host 127.0.0.1 - nrepl://127.0.0.1:58385
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_92-b14
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
    Exit: Control+D or (exit) or (quit)
 Results: Stored in vars *1, *2, *3, an exception in *e

forca.core=> (forca/jogo 2 "Pato" #{})
CompilerException java.lang.RuntimeException: No such namespace: forca, compiling:(C:\Users\alexsand
ercaproni\AppData\Local\Temp\form-init2222869101223381304.clj:1:1)

forca.core=>

Segue meu código:

(ns forca.core
  (:gen-class))

(def total-de-vidas 6)

(defn perdeu [] (print "Voce perdeu!"))
(defn ganhou [] (print "Voce ganhou!"))

(defn letras-faltantes [palavra acertos]
  (remove (fn [letra] (contains? acertos (str letra))) palavra)
)

(defn acertou-a-palavra-toda? [palavra acertos]
  (empty? (letras-faltantes palavra acertos))
)

(defn le-letra! [] (read-line))

(defn acertou? [chute palavra] (.contains palavra chute))


(defn jogo [vidas palavra acertos]
    (cond
        (=vidas 0) (perdeu)
        (acertou-a-palavra-toda? palavra acertos) (ganhou)
        :else
        (let [chute (le-letra!)]
            (if (acertou? chute palavra)
                (do
                    (println "Acertou a letra!")
                    (recur vidas palavra (conj acertos chute)))
                (do
                    (println "Errou a letra! Perdeu vida!")
                    (recur (dec vidas) palavra acertos))))))

(defn -main
  "I don't do a whole lot ... yet."
  [& args]
  (println "Hello, World!"))
1 resposta
solução!

Fala aí Alexsander,

Acho que faltou um espaço na declaração (=vidas 0). O correto creio que seria (= vidas 0).

Espero ter ajudado e bons estudos.