This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-04-21
Channels
- # aws (1)
- # aws-lambda (1)
- # beginners (27)
- # boot (16)
- # cider (1)
- # clara (54)
- # cljs-dev (4)
- # cljsjs (8)
- # cljsrn (25)
- # clojure (148)
- # clojure-dev (2)
- # clojure-finland (1)
- # clojure-france (18)
- # clojure-italy (10)
- # clojure-nl (3)
- # clojure-russia (27)
- # clojure-sg (2)
- # clojure-uk (17)
- # clojurebridge (6)
- # clojurescript (70)
- # core-async (1)
- # css (6)
- # cursive (35)
- # data-science (3)
- # datomic (22)
- # events (4)
- # jobs (18)
- # jobs-discuss (14)
- # leiningen (4)
- # lumo (22)
- # off-topic (20)
- # om (5)
- # om-next (1)
- # onyx (47)
- # pedestal (107)
- # re-frame (43)
- # reagent (1)
- # ring (2)
- # ring-swagger (2)
- # rum (18)
- # sql (15)
- # unrepl (4)
- # vim (61)
- # yada (3)
I am using chestnut template and I am always restarting the repl and (run). There should be a better way!?!
@timok the new version of chestnut will be based on component, which will make it easier to reload everything from the repl. You can already try it with lein new chestnut your_project --snapshot
.
I used the nimbus jose/jwt java library to validate tokens and wrote my own http and state interactions; nothing canned seemed even a little bit worth the integration hassle tbqh
i want to turn [["this" "is" "one"] ["this" "is" "two"]]
into [{:value "this" :idx 0 :line-no 0 :is-eol false} {:value "is" :idx 1 :line-no 0 :is-eol false} {:value "1" :idx 2 :line-no 0 :is-eol true} {:value "this" :idx 0 :line-no 1 :is-eol false} {:value "is" :idx 1 :line-no 1 :is-eol false} {:value "two" :idx 2 :line-no 1 :is-eol true}]
map-indexed
is probably a good thing to look at
(defn split-lyrics [lyrics]
(map #(split % #"\s") (split lyrics #"\n")))
(defn- make-token [tkn line ix is-eol]
{:value tkn :line-no line :idx ix :is-eol is-eol})
(defn parse-tokens [lines]
(loop [[[t & ts] & ls] lines line-no 0 ix 0 parsed []]
(let [is-eol (empty? ts)
prsed (conj parsed (make-token t line-no ix is-eol))]
(if (empty? ls)
(if is-eol
prsed
(recur [ts] line-no (inc ix) prsed))
(if is-eol
(recur ls (inc line-no) 0 prsed)
(recur (into [ts] ls) line-no (inc ix) prsed))))))
if i used map-indexed
i’d still have to do something like (let [is-eol (= (dec (count line)) ix)]
A for loop might sort you then
I think calling for a loop is just confusing things
(for [line-no (range (count lines))
idx (range (count (nth lines line-no)))]
(let [line (nth lines line-no)
value (nth line idx)
is-eol (= idx (dec (count line)))]
{:value value :line-no line-no :idx idx :is-eol is-eol}))
I’m trying to split large XML files on a specific element and then save them as individual files. The splitting part I’ve taken care of, and I have to name them based on the content of the XML, so that’s not hard either. The extra little wrinkle that got added at the last minute, though, was that I also have to write a list of the filenames to the same directory. What strategy would you use for this? The line doing all the work is (doall (map write-file (split-xml input-filename)))
, so I was thinking of making write-file return the filename to be written while actually writing the file as a side effect. But I’m not a huge fan of that approach.
My idea was to return filename
from write-file
and then use that somehow, but I’m stuck on just what to do from here.
@jcronk If I understand correctly these are two different things here and I would solve them sequentially. 1. Split and store them in individual files 2. Traverse the folder, collect the file names and write them to whereever you need them.
I was wondering about that. I’m not 100% sure that my files will be the only ones there, but I guess in that case I could get a list of what’s there first, then a list after I write the files, then use the difference between the two lists?