View ListNode.java
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
package yannick.haxl; | |
import java.util.List; | |
import java.util.stream.Collectors; | |
import lombok.Value; | |
@Value | |
public class ListNode<T> implements Node<List<T>> { | |
List<Node<T>> elements; |
View user.clj
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 user | |
(:require [rewrite-clj.zip :as z] | |
[rewrite-clj.node :as n])) | |
(defn token= | |
[loc v] | |
(and (= :token (z/tag loc)) | |
(= v (z/sexpr loc)))) | |
(defn fact? |
View ast_spec.clj
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 AST consists of declarations and calls. | |
(s/def :lang/ast | |
(s/keys :req [:lang/declarations :lang/calls])) | |
;; Throughout, we'll use variables/calls identified by their name. | |
(s/def :lang/name | |
(s/and string? #(re-matches #"[a-z]+" %))) | |
(s/def :lang/variable-name | |
:lang/name) |
View restricted_spec.clj
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
(s/def ::element | |
integer?) | |
(s/def ::list | |
(s/coll-of ::element)) | |
(s/def ::map | |
(s/keys :req [::list])) | |
;; I'd like to make the '::map' spec more restrictive, i.e. only accept a |
View benchmark.patch
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
From a74d2f6d2337d28a97d48aeb06299269bac6354d Mon Sep 17 00:00:00 2001 | |
From: Yannick Scherer <yannick.scherer@stylefruits.de> | |
Date: Sun, 31 Aug 2014 15:51:53 +0200 | |
Subject: [PATCH] benchmark adjustments. | |
--- | |
src/main/bench/pjson/parse_bench.clj | 37 +++++++++++++++++------------------- | |
1 file changed, 17 insertions(+), 20 deletions(-) | |
diff --git a/src/main/bench/pjson/parse_bench.clj b/src/main/bench/pjson/parse_bench.clj |
View fast_zip_utils.clj
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 fast-zip-utils | |
(:require [fast-zip.core :as z]) | |
(:import [fast_zip.core ZipperPath ZipperLocation])) | |
(defn remove-right | |
"Remove right sibling of the current node (if there is one)." | |
[^ZipperLocation zloc] | |
(let [path ^ZipperPath (.path zloc)] | |
(if (zero? (count (.r path))) | |
zloc |
View base64.clj
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 ^{ :doc "Base64 Encoding/Decoding in Clojure" | |
:author "Yannick Scherer" } | |
base64) | |
;; ## Conversion Functions | |
(def ^:private base64-chars | |
"Base64 Characters in the right order." | |
(vec | |
(concat |
View repl.clj
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
;; Processor | |
(import '(org.example Person PersonIndex PersonIndex$Processor | |
PersonIndex$Client PersonIndex$Iface)) | |
(def person-index-processor | |
(PersonIndex$Processor. | |
(proxy [PersonIndex$Iface] [] | |
(store [p] | |
(println "Storing Person:") |
View kasumi.hs
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
module Kasumi where | |
import Data.Bits | |
import Data.List | |
import Data.Word | |
-- Helpers | |
rol16 x 0 = x | |
rol16 x n = 0xFFFF .&. ((shiftL x n) .|. (shiftR x (16 - n))) |
View main.clj
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 character-counter.main) | |
;; ------------------------------------------------------------------------ | |
;; | |
;; SEE HERE: http://dev.xscheme.de/2012/11/counting-characters-in-clojure/ | |
;; | |
;; ------------------------------------------------------------------------ | |
;; Different Count Strategies | |
(def count-a-with-regex |