This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-22
Channels
- # bangalore-clj (6)
- # beginners (110)
- # boot (49)
- # cider (13)
- # cljs-dev (35)
- # cljsrn (5)
- # clojure (145)
- # clojure-conj (3)
- # clojure-dev (60)
- # clojure-italy (2)
- # clojure-nl (3)
- # clojure-russia (3)
- # clojure-serbia (1)
- # clojure-spec (116)
- # clojure-uk (58)
- # clojurescript (235)
- # cursive (14)
- # datascript (7)
- # datomic (31)
- # dirac (144)
- # emacs (1)
- # events (1)
- # hoplon (12)
- # leiningen (11)
- # luminus (60)
- # lumo (19)
- # off-topic (18)
- # om (74)
- # onyx (5)
- # pedestal (13)
- # precept (3)
- # re-frame (3)
- # reagent (15)
- # remote-jobs (7)
- # ring-swagger (25)
- # rum (1)
- # untangled (53)
- # vim (3)
Is there something like a modern inetd
, which listens to a port and spawns a process connected to the tcp connection via stdin/stdout?
I'd like a variant that can be run from the command line, not as a daemon, and works on macos.
Like https://github.com/joewalnes/websocketd but for regular tcp connections
(reduce
(fn [acc [from to]]
(concat acc
(mapv char (range (int from) (inc (int to))))))
[]
[[\a \z][\A \Z][\0 \9]])
(\a \b \c \d \e \f \g \h \i \j \k \l \m \n \o \p \q \r \s \t \u \v \w \x \y \A \B \C \D \E \F \G \H \I \J \K \L \M \N \O \P \Q \R \S \T \U \V \W \X \Y \0 \1 \2 \3 \4 \5 \6 \7 \8)
(mapcat (fn [[from to]] (map char (range (int from) (inc (int to))))) [[\a \z][\A \Z][\0 \9]])
for some reason reduce feels more low-level (i.e. more general and more flexible) to me so I tend to avoid it when there's another function that seems more specialized to the task at hand
Using reduce with an accumulator is a pretty common pattern, I just had a thought if there ws a wrapper like:
(defn wtf
[f combiner coll]
(reduce
(fn [acc v]
(combiner acc (f v)))
coll))
so we can just do (in our case)
(wtf
(fn [[from to]]
(mapv char (range (int from) (inc (int to)))))
concat
[[\a \z][\A \Z][\0 \9]])
Well that's pretty much (defn wtf [coll combiner f] (->> coll (map f) (reduce combiner))))