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 foo.core | |
(:require [ring.adapter.jetty :as jetty])) | |
(defn add-connection-middleware [handler uri] | |
(fn [req] | |
(let [connection (mg/connect-via-uri uri)] | |
(handler (assoc req :connection connection))))) | |
(defn handler [{:key [connection] :as request}] | |
{:status 200 |
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
// så vi har et array med tall, og vi skal legge de sammen. | |
const numbers = [1, 2, 4, 10]; | |
// den måten man kanskje lærer først, som vi gikk gjennom på tavla er noe sånt: | |
let summedNums = 0; | |
for (i = 0; i< numbers.length; i++) { | |
summedNums = summedNums + numbers[i]; | |
} |
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 src.core) | |
(def regex #"(\d+(?:\.\d+)?)|([().^*\/+-])") | |
(def presedence {'+ 1 | |
'- 1 | |
'* 2 | |
'/ 2}) | |
(defn tokenize [expr] |
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 area2 | |
(:require | |
[clojure.math :as math] | |
[criterium.core :as crit])) | |
(set! *warn-on-reflection* true) | |
(set! *unchecked-math* false) | |
(defprotocol IArea | |
(area [this])) | |
(require '[clj-java-decompiler.core :refer [decompile]]) | |
(decompile |
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 area3 | |
(:require | |
[clojure.math :as math] | |
[criterium.core :as crit])) | |
(set! *warn-on-reflection* true) | |
(set! *unchecked-math* false) | |
(definterface IArea2 | |
(^double area [])) |
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
;; json-mode | |
(use-package json-mode | |
:ensure t) | |
(use-package web-mode | |
:ensure t | |
:mode (("\\.js\\'" . web-mode) | |
("\\.jsx\\'" . web-mode) | |
("\\.ts\\'" . web-mode) | |
("\\.tsx\\'" . web-mode) |
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
(defn baz [z] | |
... | |
(foobar æ)) | |
(defn bar [y] | |
... | |
(baz z)) | |
(defn foo [x] | |
... |
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
;; https://github.com/niklas-heer/speed-comparison/tree/master | |
;; Decompilation provided by clj-java-decompiler | |
(defn calc-pi-leibniz | |
"Translation of Java solution to Clojure" | |
[^long rounds] | |
(let [end (+ 2 rounds)] | |
(loop [i 2 x 1.0 pi 1.0] | |
(if (= i end) | |
(* 4 pi) |
OlderNewer