Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Jul 29, 2015
0 parents commit 273a04a
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 0 deletions.
17 changes: 17 additions & 0 deletions .gitignore
@@ -0,0 +1,17 @@
pom.xml
*jar
lib
classes
.lein-deps-sum
.lein-repl-history
.lein-plugins/
*iml
.lein-env
out
target
.nrepl-port
.nrepl-history
.repl/
repl/
private
figwheel_server.log
3 changes: 3 additions & 0 deletions README.md
@@ -0,0 +1,3 @@
# sytac-core-async
Slides and code for presentation at the [DevJam meetup](http://www.meetup.com/Sytac-Dev-Jam/events/223330464/), July 29 2015.

23 changes: 23 additions & 0 deletions code/cljs-demo/README.md
@@ -0,0 +1,23 @@
# Animals CRUD

## Running the project

In a terminal, start the web server:

lein repl
(start-server)

In another terminal, start figwheel:

lein figwheel

Finally browse to
[http://localhost:8080/index.html](http://localhost:8080/index.html)
and have fun.

## License

Copyright Michiel Borkent

Distributed under the Eclipse Public License either version 1.0 or (at
your option) any later version.
7 changes: 7 additions & 0 deletions code/cljs-demo/index.html
@@ -0,0 +1,7 @@
<html>
<head>
</head>
<body>
<script src="main.js" type="text/javascript"></script>
</body>
</html>
5 changes: 5 additions & 0 deletions code/cljs-demo/main.js
@@ -0,0 +1,5 @@
if(typeof goog == "undefined") document.write('<script src="out/goog/base.js"></script>');
document.write('<script src="out/cljs_deps.js"></script>');
document.write('<script>if (typeof goog != "undefined") { goog.require("cljs_demo.main"); } else { console.warn("ClojureScript could not load :main, did you forget to specify :asset-path?"); };</script>');

document.write("<script>if (typeof goog != \"undefined\") { goog.require(\"figwheel.connect\"); }</script>");
23 changes: 23 additions & 0 deletions code/cljs-demo/project.clj
@@ -0,0 +1,23 @@
(defproject cljs-demo "0.1.0-SNAPSHOT"
:description "FIXME: write this!"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "0.0-3308"]
[org.clojure/core.async "0.1.346.0-17112a-alpha"] ]

:plugins [[lein-cljsbuild "1.0.5"]
[lein-figwheel "0.3.1"]]

:clean-targets ^{:protect false} [:target-path :compile-path "out"]

:cljsbuild {:builds [{:id "sytac"
:source-paths ["src"]
:figwheel true
:compiler {:output-to "main.js"
:output-dir "out"
:optimizations :none
:asset-path "out"
:main "cljs-demo.main"
:source-map true}}]}

:global-vars {*print-length* 20})
84 changes: 84 additions & 0 deletions code/cljs-demo/src/cljs_demo/main.cljs
@@ -0,0 +1,84 @@
(ns cljs-demo.main
(:require-macros [cljs.core.async.macros :refer (go)])
(:require
[cljs.core.async :refer (<!)]))

(enable-console-print!)

;; (defn f [x]
;; (inc x))

;; (defn f [x]
;; (if (odd? x) x
;; (inc x)))

;; (defn f [x]
;; (set! x "bar"))

;; (def foo (js-obj "bar" "baz"))
;; (set! (.-bar foo) "baaz")
;; (aset foo "abc" 17)

;; (js/alert "foo")
;; (.getTime (js/Date.))
;; (.. (js/Date.) (getTime) (toString))

;; ;; vectors
;; (def v [1 2 3])
;; (conj v 4)
;; (get v 0)
;; (v 0)

;; ;; hash maps
;; (def m {:foo 1 :bar 2})
;; (assoc m :foo 2)
;; (get m :foo)
;; (m :foo)
;; (:foo m)
;; (dissoc m :foo)

;; ;; functional programming
;; (def numbers (range 10))
;; (filter odd? numbers)
;; (map inc numbers)
;; (reduce + numbers)
;; (reductions + numbers)

;; ;; sequences
;; (first [1 2 3])
;; (rest [1 2 3])
;; (distinct [1 1 2 3])
;; (take 2 (range 10))

;; ;; lazy sequences
;; (take 2 (map
;; (fn [n] (js/alert n) n)
;; (range)))

;; ;; atoms/mutable state
;; (def my-atom (atom 0))
;; @my-atom
;; (reset! my-atom 1)
;; (reset! my-atom (inc @my-atom))
;; (swap! my-atom (fn [old-value]
;; (inc old-value)))
;; (swap! my-atom inc)
;; @my-atom

;; ;; macros
;; (map inc
;; (filter odd?
;; (range 10)))

;; (->>
;; (range 10)
;; (filter odd?)
;; (map inc))

;; (macroexpand
;; '(->> (range 10) (filter odd?)))

;; (macroexpand
;; '(->> (range 10)
;; (filter odd?)
;; (map inc)))

0 comments on commit 273a04a

Please sign in to comment.