Skip to content

Instantly share code, notes, and snippets.

View Oregu's full-sized avatar

Oleg Prophet Oregu

View GitHub Profile
@Oregu
Oregu / fib_num.clj
Last active August 29, 2015 14:05
fibo-with-olegs-nums
(ns musher.fib-num
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]
[musher.numbers]))
(defn noo [tag u]
(predc u (fn [x] (clojure.core/not= (if (coll? x) (first x) x) tag))))
(defn symbolo [x] (predc x symbol?))
(declare eval-expo)
@Oregu
Oregu / musher.clj
Last active August 29, 2015 14:04
miniKanren recursive interpreter
(ns musher.core
(:refer-clojure :exclude [==])
(:use [clojure.core.logic]
[clojure.pprint]))
(defn noo [tag u]
(predc u (fn [x] (clojure.core/not= (if (coll? x) (first x) x) tag))))
(defn symbolo [x] (predc x symbol?))
(defn numbero [x] (predc x number?))
@Oregu
Oregu / _.java
Last active August 29, 2015 14:02
Underscore java
/////////////////////////////////////////////////////
//
// Moved to repository:
// https://github.com/Oregu/_.java
//
/////////////////////////////////////////////////////
import java.util.function.BiFunction;
import java.util.function.Function;
@Oregu
Oregu / gist:7696491814560e7c94ea
Last active August 29, 2015 14:01
Reduce 2D collection in Java 8
Map<String, List<Field>> fieldmap = new HashMap<>();
fieldmap.put("f1", Arrays.asList(new Field("f_str"), new Field("f_abc")));
fieldmap.put("f2", Arrays.asList(new Field("f_int")));
// This is the best I came up with
List<String> names = fieldmap.values().stream().collect(
ArrayList<String>::new,
(l, fs) -> l.addAll(fs.stream().map(Field::getName).collect(toList())),
ArrayList<String>::addAll);