Klipse

Lets create some code with klipse

 
(def john {:firstname "John" :lastname "Stevenson"})
(:firstname john)
x
 
the evaluation will appear here (soon)...

Code is styled with style/website.css inline with single backtick marks as in the following code (+ 1 2 3).

And code can be shown without klipse using the usual triple backtick and optional name of the programming language


(+ 1 2 3)

And code in an earlier part of the page in Klipse should be available in latter klipse sections

 
john
 
the evaluation will appear here (soon)...

Can we hide klipse away from prying eyes

Reveal answer...
(str "fixed code answers that can be copied into klipse")

Lets use a gist with klipse - collapse false

Reveal answer...
 
;loaded from gist: https://gist.github.com/viebel/8cb19d258fea39a64146721ce50603d0
(require '[cljs.tools.reader :as r])
(require '[cljs.tools.reader.reader-types :as rt])
(defn read-several-exps [s]
  (let [sentinel (js-obj)
        reader (rt/string-push-back-reader s)]
    (loop [res []]
      (let [exp (r/read reader false sentinel)]
        (if (= exp sentinel)
          res
          (recur (conj res exp)))))))
(read-several-exps "(+ ::a 2) #_(+ 3 4) #:foo{:a 'bb} ")
 
the evaluation will appear here (soon)...

collapse true

Reveal answer...
 
;loaded from gist: https://gist.github.com/viebel/8cb19d258fea39a64146721ce50603d0
(require '[cljs.tools.reader :as r])
(require '[cljs.tools.reader.reader-types :as rt])
(defn read-several-exps [s]
  (let [sentinel (js-obj)
        reader (rt/string-push-back-reader s)]
    (loop [res []]
      (let [exp (r/read reader false sentinel)]
        (if (= exp sentinel)
          res
          (recur (conj res exp)))))))
(read-several-exps "(+ ::a 2) #_(+ 3 4) #:foo{:a 'bb} ")
 
the evaluation will appear here (soon)...

App idea: simple app that tracks how many times I mistakenly used defn instead of def or vice versa

results matching ""

    No results matching ""