Clojure namespaces.core file and repl

Question for beginners.

clojure works with lein + emacs + nrepl.

I am a little confused about the following:

I want to use the exponent function. This function is located in the following location clojure.math.numeric-tower . I add [org.clojure/math.numeric-tower "0.0.1"] to the dependencies and run lein deps .

Now it is possible (I'm sure it is possible) to add this to my .core ns as follows:

 (ns learning.core (:require [clojure.math.numeric-tower :as math])) (def i-know-the-answer (math/expt 2 10)) 

Now when I try to load ( ctl-x e ) this in the REPL, it throws errors.

clojure.lang.Compiler$CompilerException: java.lang.RuntimeException: No such namespace: math, compiling:(NO_SOURCE_PATH:2)

Do I need to directly load dependencies in REPL? Can I not just change the source file / recompile it and use it?

+4
source share
1 answer

Download the file using ctrl-c ctrl-l, then switch your replica to the namespace in this file using

 (in-ns 'learning.core) 

Or press ctrl-c alt-n from the Clojure buffer to switch the replica to the buffer namespace. You can find out if this works by looking at the repl prompt.

+4
source

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


All Articles