E ai pessoal, tudo certo ? Estou enfrantando alguns problemas quanto a compilação do meu código. O que é printado no meu console é o seguinte:
C:\Leiningen\forca\src\forca>lein repl
#error {
:cause Unable to resolve symbol: jogo in this context
:via
[{:type clojure.lang.Compiler$CompilerException
:message java.lang.RuntimeException: Unable to resolve symbol: jogo in this context, compiling:(forca/core.clj:23:7)
:at [clojure.lang.Compiler analyze Compiler.java 6688]}
{:type java.lang.RuntimeException
:message Unable to resolve symbol: jogo 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 2797]
[clojure.lang.Compiler analyzeSeq Compiler.java 6868]
[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-init5984850075210968250.clj 1]
[user$eval5 invoke form-init5984850075210968250.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 50309 on host 127.0.0.1 - nrepl://127.0.0.1:50309
REPL-y 0.3.7, nREPL 0.2.12
Clojure 1.8.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_101-b13
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
Por via de dúvidas, 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 avalia-chute [chute vidas palavra acertos]
(if (acertou? chute palavra)
(jogo vidas palavra (conj acertos chute))
(jogo (dec vidas) palavra acertos)
)
)
(defn jogo [vidas palavra acertos]
(if (= vidas 0)
(perdeu)
(if (acertou-a-palavra-toda? palavra acertos)
(ganhou)
(avalia-chute (le-letra!) vidas palavra acertos)
)
)
)
(defn -main
"I don't do a whole lot ... yet."
[& args]
(println "Hello, World!"))
Agradeço se alguém puder me ajudar.
Obrigado.