Fork me on GitHub
#beginners
<
2016-03-06
>
lopalghost12:03:40

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

emperorcezar15:03:37

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

escherize16:03:29

so, did you want a function like f:

(f "applesauce" [2 5]) 
;;=> ["ap" "pples" "auce"]

escherize16:03:33

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")

base69819:03:24

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.

base69819:03:29

(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))))))

base69819:03:53

I can't use recur/loop because of the concat

base69819:03:09

and i know it's not idiomatic to not say xs simple_smile

jonahbenton19:03:36

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)))

base69820:03:48

Did that. trying it, but got an infinite loop from count data == 2

base69820:03:04

so weird. my brain is like not working at all.

jonahbenton20:03:25

@base698 the termination condition should probably be (= (count data) 2), and should return interpolate-between-points of those 2 points?

lmergen20:03:31

(= (count data) 2) ?

lmergen20:03:27

@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?

base69820:03:11

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.

base69820:03:06

it's so close to finished. just can't get it to work on a real data set

jonahbenton20:03:48

exhaustion dismantles everyone. simple_smile you're almost there. leave the < 2 condition, add the = 2 condition, and you should be done

base69820:03:57

that didn't work either, just keeps going with list size 3

jonahbenton20:03:24

can you copy paste the fn again?

base69820:03:54

(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)))))))

base69820:03:14

actually it's working for my basic test case, but fails for the one that causes the stack overflow

base69820:03:46

wow it's another error

base69820:03:49

not stack overflow

base69820:03:00

probably a problem with the test simple_smile

jonahbenton20:03:28

what does interpolate-between-points return?

jonahbenton20:03:17

there shouldn't be a need for the (conj (i-b-p f a b) b)

jonahbenton20:03:42

just have (= (count data) 2) (interpolate-between-points f (first data) (second data))

base69820:03:15

could probably change that, but it looks like it's working

base69820:03:25

thanks so much for your help!

base69820:03:28

so awesome

jonahbenton20:03:09

great! hope you can reward yourself with sleep simple_smile

base69820:03:08

I've been following clojure for about 3 years and used it for some toy stuff. When our company started moving in plain ole java I figured it was a good opportunity to use it for something real. Hopefully I won't get fired for rebuilding it all in clojure before anyone notices simple_smile

lmergen21:03:25

hah you didnt discuss this with anyone else in the company? good luck with that :)

base69821:03:25

I don't have lead in my title to code in Java, what is this, 2006?

base69821:03:51

I was offered $150/hr to code in Java, but I turned it down for $100/hr to gouge out my eyes.