开发者

How can i use the functions in "test.clj" automatically once entering the REPL?

开发者 https://www.devze.com 2023-03-29 18:50 出处:网络
In haskell, i can use the functions defined in \"test.hs\" automatically when entering its interactive environment by cusomizing ~/.ghci .

In haskell, i can use the functions defined in "test.hs" automatically when entering its interactive environment by cusomizing ~/.ghci .

>cat ~/.ghci
:def hoogle \str -> return $ ":! hoogle --count=15 \"" ++ str ++ "\""
:cd /media/E/www/qachina/db/doc/test
:load test

Now i convert "test.hs" to "test.clj" and use the following script to enter its REPL.

%cat ~/bin/myclj 
#!/bin/sh
breakchars="(){}[],^%$#@\"\";:''|\\"
CLOJURE_DIR=/usr/share/clojure
CLOJURE_JAR="$CLOJURE_DIR"/clojure.jar
CONTRIB_JAR="$CLOJURE_DIR"/clojure-contrib.jar
if [ $# -eq 0 ]; then 
     exec rlwrap --remember -c -b "$breakchars" \
       -f "$HOME"/.clj_completions \
     java -cp "$CLOJURE_JAR:$CONTRIB_JAR" clojure.main
els开发者_开发知识库e
     exec java -cp "$CLOJURE_JAR:$CONTRIB_JAR" clojure.main $1 -- "$@"
fi

Sincerely!


for evaluation + REPL you can use following command:

java -cp .....  clojure.main -i script/run.clj -r

See documentation for clojure.main function. Order of command line options is important!


You could just use Leiningen.

 lein new foo

Paste your code into ./foo/src/foo/core.clj and run 'lein repl' in ./foo

That way you can use the functions defined in core.clj in a REPL.

0

精彩评论

暂无评论...
验证码 换一张
取 消