Question

I am trying to use expt function according to this answer but when I try to do (use 'clojure.math.numeric-tower) in REPL I get the error

user> (use 'clojure.math.numeric-tower)
(use 'clojure.math.numeric-tower)FileNotFoundException Could not locate clojure/math/numeric_tower__init.class or clojure/math/numeric_tower.clj on classpath:   clojure.lang.RT.load (RT.java:443)

I thought I needed to put Leiningen dependency information as explained here

[org.clojure/math.numeric-tower "0.0.2"]

in my project.clj, and I did that but I still get the same error. What am I doing wrong?


EDIT

As in this answer I went to my project directory and did lein deps

a@b:~/command-line-args$ lein deps
Retrieving org/clojure/math.numeric-tower/0.0.2/math.numeric-tower-0.0.2.pom from central
Retrieving org/clojure/math.numeric-tower/0.0.2/math.numeric-tower-0.0.2.jar from central
a@b:~/command-line-args$ 

but I still get the same error in REPL.


Edit2

As per Vidya's answer I am trying to use Pomegranate but without success. This is what I tried. What am I doing wrong:

user> (use '[cemerick.pomegranate :only (add-dependencies)])
nil
user> (add-dependencies :coordinate '[[org.clojure/math.numeric-tower "0.0.2"]]
                        :repositories (merge cemerick.pomegranate.aether/maven-central
                                             {"clojars" "http://clojars.org/repo"}))
{}
user> (require '(numeric-tower core stats charts))
FileNotFoundException Could not locate numeric_tower/core__init.class or numeric_tower/core.clj on classpath:   clojure.lang.RT.load (RT.java:443)
user> (require 'clojure.contrib.math)
FileNotFoundException Could not locate clojure/contrib/math__init.class or clojure/contrib/math.clj on classpath:   clojure.lang.RT.load (RT.java:443)
user> 
Was it helpful?

Solution

here is an example of a properly configured project to compare with:

project.clj:

(defproject math-example "0.1.0-SNAPSHOT"                            
  :description "FIXME: write description"                            
  :url "http://example.com/FIXME"                                    
  :license {:name "Eclipse Public License"                           
            :url "http://www.eclipse.org/legal/epl-v10.html"}        
  :dependencies [[org.clojure/clojure "1.5.1"]                       
                 [org.clojure/math.numeric-tower "0.0.2"]]) 

src/math_example/core.clj:

(ns math-example.core                                                
  (:require [clojure.math.numeric-tower :as math]))                  

(def x (math/expt 2 10)) 

repl:

math-example.core> (math/expt 2 10)                                  
1024                                                                 
math-example.core> x                                                 
1024                                                                 
math-example.core> 

Using most clojure libraries should, in general, be no harder than adding the dependency and adding a :require tag to a namespace (or a :use tag if you prefer).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top