This file contains 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
;;;; transducer parser | |
;; channel that parses input bytes into utf8 chars | |
(def c (chan 10 (parse utf8))) | |
;;=> #'foo.baz/c | |
;; vector of utf8 encoded characters | |
(def v [-16 -99 -109 -105 -16 -99 -109 -82 -16 -99 -109 -75 -16 -99 -109 -75 -16 -99 -109 -72 32 -16 -99 -108 -128 -16 -99 -109 -72 -16 -99 -109 -69 -16 -99 -109 -75 -16 -99 -109 -83]) | |
;;=> #'foo.baz/v |
This file contains 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 set-window-width (n) | |
"Set the selected window's width." | |
(adjust-window-trailing-edge (selected-window) (- n (window-width)) t)) | |
(defun set-70-columns () | |
"Set the selected window to 80 columns." | |
(interactive) | |
(set-window-width 70)) | |
(global-set-key "\C-x`" 'set-70-columns) |
This file contains 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 foo.core | |
(:api dunaj) | |
(:require [dunaj.host.int :refer [i== iDOT]] | |
[dunaj.host.array :as dha] | |
[dunaj.format.base64 :refer [base64-safe]] | |
[dunaj.coll.recipe :refer [concat*]] | |
[dunaj.concurrent.port :refer [reduce! onto-chan!]])) | |
(def+ ByteColl [java.lang.Byte]) ;; type signature |
This file contains 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 lazy-seq* [reducible] | |
(let [c (chan) | |
NIL (Object.) | |
encode-nil #(if (nil? %) NIL %) | |
decode-nil #(if (identical? NIL %) nil %) | |
reduce-fn (fn [r v] (>!! c (encode-nil v)))] | |
(thread | |
(reduce reduce-fn nil reducible) | |
(close! c)) | |
(->> #(<!! c) |
This file contains 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
;; machine: amd64 Linux 2.6.32-48-server 16 cpu(s) | |
;; Java HotSpot(TM) 64-Bit Server VM 23.25-b01 | |
;; | |
;; == without lazy seq realization | |
;; regex split: 258.567183 ms | |
;; parallelized regex split: 65.053176 ms - lazy seqs are not realized! | |
;; correct reduce: 623.541446 ms | |
;; correct fold: 252.817020 ms | |
;; | |
;; == lazy seq realization with (into [] %) |
This file contains 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
// original | |
int CheckExtension (char *filename, char *ext) | |
{ | |
char *s; | |
if (!filename) return(0); | |
if (strlen(filename) == 0) return(0); | |
s = strrchr(filename,'.'); | |
if (!s) return(0); | |
if (!strcmp(s,ext)) return(1); |
This file contains 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 '[clojure.java.io :as jio]) | |
(deftype Slurp [filename] | |
clojure.core.protocols/CollReduce | |
(coll-reduce [this f1] | |
(clojure.core.protocols/coll-reduce this f1 (f1))) | |
(coll-reduce [_ f1 init] | |
(with-open [#^java.io.Reader r | |
(apply jio/reader filename nil)] | |
(loop [ret init |
This file contains 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
Type Error (user:1:5) Polymorphic function clojure.core/merge could not be applied to arguments: | |
Polymorphic Variables: | |
k36143 | |
v36144 | |
Domains: | |
nil * | |
(clojure.lang.IPersistentMap k v) (clojure.lang.IPersistentMap k v) * | |
(Option (clojure.lang.IPersistentMap k v)) * |
This file contains 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
;; AOT before loading (e.g. with :aot :all in project.clj) | |
;; $ lein deps :tree | |
;; [clojure-complete "0.2.3" :exclusions [[org.clojure/clojure]]] | |
;; [org.clojure/clojure "1.5.1"] | |
;; [org.clojure/tools.nrepl "0.2.3" :exclusions [[org.clojure/clojure]]] | |
(ns ccc.core | |
(:gen-class)) | |
(defprotocol P) |
This file contains 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
(add-hook 'before-save-hook | |
(lambda () | |
(whitespace-cleanup) | |
(delete-trailing-whitespace))) |