This file contains hidden or 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
(import '[java.security SecureRandom Key] | |
'[javax.crypto KeyGenerator Cipher] | |
'[javax.crypto.spec IvParameterSpec] | |
'[java.security.spec AlgorithmParameterSpec]) | |
(defn ^bytes rand-bytes [n] | |
(let [b (byte-array n)] | |
(.. (SecureRandom.) (nextBytes b)) | |
b)) |
This file contains hidden or 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 basic; | |
import java.util.function.*; | |
public class Init { | |
Init(){ | |
p("constructor"); | |
} | |
int i = ((IntSupplier)(() -> { p("field1"); return 0; })).getAsInt(); | |
{ |
This file contains hidden or 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 basic; | |
import java.util.LinkedHashMap; | |
import java.util.Map; | |
import java.util.stream.IntStream; | |
public class FizzBuzz { | |
public static void main(String... args){ | |
Map<Integer, String> map = new LinkedHashMap<>(); | |
map.put(15, "FizzBuzz"); |
This file contains hidden or 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
(type {}) | |
(type {1 1}) | |
(type {1 1 2 2 3 3 4 4 5 5 6 6 7 7}) | |
(type {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8}) | |
(type {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9}) | |
(type (assoc {1 1 2 2 3 3 4 4 5 5 6 6 7 7} 8 8)) | |
(type (assoc {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8} 9 9)) | |
(type (assoc {1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9} 10 10)) |
This file contains hidden or 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
(with-local-vars [x (promise) | |
y (future-call (fn [] x)) | |
z (reify clojure.lang.IDeref (deref [this] y))] | |
(deliver x (-> 9 ref atom agent delay future reduced)) | |
(str @@@@@@@@@@@@z)) |
This file contains hidden or 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
(apply #(println %1 %-1 %2 %&) (range 10)) |
This file contains hidden or 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 classzu.core | |
(:require [dorothy.core :refer :all] | |
[clojure.set :as set] | |
[clojure.walk :as walk])) | |
(defn show-diagram [& class-defs] | |
(->> (for [[class extends & implements] class-defs] | |
(concat [class] | |
(when extends [[class extends]]) | |
(map (fn [i] [class i {:style :dashed}]) implements))) |
This file contains hidden or 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 sample.core | |
(:require [lt.object :as o]) | |
(:require-macros [lt.macros :as m])) |
This file contains hidden or 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
Elapsed time: 0.007123 msecs | |
Elapsed time: 0.005308 msecs | |
Elapsed time: 0.003352 msecs | |
Elapsed time: 191.406869 msecs | |
Elapsed time: 129.120391 msecs | |
Elapsed time: 77.368283 msecs | |
Elapsed time: 243.091859 msecs | |
Elapsed time: 0.006216 msecs | |
Elapsed time: 29.659985 msecs | |
Elapsed time: 0.093308 msecs |
This file contains hidden or 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
static <T> Stream<T> cycle(T t0, T... ts){ | |
return Stream.generate(new Supplier<T>() { | |
int index = -1; | |
@Override | |
public T get() { | |
index = (index + 1) % (ts.length + 1); | |
if(index == 0){ | |
return t0; | |
} | |
return ts[index - 1]; |