Skip to content
This repository has been archived by the owner on Jan 1, 2019. It is now read-only.

Commit

Permalink
Make a separate Clojure directory.
Browse files Browse the repository at this point in the history
Add a hello arguments example.
Add some ClojureScript examples.
Add a readme.
  • Loading branch information
oylenshpeegul committed Oct 3, 2017
1 parent e68b6ce commit d33d5ad
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 0 deletions.
56 changes: 56 additions & 0 deletions Clojure/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# [Clojure](https://clojure.org/) is a robust, practical, and fast programming language with a set of useful features that together form a simple, coherent, and powerful tool.

Clojure is a dialect of Lisp that runs on the Java Virual Machine.

```
$ ./hello.clj
Hello, World!
```

The command line arguments are passed in as `*command-line-args*`

```
$ ./hello.clj Hank Dean Brock
Hello, Hank!
Hello, Dean!
Hello, Brock!
```

# [ClojureScript](https://clojure.org/about/clojurescript) is a compiler for Clojure that targets JavaScript.

## [Planck](http://planck-repl.org/) is a stand-alone ClojureScript REPL based on [JavaScriptCore](https://webkit.org/).

```
$ ./hello-planck
Hello, World!
```

It has its own way of getting the `*command-line-args*`

```
$ ./hello-planck Hank Dean Brock
Hello, Hank!
Hello, Dean!
Hello, Brock!
```

but otherwise it looks like Clojure.

## [Lumo](https://github.com/anmonteiro/lumo) is a stand-alone ClojureScript REPL based on [V8](https://nodejs.org/).


```
$ ./hello-lumo
Hello, World!
```

We get the command line arguments through Node.js

```
$ ./hello-lumo Hank Dean Brock
Hello, Hank!
Hello, Dean!
Hello, Brock!
```

Just as Clojure as easy interop with Java, ClojureScript has easy interop with JavaScript.
15 changes: 15 additions & 0 deletions Clojure/hello-lumo
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env lumo
;; -*- clojure -*-

(def process (js/require "process"))

(def args (.slice (.-argv process) 3))

(defn greet [name]
(println (str "Hello, " name "!")))

(if (empty? args)
(greet "World")
(doseq [name args]
(greet name)))

16 changes: 16 additions & 0 deletions Clojure/hello-planck
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env planck
;; -*- clojure -*-

(ns hello.core
(:require [planck.core :refer [*command-line-args*]]))

(def args *command-line-args*)

(defn greet [name]
(println (str "Hello, " name "!")))

(if (empty? args)
(greet "World")
(doseq [name args]
(greet name)))

File renamed without changes.
12 changes: 12 additions & 0 deletions Clojure/hello.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/usr/bin/env clj

(def args *command-line-args*)

(defn greet [name]
(println (str "Hello, " name "!")))

(if (empty? args)
(greet "World")
(doseq [name args]
(greet name)))

0 comments on commit d33d5ad

Please sign in to comment.