Skip to content

Instantly share code, notes, and snippets.

View bendisposto's full-sized avatar

Jens Bendisposto bendisposto

View GitHub Profile
@bendisposto
bendisposto / gist:b3049cc3c862e5a8544a
Created February 18, 2015 15:29
vl_5_2_2015 Teil4: Quickcheck
(ns repl.core
(:require [clojure.test.check :as tc]
[clojure.test.check.generators :as gen]
[clojure.test.check.properties :as prop]
[clojure.test :as t]))
;; Wichtig! Clojure 1.4 verwenden!
(comment
@bendisposto
bendisposto / gist:aadd0f87f61a45ecbb75
Created February 18, 2015 15:28
vl_5_2_2015 Teil3: Contracts/Schema
(ns dbc.core
(:require [schema.core :as s]))
(comment
(cons 3 [4 5])
(conj 3 [4 5])
;; ClassCastException ?!?
@bendisposto
bendisposto / gist:3a4698e46366637906fa
Created February 18, 2015 15:26
vl_5_2_2015 Teil2: Type Checking
(ns type.core
(:require [clojure.core.typed :as t]))
(defn anzahl [c]
(if-not (seq c)
0
(inc (anzahl (rest c)))))
(t/ann anzahl [(t/Seqable t/Any) -> t/Int])
@bendisposto
bendisposto / example_based_testing.clj
Created February 18, 2015 15:24
vl_5_2_2015 Teil1: Example based testing
(ns ebt.core
(:require [clojure.test :as t :refer [deftest is run-all-tests]]
[midje.sweet :as m :refer [tabular fact]]
[speclj.core :as s :refer [describe it should= run-specs]]))
(defn plus
"I am a bogus addition function"
[a b]
(if (= a b) (+ a b) (+ a a)))
(ns repl.core
(:use clojure.algo.monads))
(declare $assign $int $id $postinc $add $postinc $do'
m-assign m-int m-id m-postinc m-add m-do)
(comment
;; Monaden
(ns macros.core
(:use clojure.walk
[clojure.algo.monads]))
(defn my-read [foo]
(let [data (read-string foo)
result (try (eval data) (catch Throwable t (.getMessage t)))]
{:input foo
:read data
(ns repl.core
(:use clojure.repl))
(def x -3)
(defrecord Klausurergebnis [matrikel punkte note])
(comment
;; --- Wiederholung
(ns repl.core)
(defn new-thread [f] (.start (Thread. f)))
(comment
;; Keywords
:foo
::foo
@bendisposto
bendisposto / friendly_hello.clj
Created December 4, 2014 13:37
Code aus der Vorlesung vom 4.12.2014
(ns repl.greeter.friendly-hello
(:require [clojure.string :as str]))
(defn msg! [& args]
(println "Hello" (str/join " and " args)))
@bendisposto
bendisposto / vl_27_11_2014
Created December 1, 2014 06:21
Code aus der Vorlesung vom 27.11.2014
(ns repl.core)
(comment
;; recursion
(use 'clojure.tools.trace)
(deftrace ! [n]
(if (= 1 n)
n