@mfikes — a suggestion: it would be nice for scripting to have something like (slurp *in*)
@cvermilion: Seems like a reasonable thing to do. If you can brew
HEAD
I dropped some code supporting that in master.
Here is an example:
$ cat foo.cljs
(ns foo.core
(:require [planck.core :refer [slurp *in*]]
[<http://planck.io|planck.io>]))
(-> (slurp *in*)
count
println)
$ wc foo.cljs
7 13 122 foo.cljs
$ planck foo.cljs < foo.cljs
122
If you decide to brew
HEAD
, note the bit about brew edit planck
at http://planck-repl.org/setup.html
@cvermilion: Alternatively, you can fairly easily make an equivalent of (slurp *in*)
in Planck 1.15 based on read-line
:
(ns foo.core
(:require [clojure.string :as string]
[planck.core :refer [read-line]]))
(defn slurp-in []
(let [lines (atom [])]
(loop [line (read-line)]
(when line
(swap! lines conj line)
(recur (read-line))))
(string/join "\n" @lines)))
(-> (slurp-in)
count
println)
@mfikes: nice — thanks!