java version restriction has been lifted

This commit is contained in:
Sameer Rahmani 2020-01-02 17:59:27 +00:00
parent 9287dec83a
commit ade2cff99d
2 changed files with 37 additions and 8 deletions

View File

@ -1,3 +1,23 @@
(def reduce
(fn (f xs initial-value)
(cond
((first xs) (reduce f (rest xs) (f initial-value (first xs))))
(true initial-value))))
(def map
(fn (f xs)
(reduce (fn (acc x) (cons acc (f x))) xs (list))))
(def range-list
(fn (x y init)
(if (< y x)
(do
(conj (range-list x (+ y 1) init) y))
init)))
(def range
(fn (x)
(range-list x 0 (list))))
(def fib
(fn (n)
(if (< n 2)
@ -5,4 +25,20 @@
(+ (fib (- n 1))
(fib (- n 2))))))
(println (fib 10))
(def benchmark-fn
(fn (x)
(let ((start (now)))
(fib x)
(- (now) start))))
(def run-benchmark
(fn (times)
(map (fn (x)
(println "Benchmark: " x)
(println "Took: " (benchmark-fn 30)))
(range times))))
(run-benchmark 20)

View File

@ -50,13 +50,7 @@ public class Main {
"to redistribute it under certain conditions; \n" +
"for details take a look at the LICENSE file.\n";
private static void isJava8() throws RuntimeException {
if (System.getProperty("java.vm.specification.version").equals("1.8"))
throw new RuntimeException("Minimume required version of JDK is 1.8");
}
public static void main(String[] args) throws IOException, RuntimeException {
Main.isJava8();
if (args.length == 0) {
startRepl();
@ -75,7 +69,6 @@ public class Main {
while(true) {
String inputData = console.readLine("serene-> ");
//String inputData = "(fn (x) x)";
if (inputData == null) break;