Clojure 1.3.0
core.logic 0.6.8
This is the base code for which all
the run
calls use.
(use 'clojure.core.logic)
(defne all-in [x mems]
;; Datomic example code | |
(use '[datomic.api :only (db q) :as d]) | |
;; ?answer binds a scalar | |
(q '[:find ?answer :in ?answer] | |
42) | |
;; of course you can bind more than one of anything | |
(q '[:find ?last ?first :in ?last ?first] | |
"Doe" "John") |
;; | |
;; Neil's Bot | |
;; | |
(defn- valid-empty-space? [board [r c]] | |
(cond | |
(not (< -1 r (count board))) false | |
(not (< -1 c (count (nth board r)))) false | |
:else (nil? (nth (nth board r) c)))) |
Clojure 1.3.0
core.logic 0.6.8
This is the base code for which all
the run
calls use.
(use 'clojure.core.logic)
(defne all-in [x mems]
;; lein settings | |
(defproject foo "1.0.0-SNAPSHOT" | |
:description "Test App" | |
:dependencies [[com.datomic/datomic "0.1.2678"] | |
[frinj "0.1.2" :exclusions [org.clojure/clojure]]]) | |
;; load libs | |
(use 'frinj.core 'frinj.calc) | |
(frinj-init!) | |
(use '[datomic.api :only (q db) :as d]) |
(ns fst | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic])) | |
;; A finite state transducer is essentially a translator between | |
;; two tapes of symbols. It is normally a translator from an input | |
;; tape to an output tape, but since we are using core.logic, | |
;; we hope to relax this restriction :). | |
;; The main idea is that every transition accepts two symbols |
(defn make-foo [n] | |
(let [foo (atom n)] | |
{:update (fn [n] (reset! foo n)) | |
:inc (fn [] (swap! foo inc)) | |
:status (fn [] (print @foo))} )) | |
(defmacro defobject | |
"doesn't work yet" | |
[name field-vec & methods] | |
(let [methods (partition 3 methods) |
For a moment, I'm going to throw away my automation and configuration management hat. I'll let you know when I put it back on. Also, let's ignore that we're talking about Riak specifically for a moment. Also also, let's ignore any (for a brief moment) the proper role of a package manager.
If you're writing server software, you have two target markets. The system administrator/operations team and the developer.
The main reason you want autostart is to get people up and running quickly. To do this, you need to ship safe and sane defaults. This means something like a default configuration that listens only on localhost.
(ns fsmparse | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic])) | |
;; We will encode a state machine that accepts lists containing '(w h y) as a sublist | |
;; Moreover, instead of a recognizer, we will implement a parser, that returns a list | |
;; of visited states in order | |
;; | |
;; +----#-----+----#-----+ +--?--+ | |
;; v | | v | |
(ns fsm | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic])) | |
;; Encoding a Finite State Machine and recognizing strings in its language in Clojure core.logic | |
;; We will encode the following FSM: | |
;; | |
;; (ok) --+---b---> (fail) | |
;; ^ | |
;; This first swipe at generative-style testing in Midje was super easy: | |
;; first a use of it | |
(defn make-string [] | |
(rand-nth ["a" "b" "c" "d" "e" "f" "g" "i"])) | |
(formula [a (make-string) b (make-string)] | |
(str a b) => #(.startsWith % a)) |