簡體   English   中英

一旦進入REPL,我如何自動使用“test.clj”中的功能?

[英]How can i use the functions in “test.clj” automatically once entering the REPL?

在haskell中,當通過cusomizing~ / .ghci進入其交互式環境時,我可以自動使用“test.hs”中定義的函數。

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

現在我將“test.hs”轉換為“test.clj”並使用以下腳本輸入其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
else
     exec java -cp "$CLOJURE_JAR:$CONTRIB_JAR" clojure.main $1 -- "$@"
fi

祝商祺!

你可以用Leiningen。

 lein new foo

將代碼粘貼到./foo/src/foo/core.clj並在./foo中運行'lein repl'

這樣,您就可以在REPL中使用core.clj中定義的函數。

對於評估+ REPL,您可以使用以下命令:

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

請參閱clojure.main函數的文檔 命令行選項順序很重要!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM