Created
November 13, 2017 22:31
-
-
Save chbrown/1be326463368d856517f54cd635840c2 to your computer and use it in GitHub Desktop.
tools.trace-example
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 main) | |
(defonce ^:private counter (atom 0)) | |
(defn- interleave-with-reversed [s] | |
(interleave s (reverse s))) | |
(defn frobnicate [user] | |
(apply str (interleave-with-reversed user))) | |
(defn print-frobnicated [user] | |
(println (frobnicate user)) | |
(swap! counter inc)) |
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
(defproject trace-example "0.1.0-SNAPSHOT" | |
:description "A test project for tools.trace" | |
:license {:name "Eclipse Public License" | |
:url "http://www.eclipse.org/legal/epl-v10.html"} | |
:dependencies [[org.clojure/clojure "1.8.0"]] | |
:profiles {:dev {:source-paths ["dev"] | |
:dependencies [[org.clojure/tools.trace "0.7.9"]] | |
:repl-options {:init-ns user}}}) |
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 user | |
(:require [clojure.tools.trace :as trace] | |
[main])) | |
(main/frobnicate "Giorgio") | |
;=> "GoiiogrrgoiioG" | |
(main/print-frobnicated "Giorgio") | |
;=> "GoiiogrrgoiioG" | |
;=> 1 | |
;; set up tracing on the "main" namespace | |
;; see https://clojure.github.io/tools.trace/ for tools.trace docs | |
(trace/trace-ns 'main) | |
(main/frobnicate "Giorgio") | |
;=> TRACE t3169: (main/frobnicate "Giorgio") | |
;=> TRACE t3170: | (main/interleave-with-reversed "Giorgio") | |
;=> TRACE t3170: | => (\G \o \i \i \o \g \r \r \g \o \i \i \o \G) | |
;=> TRACE t3169: => "GoiiogrrgoiioG" | |
;=> "GoiiogrrgoiioG" | |
(main/print-frobnicated "Giorgio") | |
;=> TRACE t3173: (main/print-frobnicated "Giorgio") | |
;=> TRACE t3174: | (main/frobnicate "Giorgio") | |
;=> TRACE t3175: | | (main/interleave-with-reversed "Giorgio") | |
;=> TRACE t3175: | | => (\G \o \i \i \o \g \r \r \g \o \i \i \o \G) | |
;=> TRACE t3174: | => "GoiiogrrgoiioG" | |
;=> GoiiogrrgoiioG | |
;=> TRACE t3173: => 2 | |
;=> 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment