Skip to content

Instantly share code, notes, and snippets.

(definterface ITak
(#^int tak [#^int x #^int y #^int z]))
(deftype Tak []
ITak
(tak [this x y z]
(if (>= y x)
z
(recur (.tak this (dec x) y z)
(.tak this (dec y) z x)
;sample use idea:
(defn mapx
"Returns a lazy sequence consisting of the result of applying f to the
set of first items of each coll, followed by applying f to the set
of second items in each coll, until any one of the colls is
exhausted. Any remaining items in other colls are ignored. Function
f should accept number-of-colls arguments."
[f coll]
(gen-iter iter [f seq-cell]
(defmacro gen-iter-fn
[name [op coll] has-item-body item-body move!-body]
`(defn ~name [~op ~coll]
(letfn
[(iter# [~op ~coll]
(reify :as ~'this
~'Iter
(~'has-item [] ~@has-item-body)
(~'item [] ~@item-body)
(~'move! [] ~@move!-body)
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(set! *warn-on-reflection* true)
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(set! *warn-on-reflection* true)
; Copyright (c) Rich Hickey. All rights reserved.
; The use and distribution terms for this software are covered by the
; Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
; which can be found in the file epl-v10.html at the root of this distribution.
; By using this software in any fashion, you are agreeing to be bound by
; the terms of this license.
; You must not remove this notice, or any other, from this software.
(set! *warn-on-reflection* true)
;variants of the code from point #2 of:
; http://www.tbray.org/ongoing/When/200x/2009/12/01/Clojure-Theses
;original
(apply merge-with +
(pmap count-lines
(partition-all *batch-size*
(line-seq (reader filename)))))
(reify
[ActionListener
(actionPerformed [this evt] ...)])
(deftype ::MyType [a b c]
[SeqableProtocol
(seq-me [this] (blah a c))]
[IBarInterface
(.bar [this that] (fred b))])