This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Define a "base type" of Dog | |
(defrecord Dog [breed]) | |
;; Define a "sub type" of TrainedDog | |
(defrecord TrainedDog [dog word]) | |
;; The interface that both Dog and TrainedDog will implement | |
(defprotocol Talker | |
(bark [_]) | |
(speak |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; (:require [lonocloud.step.async.pschema :as s]) | |
;; Define a higher-order function. Note the 'format-f' argument that is specified to be a function | |
;; of one arity that takes a String and an s/Int to produce a String | |
(s/defn write-person [format-f :- (s/fn String [String s/Int]) | |
person :- {:name String | |
:age s/Int}] | |
(format-f (:name person) (:age person))) | |
(def joe {:name "joe" :age 19}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns datomic-tutorial (:import [datomic Peer Util] | |
[java.io FileReader])) | |
;;create database | |
(Peer/createDatabase "datomic:mem://seattle") | |
(Peer/createDatabase "datomic:mem://seattle") | |
(let [conn (Peer/connect "datomic:mem://seattle")] | |
;; setup sample schema | |
(.get (.transact conn |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns bolo.sandbox | |
(:require [bolo.nxt] | |
[bolo.ino]) | |
(:use [bolo.base :only (dbg eval-in-ns)] | |
[bolo.ops :only (main forward backward turn-left turn-right wait duration block)] | |
[clojure.pprint :only (pprint)]) | |
(:import [bolo.ops Wait])) | |
;; make a program in our tank DSL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns bolo.ops | |
(:use [bolo.base :only (new-op)])) | |
;; define the operators for our tank DSL | |
(new-op main [& commands]) | |
(new-op forward [power]) | |
(new-op backward [power]) | |
(new-op turn-left [power]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns bolo.op-demo | |
(:use [bolo.base :only (new-op)])) | |
;; example of how an operator works | |
;; an operator is similar to a Clojure record. The main difference is | |
;; that an operator presents itself as a Clojure List, whereas a record | |
;; presents itself as a Clojure Map. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns people | |
(:use [clojure.string :only (join)] | |
[clojure.pprint :only (pprint simple-dispatch)])) | |
;; we can make maps using the special literal form: | |
{:a 100 | |
:b 200} | |
(class {:a 100 :b 200}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Define a "base type" of Dog | |
(defrecord Dog [breed]) | |
;; Define a "sub type" of TrainedDog | |
(defrecord TrainedDog [dog word]) | |
;; The interface that both Dog and TrainedDog will implement | |
(defprotocol Talker | |
(bark [_]) | |
(speak [_]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(pprint (new-rocket-car {:color "Blue" :fuel 100 :name "Zoomer"})) | |
;; -> "(new-rocket-car {:color "Blue", :fuel 100, :name "Zoomer"})\n" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(new-rocket-car | |
(new-rocket-car {:color "Blue" :fuel 100 :name "Zoomer"}) | |
{:color "Red" :name "Flash"}) | |
;; -> (new-rocket-car {:name "Flash", :fuel 100, :color "Red"}) |
NewerOlder