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 map-indexed | |
"Returns a lazy sequence consisting of the result of applying f to 0 | |
and the first item of coll, followed by applying f to 1 and the second | |
item in coll, etc, until coll is exhausted. Thus function f should | |
accept 2 arguments, index and item." | |
{:added "1.2"} | |
([f coll] (map-indexed f 0 1 coll)) | |
([f start coll] (map-indexed f start 1 coll)) | |
([f start step coll] | |
(letfn [(mapi [idx coll] |
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 map-indexed | |
"Returns a lazy sequence consisting of the result of applying f to 0 | |
and the first item of coll, followed by applying f to 1 and the second | |
item in coll, etc, until coll is exhausted. Thus function f should | |
accept 2 arguments, index and item." | |
{:added "1.2"} | |
([f coll] (map-indexed f 0 coll)) | |
([f start coll] | |
(letfn [(mapi [idx coll] | |
(lazy-seq |
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 topoged.model.type | |
(:import | |
(javax.persistence Entity Id Column Table GeneratedValue) | |
)) | |
(definterface IType (getId [])) | |
(deftype | |
^{Entity {} Table {:name="TYPE"} org.hibernate.annotations.Entity {:mutable false}} | |
TypeX [^Long id] |
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 digit-seq | |
"Convert a number into a lazy sequence of digits as (digit-seq 1798) => (1 7 9 8)" | |
[num] (map #(- (int %) (int \0)) (str num))) |
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 long-to-bytes | |
"convert a long into a sequence of 8 bytes. The zeroes are padded to the | |
beginning to make the BigInteger contructor happy" [^long lng] | |
(let [pad (repeat 8 (byte 0)) | |
bytes (map byte (.. (BigInteger/valueOf lng) toByteArray))] | |
(concat (drop (count bytes) pad) bytes))) |
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
(defprotocol Hexl | |
(hexl-hex [val]) | |
(hexl-char [char])) | |
(extend-type Number | |
Hexl | |
(hexl-hex [i] | |
(let [rtnval (Integer/toHexString (if (< i 0) (+ 256 i) i)) ] | |
(if (< (count rtnval) 2) (str "0" rtnval) rtnval))) | |
(hexl-char [b] |
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
(with-session [session _] | |
(let [iter (.. session (createQuery "from Event") iterate)] | |
(iterator-seq iter))) |
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
(with-session [session _] | |
(let [iter (.. session (createQuery "from Event") iterate)] | |
(for [row (iterator-seq iter)] | |
(process-data row))))) |
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 gist.multipartmime-zip | |
(:require [clojure.zip :as zip]) | |
(:import [javax.mail.util ByteArrayDataSource] | |
[javax.mail.internet MimeMultipart])) | |
(defn multipart? [part] | |
(.startsWith (.getContentType part) "multipart")) | |
(defn zip-children [mime-multi-part] | |
(let [count (.getCount mime-multi-part)] |
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 vec+ | |
([] nil) | |
([v1] v1) | |
([v1 v2] | |
(let [c1 (count v1) | |
c2 (count v2) | |
seq (if (< c1 c2) | |
(map + (concat v1 (repeat 0)) v2) | |
(map + (concat v2 (repeat 0)) v1))] | |
(vec seq))) |
OlderNewer