Clause | Options | Desc |
---|---|---|
INITIALLY | Lisp forms to execute before loop starts | |
AFTER-EACH | Lisp |
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
(defun map-update (fun src &rest lists) | |
(funcall | |
(reduce (lambda (cont list-elms) | |
(lambda () | |
(apply fun (funcall cont) list-elms) )) | |
(apply #'mapcar #'list lists) | |
:initial-value (constantly src) ))) | |
(defun subst-all (to-list from-list src) | |
(map-update |
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 uri "datomic:mem://user-groups3") | |
(d/create-database uri) | |
(def conn (d/connect uri)) | |
(d/transact | |
conn | |
[{:db.install/_attribute :db.part/db | |
:db/id #db/id[:db.part/db] | |
:db/ident :user/name |
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
;; | |
;; in the directory /tmp/include-binary/ | |
;; containing a file foo.jpg, this file, and product.lisp | |
;; | |
;; | |
;; $ ls -la | |
;; total 768 | |
;; drwxr-xr-x 5 user wheel 170 Oct 4 08:28 . | |
;; drwxrwxrwt 19 root wheel 646 Oct 4 08:25 .. |
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
(defn run | |
[] | |
(let [symbols ["AAPL","GLD","GOOG","$SPX","XOM"] | |
start-day (date-time 2012 1 1) | |
end-day (date-time 2012 12 31) | |
time-of-day (hours 16) | |
timestamps (get-NYSE-days start-day end-day time-of-day) | |
symbols-data (read-symbols-data "Yahoo" symbols) | |
adj-close-data (incanter.core/to-dataset | |
(get-data timestamps symbols (keyword "Adj Close") symbols-data time-of-day))] |
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 qstk.tutorial1 | |
(:use [clj-time.core :exclude 'extend]) | |
(:use clj-time.format) | |
(:use clj-time.coerce) | |
(:require incanter.io) | |
(:require incanter.core)) | |
(def ^{:dynamic true} *QS* (get (System/getenv) "QS")) | |
(defn get-NYSE-days |
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
;; -*- mode:common-lisp -*- | |
(defun map-file (filename &rest flags) | |
"Maps FILENAME, returns the opened stream, base aligned address and length." | |
(let ((s (apply #'open filename :mapped t flags))) | |
(values s (slot-value s 'excl::buffer) (file-length s)))) | |
;; Read unaligned little-endian numbers | |
(defun read-u8 (base off) | |
(sys:memref base off 0 :unsigned-byte)) |
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
(let [[message-seq put] (pipe)] | |
(letfn [(message-handler [ch msg-meta payload]) | |
(put {:ch ch :msg-meta msg-meta :payload payload})] | |
(lc/subscribe ch qname message-handler :auto-ack true)) | |
message-seq) |
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
(defun read-listcomp (stream char) | |
(declare (ignore char)) | |
(let (rezs srcs conds state) | |
(dolist (item (read-delimited-list #\} stream)) | |
(if (eql '|| item) | |
(setf state (if state :cond :src)) | |
(case state | |
(:src (push item srcs)) | |
(:cond (push item conds)) | |
(otherwise (push item rezs))))) |
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
(in-package :actor) | |
(defparameter *current-process* (make-process :background nil)) | |
(define-symbol-macro self *current-process*) | |
;; fork | |
(defun fork-impl (fn) | |
(let ((proc (make-process))) | |
(execute-fork-fn fn proc) ; forkしたプロセスを実行する | |
proc)) |