* JLine 다운로드: http://jline.sourceforge.net/downloads.html
jline-1.0.jar 파일을 d:\clojure-1.4.0 폴더에 복사함
*일괄 파일 clj.bat 의 내용
:: 2. Put this clj.bat file on your PATH
::
:: Usage:
::
:: clj # Starts REPL
:: clj my_script.clj # Runs the script
:: clj my_script.clj arg1 arg2 # Runs the script with arguments
@echo off
:: Change the following to match your paths
set CLOJURE_DIR=D:\clojure-1.4.0
set CLOJURE_JAR=%CLOJURE_DIR%\clojure-1.4.0.jar
set CONTRIB_JAR=%CLOJURE_DIR%\clojure-contrib-1.4.0.jar
set JLINE_JAR=%CLOJURE_DIR%\jline-1.0.jar
if (%1) == () (
:: Start REPL
java -cp .;%JLINE_JAR%;%CLOJURE_JAR%;%CONTRIB_JAR% jline.ConsoleRunner clojure.main
) else (
:: Start some_script.clj
java -cp .;%CLOJURE_JAR%;%CONTRIB_JAR% clojure.main %1 %*
)
* 소스 파일 hello.clj 의 내용 (저장시 utf-8 인코딩으로 저장해야 한글이 정상 처리됨)
(println "안녕?")
(printf "%s\n" "안녕?")
(println (first *command-line-args*))
(println (str *command-line-args*))
(println (rest *command-line-args*))
(printf "%d\n" (reduce + (map read-string ["1" "2" "3" "4"])))
(printf "%d\n" (reduce + (map read-string (rest *command-line-args*))))
(defn sqr [x] (* x x))
(printf "%d\n" (reduce + (map sqr (map read-string (rest *command-line-args*) ))))
;; -------------------------------------------------------------------
;; JLine 도 설치하고, clj.bat 도 미리 작성함
;; JLine 은 http://jline.sourceforge.net/downloads.html 에서 다운로드
;;
;; jline-1.0.jar 파일을 d:\clojure-1.4.0 폴더에 복사함
;;
;; 소스 파일은 utf-8 인코딩으로 저장함
;;
;; Prompt> chcp 949
;;
;; Prompt> clj hello.clj 5 1 2 3 9
;; Hello
;; 안녕?
;; 안녕?
;; hello.clj
;; ("hello.clj" "5" "1" "2" "3" "9")
;; (5 1 2 3 9)
;; 10
;; 20
;; 120
;; -------------------------------------------------------------------
* 위의 소스 파일 hello.clj 를 실행하기
Prompt> clj hello.clj 5 1 2 3 9
'프로그래밍 > Clojure' 카테고리의 다른 글
Clojure 언어로 계산하는 30000! (팩토리얼) 계산하기 (0) | 2013.02.11 |
---|