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
SpaceShip ship = new BigSpaceShip(); | |
LauncherSystem launcher = new LauncherSystem(); | |
launcher.launch(ship); | |
class LauncherSystem{ | |
public void launch(SpaceShip ship){ | |
Launcher launcher = new Launcher(); | |
launcher.launch(ship); | |
} |
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
public class NeedVistorPattern { | |
public static void main(String[] args){ | |
SpaceShip ship = new BigSpaceShip(); | |
SpaceShipLauncher launcher = new SpaceShipLauncher(); | |
launcher.launch(ship); | |
} | |
private static class SpaceShipLauncher{ |
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 compojur-learning.core | |
(:use compojure.core)) | |
(defroutes handler | |
(GET "/" [] (println "middle") {:status 200})) | |
(def app (-> handler)) |
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 compojur-learning.core | |
(:use compojure.core)) | |
(defroutes handler | |
(GET "/" [] (println "middle") {:status 200})) | |
(defn logging [chain] (fn [req] ( | |
(println "before") | |
(chain req) | |
(println "after")))) |
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
before | |
Exception: java.lang.NullPointerException: null | |
core.clj:10 compojur-learning.core/logging[fn] | |
Var.java:401 clojure.lang.Var.invoke |
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
(defn logging [chain] (fn [req] | |
(println "before") | |
(chain req))) |
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
(defn logging [chain] (fn [req] | |
(println "before") | |
(try (chain req) (finally (println "after"))) | |
)) |
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 dijkstra.core) | |
(def edges {:A {:F 14 :C 9 :B 7} | |
:B {:A 7 :C 10 :D 15} | |
:C {:A 9 :B 10 :D 11 :F 2} | |
:D {:B 15 :C 11 :E 6} | |
:E {:D 6 :F 9} | |
:F {:A 14 :C 2 :E 9}}) | |
(def inf Integer/MAX_VALUE) |
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
(defn f [s p v] (filter #(s % p) v)) | |
(defn s [w] | |
(if-let [p (first w)] | |
(if-let [v (rest w)] | |
(concat (s (f < p v)) [p] (s (f >= p v))) | |
p) | |
() | |
)) | |
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
;; tc | |
(ns tron.bots | |
(:require [tron.core :as tron])) | |
;;bot func: tc | |
(defn empty-look | |
"A mock look function which just checks for the arena | |
boundaries." |
OlderNewer