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 marksto.lang; | |
import java.math.BigInteger; | |
import java.util.stream.Stream; | |
public class TailCallJava8 { | |
@FunctionalInterface | |
public interface TailCall<T> { |
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 marksto.lang; | |
import java.util.UUID; | |
public class GeneralizedBiDiList { | |
static class Node { | |
String listId; | |
int value; | |
Node next; |
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 marksto.algorithms; | |
import org.openjdk.jmh.annotations.Benchmark; | |
import org.openjdk.jmh.annotations.Mode; | |
import org.openjdk.jmh.runner.Runner; | |
import org.openjdk.jmh.runner.options.Options; | |
import org.openjdk.jmh.runner.options.OptionsBuilder; | |
import org.openjdk.jmh.runner.options.TimeValue; | |
import java.util.HashMap; |
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
private static class RecursiveBrickPileSolver extends BrickPileSolver { | |
// NOTE: The 'ConcurrentHashMap' implementation should be used instead | |
// in case this object is to be shared between multiple threads. | |
final Map<Integer, double[]> cache = new HashMap<>(); | |
public RecursiveBrickPileSolver(double brickMass) { | |
super(brickMass); | |
} |
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
{:debug {:debug true | |
:dependencies [[org.clojure/tools.namespace "0.2.11"] | |
[clj-commons/spyscope "0.1.48"]] | |
:injections [(require '(clojure.tools.namespace repl find)) | |
; try/catch to workaround an issue where `lein repl` outside a project dir | |
; will not load reader literal definitions correctly: | |
(try (require '[spyscope.core :as spy]) | |
(catch RuntimeException e)) | |
(prn (into {} (System/getProperties)))]} | |
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 my-cljs.macros.debug | |
(:require [cljs.analyzer :as cljs] | |
clojure.walk)) | |
(declare ap | |
cljs-macroexpand* | |
cljs-macroexpand-1* | |
cljs-macroexpand-all* | |
cljs-macroexpand |
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 fizz-buzz | |
"Approaching the infamous 'FizzBuzz' code problem with cyclic sequences and declarative rules") | |
;; SOLUTION | |
;; Core ideas: | |
;; 1. Note that the logic is essentially sequential and cyclical. | |
;; 2. Delay the actual computation (execution) by opting for lazy sequences. | |
;; 3. Separate control flow and logic, extracting the latter into a ruleset data structure. |