This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-03-06
Channels
- # admin-announcements (1)
- # aws (12)
- # beginners (35)
- # boot (12)
- # cider (32)
- # cljsrn (5)
- # clojars (10)
- # clojure (20)
- # clojure-russia (60)
- # clojurescript (229)
- # community-development (14)
- # cursive (9)
- # data-science (4)
- # datomic (3)
- # funcool (2)
- # hoplon (29)
- # jobs (15)
- # jobs-discuss (53)
- # keechma (2)
- # luminus (8)
- # om (42)
- # onyx (15)
- # parinfer (22)
- # re-frame (12)
- # reagent (162)
- # spacemacs (1)
What information would you need to reproduce the output/state of your application? There are lots of approaches to logging, but that's probably where you should start
I have a string of pre-defined size and what to split it based on a certain number or characters. Like a 10 character string and split it 5, 3, 2
so, did you want a function like f:
(f "applesauce" [2 5])
;;=> ["ap" "pples" "auce"]
if so you can do this:
(defn split-word [word splitters]
(let [splits (->> [(count word)]
(concat (reductions + (concat [0] splitters)))
(partition 2 1))]
(map (fn [[x y]] (subs word x y)) splits)))
(split-word "applesauce" [2 5])
;;=> ("ap" "plesa" "uce")
This is getting a stack overflow, and i've coded so much this week building something that my brain is so fried I can't think of an alternative.
(defn interpolate-series [f data]
(cond (< (count data) 2) data
:else (let [[a b & xs] data]
(concat
(interpolate-between-points f a b)
(interpolate-series f (cons b xs))))))
hey @base698- try 2 changes: * replace the let with (let [a (first data) b (second data)] * replace the last line with (lazy-seq (interpolate-series f (rest data)))
@base698 the termination condition should probably be (= (count data) 2), and should return interpolate-between-points of those 2 points?
@base698: what's your previous experience with FP languages.. you say your brain is hurting, is it because of the syntax, or because of the concepts of FP?
it's because i've been building this thing all week about 10 - 12 hours a day i'm like down to the last bits. just out of juice.
exhaustion dismantles everyone. you're almost there. leave the < 2 condition, add the = 2 condition, and you should be done
can you copy paste the fn again?
(defn interpolate-series [f data] (let [a (first data) b (second data)] (cond (< (count data) 2) data (= (count data) 2) (conj (interpolate-between-points f a b) b) :else (concat (interpolate-between-points f a b) (lazy-seq (interpolate-series f (rest data)))))))
actually it's working for my basic test case, but fails for the one that causes the stack overflow
what does interpolate-between-points return?
there shouldn't be a need for the (conj (i-b-p f a b) b)
just have (= (count data) 2) (interpolate-between-points f (first data) (second data))
great! hope you can reward yourself with sleep