Skip to content

Commit

Permalink
* project.clj: update project.clj for latest, fix :require-macros for…
Browse files Browse the repository at this point in the history
… core.logic 0.7.0
  • Loading branch information
David Nolen authored and David Nolen committed Mar 30, 2012
1 parent 7346b15 commit 7206944
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
(defproject cljs-demo "0.1.0-SNAPSHOT"
(defproject cljs-demo "0.1.0"
:description "ClojureScripting!"
:dependencies [[org.clojure/clojure "1.4.0-beta3"]
[domina "1.0.0-alpha2"]
[org.clojure/core.match "0.2.0-alpha9"]
[org.clojure/tools.macro "0.1.1"]
[core.logic "0.6.9"]]
[org.clojure/core.logic "0.7.0"]]
:dev-dependencies [[lein-cljsbuild "0.1.3"]]
:cljsbuild {:builds [{:source-path "src"
:compiler {:optimizations :simple
Expand Down
19 changes: 12 additions & 7 deletions src/cljs_demo/core.cljs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
;; proper namespaces
(ns cljs-demo.core
(:use-macros [clojure.core.match.js :only [match]])
(:require-macros [clj.core.logic.macros :as m]
(:require-macros [cljs.core.logic.macros :as m]
[clojure.tools.macro :as mu])
(:use [cljs.core.logic :only [firsto membero lvar *occurs-check*]])
(:require [clojure.string :as s]
Expand Down Expand Up @@ -54,6 +54,10 @@
(comment
;; In JavaScript, Objects do double duty as types and maps

;; everything is immutable!
(def l '(1 2 3 4 5))
(def v [1 2 3 4 5])

;; real hashmaps
(def david {:first "David", :middle "E", :last "Nolen"})
(def bob {:first "Bob" :middle "J" :last "Smith"})
Expand Down Expand Up @@ -88,7 +92,7 @@
;; we can use hash maps as functions
;; there's no magic here, you can implement
;; your function-like type as well
(map address [:street :city])
(map address [:city :street])

;; normally in JS we need something like Underscore.js
;; even then, still verbose, wrapping in functions
Expand All @@ -114,7 +118,7 @@

;; this is just sugar
;; we'll see how this works below
(let [{foo :city} address]
(let [{foo :state} address]
(str foo " cool!"))

;; nested destructuring
Expand Down Expand Up @@ -245,14 +249,14 @@
(deftype MyThing [a b]
ISeqable
(-seq [_]
(list b a)))
(list a b)))

(comment
(.-a (MyThing. "foo" "bar"))
(.-b (MyThing. "foo" "bar"))

;; destructuring just works
(let [[_ f] (MyThing. "foo" "bar")]
(let [[f _] (MyThing. "foo" "bar")]
f)
)

Expand All @@ -277,7 +281,7 @@
(-sound (Cat.))
(-sound (Dog.))
(-sound 1)
(-sound {})
(-sound {})
(-sound [])
(-sound (js/Date.))

Expand Down Expand Up @@ -311,7 +315,8 @@
;; IcedClojureScript not necessary, just make a macro library!
)

;; logic programming
;; Logic programming

(m/defne righto [x y l]
([_ _ [x y . r]])
([_ _ [_ . r]] (righto x y r)))
Expand Down

0 comments on commit 7206944

Please sign in to comment.