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 morel.core | |
(:import (com.oracle.truffle.api.nodes RootNode NodeInfo Node$Child)) | |
(:require [clojure.interop :refer [defclass]] | |
[clojure.reflect :as reflect])) | |
(defclass | |
^{NodeInfo {:language "SL" | |
:description "The root of all SL execution trees"}} | |
SLRootNode [language | |
frame-descriptor |
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
(def ^:dynamic *counters*) | |
(defn new-counter [name] | |
"Creates a pair of LongAdders" | |
...) | |
(defn get-counter [name] | |
(if-let [ctr (get *counter* name] | |
ctr |
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
;;; | |
(->> actors | |
(map (partial get-data server-pool)) | |
(filter #(> (:age %) 42)) | |
(map :name) | |
set) | |
(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
(defn unordered-pmap [threads f in-c out-c] | |
(let [remain (atom threads)] | |
(dotimes [x threads] | |
(go-loop [] | |
(if-some [v (<! in-c)] | |
(do (>! out-c (f v)) | |
(recur)) |
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
(def data {:cards | |
[{:id "card-1", :idList "list-id-1", :name "Task 1"}], | |
:lists | |
[{:id "list-id-1", :name "List 1"} | |
{:id "list-id-2", :name "List 2"}]}) | |
(vec (o/for-query | |
(o/and | |
(d/query-in data _ [:lists _] ?list-item) | |
(d/query data ?list-item :id ?list-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
;; On my box, wc processes the 11GB JSON file in 50sec | |
;; This code does it in 11sec | |
;; Compiled with lein uberjar, and run with java -server -jar word-count-STANDALONE.jar | |
(ns word-count.core | |
(:import (java.io RandomAccessFile File) | |
(java.nio.channels FileChannel$MapMode) | |
(java.nio ByteBuffer)) | |
(:gen-class)) |
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 my-dsl-fn | |
([mp] | |
... do stuff with map ... | |
([k v & {:as mp}] | |
(my-dsl-fn (assoc mp 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
The question was asked why I (as a programmer who prefers dynamic languages) don't consider static types "worth it". Here | |
is a short list of what I would need from a type system for it to be truely useful to me: | |
1) Full type inference. I would really prefer to be able to write: | |
(defn concat-names [person] | |
(assoc person :full-name (str (:first-name person) | |
(:second-name person)))) | |
And have the compiler know that whatever type required and produced from this function was acceptible as long as the |
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 other-examples.shapes-3d | |
(:require [fn-fx.fx-dom :as dom] | |
[fn-fx.diff :refer [component defui render should-update?]] | |
[fn-fx.controls :as ui])) | |
(def red (ui/color :red 1 :blue 0 :green 0)) | |
(def green (ui/color :red 0 :blue 0 :green 1)) | |
(def blue (ui/color :red 0 :blue 1 :green 0)) | |
(def grey (ui/color :red 0.5 :blue 0.5 :green 0.5)) |
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 other-examples.shapes-3d | |
(:require [fn-fx.fx-dom :as dom] | |
[fn-fx.diff :refer [component defui render should-update?]] | |
[fn-fx.controls :as ui])) | |
(def red (ui/color :red 1 :blue 0 :green 0)) | |
(def green (ui/color :red 0 :blue 0 :green 1)) | |
(def blue (ui/color :red 0 :blue 1 :green 0)) | |
(def grey (ui/color :red 0.5 :blue 0.5 :green 0.5)) |