I have a set of functions saved in .clj.
How do I Provide selected set of functions and then import these functions in my other file?
I have a set of functions saved in .clj.
How do I Provide selected set of functions and then import these functions in my other file?
You have a few options.
If it's just a file (not in a package) then in your files, you can just use load
. If your file was named fun.clj, you would just use the name of the file w/o the extension:
(load "fun")
(provided fun.clj
was on your classpath). Or
(load "files/fun")
if it wasn't on your classpath but in the files
directory.
Or you could use load-file
and pass it the location of your file:
(load-file "./files/fun.clj")
If you wanted to namespace them (put them in a package), then you'd put the ns
macro at the beginning of your file, again put it on your classpath. Then you could load it via use
or require.
Here are the docs for the functions I've described.
Hope this helps.
This one solved my problem and I have looked through countless other issues here so I would like to clarify.
The easiest way in emacs (on linux) is to do something like this:
java -cp "lib/*":. clojure.main -e "(do (require 'swank.swank) (swank.swank/start-repl))"
(note the "lib/*":. given to -cp
Then you can use M-x slime-connect to connect with this instance.
Don't know if it's required, but I have read that it's a good idea to use the same version of clojure, clojure-contrib and swank-clojure on both sides.
You can also setup the path inside emacs by consing the "." to swank-clojure-classpath.