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
// Small (incomplete) implementation of a trie map with focusing capabilities. | |
// Nice for (exact) autocomplete matching. Example usage in main function at the top. | |
#![feature(box_syntax)] | |
#![allow(unstable)] | |
use std::mem; | |
use std::collections::dlist::DList; | |
use std::cmp::Ordering::{Less, Equal, Greater}; | |
fn main() { |
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 I #([%](+))) | |
(def K (-> (->> $ #(:- %)) (->> #() (-> [$])))) | |
(def S (-> (->> ((! $) (? $)) #() (-> [$])) (->> #() (-> [?]) #() (-> [!])))) |
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
;; I'm hitting my head against a wall trying to implement the Y Combinator in SKI in Clojure | |
;; Anyone with experience implementing it, or is able to detect what's wrong here? | |
(defn I [x] x) | |
#_=> #'user/I | |
(def K (fn [x] (fn [y] x))) | |
#_=> #'user/K | |
(def S (fn [x] (fn [y] (fn [z] ((x z)(y z)))))) | |
#_=> #'user/S | |
;; The culprit: |
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
@echo off | |
setLocal EnableExtensions EnableDelayedExpansion | |
set LEIN_VERSION=2.5.1 | |
if "%LEIN_VERSION:~-9%" == "-SNAPSHOT" ( | |
set SNAPSHOT=YES | |
) else ( | |
set SNAPSHOT=NO |
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
## This is not an optimised persistent vector, just an implementation "straight | |
## off" http://hypirion.com/thesis.pdf. However, compared to Clojure's | |
## persistent vector, it is interesting in that this implementation | |
## | |
## - has O(n) runtime on iteration/reduce and map | |
## -> Clojure's implementations run in O(n log n) time | |
## - has submap and subiterators that runs in O(min(log n, m)) time, | |
## where m is the amount of elements to walk over | |
## -> Clojure doesn't support submap, although has subiterator indirectly | |
## through subvec, which runs in O(min(log n, m log n)) time |
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
jeannikl@Madonna of the Wasps ~/leiningen master ● git rev-parse HEAD | |
d701275464c185f4f22be58450b1af4b94a79836 | |
jeannikl@Madonna of the Wasps ~/leiningen master ● cd leiningen-core | |
jeannikl@Madonna of the Wasps ~/leiningen/leiningen-core master lein version | |
Leiningen 2.5.3 on Java 1.8.0_66-internal OpenJDK 64-Bit Server VM | |
jeannikl@Madonna of the Wasps ~/leiningen/leiningen-core master lein bootstrap | |
Created /home/jeannikl/leiningen/leiningen-core/target/leiningen-core-2.6.0-SNAPSHOT.jar | |
Wrote /home/jeannikl/leiningen/leiningen-core/pom.xml | |
Installed jar and pom into local repo. | |
jeannikl@Madonna of the Wasps ~/leiningen/leiningen-core master ● cd .. |
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 lookup | |
"Lookup a variable in the model. Respects inversion of the variable if it is | |
specified with a - symbol. Returns nil if the variable is unset." | |
[[first-char :as var] model] | |
(if (= first-char \-) ; If the first character is '-' | |
(if-let [[_ val] (find model (subs var 1))] ; test for existence | |
(not val) ; invert value if exists | |
nil) ; otherwise return nil | |
(get model 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
(defmacro defsignal [name bindings out-path & body] | |
(let [state (gensym "state")] | |
`(defn ~name [~state] | |
(let [~@(mapcat (fn [[a b]] [a `(get-in ~state ~b)]) | |
(partition 2 bindings))] | |
(assoc-in ~state ~out-path (do ~@body)))))) |
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 merge-example | |
(:require [clojure.set :as set] | |
[fairbrook.path :as path] | |
[fairbrook.rule :as rule] | |
[fairbrook.meta :as meta] | |
[fairbrook.util :as u :refer [<<-]])) | |
(defn- displace? [obj] | |
(-> obj meta :displace)) |
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 meeting-times.core | |
(:refer-clojure :exclude [==]) | |
(:use clojure.core.logic | |
clojure.core.logic.protocols) | |
(:require [clojure.set :as set]) | |
(:gen-class)) | |
(defn sublists [list] | |
(take-while (comp pos? dec count) | |
(iterate rest list))) |
OlderNewer