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
/***************************************************************************** | |
* QuantCup 1: Price-Time Matching Engine | |
* | |
* Submitted by: voyager | |
* | |
* Design Overview: | |
* In this implementation, the limit order book is represented using | |
* a flat linear array (pricePoints), indexed by the numeric price value. | |
* Each entry in this array corresponds to a specific price point and holds | |
* an instance of struct pricePoint. This data structure maintains a list |
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 reagent-test.core | |
(:require [reagent.core :as reagent :refer [atom]] | |
[datascript :as d] | |
[cljs-uuid-utils :as uuid])) | |
(enable-console-print!) | |
(defn bind | |
([conn q] | |
(bind conn q (atom nil))) |
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
(def msgs [ {"a" {:stat1 1 :stat2 10} "b" {:stat1 1}} {"a" {:stat1 1}}]) | |
(def merged (apply merge-with (partial merge-with +) msgs)) | |
;; {"a" {:stat1 2, :stat2 10}, "b" {:stat1 1}} | |
(prn merged) | |
;; {"a" {:stat1 2, :stat2 10}, "b" {:stat1 1}} | |
(= (-> merged first second :stat1) 2) | |
;; true |
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 test.core | |
(:require-macros [cljs.core.async.macros :refer [go]]) | |
(:require [cljs.core.async :refer [<! chan put!]] | |
[om.core :as om :include-macros true] | |
[om.dom :as dom :include-macros true])) | |
(def app-state (atom {:projects | |
[{:id 1 :title "proj 1"} | |
{:id 2 :title "proj 2"} | |
{:id 3 :title "proj 3"} |
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 test.core | |
(:require-macros [cljs.core.async.macros :refer [go]]) | |
(:require [cljs.core.async :refer [<! chan put!]] | |
[om.core :as om :include-macros true] | |
[om.dom :as dom :include-macros true])) | |
(enable-console-print!) | |
(def aidc (chan)) |
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
;; Datomic example code | |
;; Demonstrates using datalog with Clojure defrecords | |
(use '[datomic.api :only [q db] :as d]) | |
;;; http://www.lshift.net/blog/2010/08/21/some-relational-algebra-with-datatypes-in-clojure-12 | |
(defrecord Supplier [number name status city]) | |
(defrecord Part [number name colour weight city]) | |
(defrecord Shipment [supplier part quantity]) | |
;; sample data |
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 timetable.core2 | |
(:refer-clojure :exclude [==]) | |
(:use [clojure.core.logic] | |
[clojure.tools.macro])) | |
;; -------------------------------------------------------- | |
;; Useful goals | |
(defne rembero | |
"Succeeds if out is the list l with the first instance of element x removed" | |
[x l out] |
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
;; based on core.logic 0.8-alpha2 or core.logic master branch | |
(ns sudoku | |
(:refer-clojure :exclude [==]) | |
(:use clojure.core.logic)) | |
(defn get-square [rows x y] | |
(for [x (range x (+ x 3)) | |
y (range y (+ y 3))] | |
(get-in rows [x y]))) |
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
(use '[datomic.api :only (q db) :as d]) | |
(def initial-data | |
[{:sku "1" :price 0.95M :qty 1} | |
{:sku "2" :price 1.99M :qty 0} | |
{:sku "3" :price 1.99M :qty 0} | |
{:sku "4" :price 5.99M :qty 3} | |
{:sku "5" :price 9.99M :qty 2} | |
{:sku "6" :price 2.99M :qty 3} | |
{:sku "7" :price 2.99M :qty 2}]) |
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 sudoku | |
(:refer-clojure :exclude [==]) | |
(:use clojure.core.logic)) | |
(defn get-square [grid x y] | |
(for [x (range x (+ x 3)) | |
y (range y (+ y 3))] | |
(get-in grid [x y]))) | |
(defn init [grid [pos value]] |
NewerOlder