Clojure

From GeilThings

Jump to: navigation, search
Clojure
General
Version 1.5.1
Stable 1.5.1
Function Programming Language
Scripts

Contents

General

  • Worth reading
  • Console: REPL (Read-Evaluate-Print-Loop); java -cp /path/to/clojure.jar clojure.main
    • To quit the console, type (. System exit 0)
  • Example of how to run a program: (/opt/kv-1.2.123/lib/kvclient-1.2.123.jar is a needed external library in this example)
    • java -cp .:/opt/kv-1.2.123/lib/kvclient-1.2.123.jar:/opt/clojure/clojure-1.3.0.jar clojure.main Clojure_oraclenosql.clj
  • Or add
    • java -cp .:/opt/kv-1.2.123/lib/kvclient-1.2.123.jar:/opt/clojure/clojure-1.3.0.jar clojure.main $1
  • to a file, called clj, and run with
    • ./clj Clojure_oraclenosql.clj
  • Version:
    • Enter the REPL: clj. The version will be displayed. Exit with Ctrl-D.
    • In the REPL: (clojure-version)
    • Best: Create a file called clojure-version.clj with (println (clojure-version)) in it. Call it with ./clj clojure-version.clj.

Installing Clojure

APPNAME=clojure
NEWVERSION=1.3.0
 
cd /opt
# Why is this -U YUBLOCKWGET needed for clojure 1.3.0???
# http://dev.clojure.org/jira/browse/CLJ-841
wget http://repo1.maven.org/maven2/org/clojure/clojure/${NEWVERSION}/clojure-${NEWVERSION}.zip -U YUBLOCKWGET
unzip clojure-${NEWVERSION}.zip
ln -s clojure-${NEWVERSION} /opt/clojure
cd clojure
touch clj
vi clj
# In vi:
i
java -jar /opt/clojure/clojure-${NEWVERSION}.jar $1
Esc
:w
:q
# vi is finished.
chmod u+x clj
 
# For administration.
vi clojure-version.clj
# In vi:
i
(println (clojure-version))
:w
:q
# vi is finished.
# Read the clojure version with:
./clj clojure-version.clj

Upgrade Clojure

  • Started with 1.3.0.
APPNAME=clojure
cd /opt/clojure
OLDVERSION=`./clj clojure-version.clj`
echo $OLDVERSION
 
RAWNEWVERSION=`curl -sd "action=ask&query=[[Clojure]]|%3FStable&format=json" http://www.geilthings.com/api.php` 
# Get Version as Substring.  
# Using grep to sed to extract STRING between first occurrence of MATCH1 and next occurrence of MATCH2:  
# http://bit.ly/Ucsnb9  
NEWVERSION=`echo "$RAWNEWVERSION" | grep -Po '^.*?\K(?<=Stable\":\[\").*?(?=\")'`  
echo $NEWVERSION
 
cd /opt
# Why was this -U YUBLOCKWGET needed for clojure 1.3.0???
# http://dev.clojure.org/jira/browse/CLJ-841
wget http://repo1.maven.org/maven2/org/clojure/clojure/${NEWVERSION}/clojure-${NEWVERSION}.zip -U YUBLOCKWGET
unzip clojure-${NEWVERSION}.zip
 
rm -f /opt/clojure
ln -s clojure-${NEWVERSION} /opt/clojure
cd clojure
ln -s clojure-${NEWVERSION}.jar clojure.jar
touch clj
vi clj
# In vi:
i
java -jar /opt/clojure/clojure.jar $1
Esc
:w
:q
# vi is finished.
chmod u+x clj
 
# For administration.
vi clojure-version.clj
# In vi:
i
(println (clojure-version))
:w
:q
# vi is finished.
# Read the clojure version with:
./clj clojure-version.clj
mv /opt/clojure-${OLDVERSION} /opt/old_clojure-${OLDVERSION}
 
# Test programs.
# ...

Programming


Versions

Software name Version number Version date
Clojure 1.5.0
1.5.1
4 March 2013
11 March 2013

Comments

blog comments powered by Disqus