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
(import javafx.beans.Observable | |
javafx.beans.binding.ObjectBinding) | |
;; javafx.beans.binding.ObjectBinding#bind() を見えるようにする為だけの継承クラス | |
(gen-class | |
:name "cljfx.binding.ObjectBinding" | |
:extends javafx.beans.binding.ObjectBinding | |
:exposes-methods {bind bindAll}) | |
(defmacro make-bindings |
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
;; http://docs.oracle.com/javase/8/javafx/properties-binding-tutorial/binding.htm#JFXBD107 | |
;; の Example 1-7 Using the Low-Level API のサンプルを Clojure REPL で動くように書いてみた | |
(import javafx.beans.binding.DoubleBinding | |
javafx.beans.property.SimpleDoubleProperty) | |
(def a (SimpleDoubleProperty. 1)) | |
(def b (SimpleDoubleProperty. 2)) | |
(def c (SimpleDoubleProperty. 3)) | |
(def d (SimpleDoubleProperty. 4)) |
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
(require '[clojure.core.memoize :as memo]) ; もちろんここは一度きり | |
(def func-a-lrufn (memo/lru (fn [some-params] (some-proc some-params)))) | |
(defn func-a | |
[some-params] | |
(func-a-lrufn some-params)) | |
(defmacro defn-lru | |
[name [& params*] threshold-val & body] ;; <- ん? | |
(let [private-fn (symbol (str name "-lrufn"))] |
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
;; cannot apply to 4Clojure answer. | |
(fn uce | |
[expr] | |
(fn [m] (eval (clojure.walk/postwalk-replace m expr)))) |
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
(defprotocol IEditName | |
(get-name [this]) | |
(set-name! [this val])) | |
(deftype PersonName [^:volatile-mutable lname] | |
IEditName | |
(get-name [this] (. this lname)) | |
(set-name! [this val] (set! lname val))) | |
(def pname (PersonName. "hoge")) |
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
;; This answer cannot use in 4Clojure | |
(use 'clojure.zip) | |
(fn binary-tree? [root] | |
(let [zp (zipper coll? rest (fn [n c] c) root)] | |
(->> (take-while (complement end?) (iterate next zp)) | |
(filter branch?) | |
(every? #(= (count (children %)) 2))))) |