Fork me on GitHub
#beginners
<
2018-07-14
>
kennytilton06:07:53

@ryan.russell011 As long as you are happy. I began on Emacs with no more than the Brave Clojure emacs setup and was quickly productive aside from never knowing what the hell buffer Emacs would select when I navigated. Then an ex-friend recommended Spacemacs and pretty soon I was on IntelliJ. 🙂

kennytilton06:07:39

btw, not sure where your sticking points are, but if the keychords are a problem just hang in there. That much I love. Try to learn a new one every week over the morning coffee.

_rj_r_06:07:37

mostly I am just trying to get into a good Clojure environment.. and since Emacs is the one thing I haven't used much figured I'd give it a go. I decided to ditch Spacemacs... it has a feel to it that I didn't much care for.. so I just embarked on the journey of Emacs configuration and all it's "glory" lol

_rj_r_06:07:26

Evil mode will have to be installed... not having Vim commands is something that I'm not sure I could live with lol

mg11:07:16

@parth.12282 looks like what's going wrong is that you're expecting calling dissoc and assoc on major-data, minor-data, major-only and minor-only is going to modify those things like variables. Clojure has immutable data. When you call assoc on a binding like minor-only, it returns the result of that - a new map with the key assoced in - but minor-only doesn't change.

mg11:07:34

For what you're trying to do there, you probably want to do a reduce to build up the new map data structure that you return, rather than map

P69614:07:26

@michael.gaare Thanks for the help. I am trying to do it with using reduce , but it is not getting iterated in any of the http://condition.Do I also need to change anything else with the change of replacing map with reduce?

mg14:07:59

Yes, almost every line needs to be changed 😄

P69614:07:14

😂Okay

mg14:07:21

What's supposed to be in "Major-only" vs "Minor-only"?

P69614:07:08

If the key-value pair of major-data is not present in the minor-data then that entry should be considered in major-only (because it is present in only major data). And if the major-data's value for a particular key is not a subset of the minor's value for that same key then it should be included in minor-only.

P69614:07:39

So if it is not a subset then it will be in both the data. major and minor both.

valerauko14:07:27

so you want an end result in the shape of { :minor-only {200 {...}, 201 {...}}, :major-only {200 {...}, 201 {...}}, :both {200 {...}, 201 {...}} } ?

P69614:07:27

In end result even if i have only map as { :minor- only value-of-minor-only :major-only value-of-major-only } it should be fine, Since we are going to have values in both of them when subset condition fails, so no need to have an extra both to the end result.

valerauko14:07:58

>we are going to have values in both of them when subset condition fails i don't understand what you're trying to achieve

P69615:07:18

Okay.Sorry for not explaining properly. For example, i have this data `{"Major" { [200 {1 5,2 10, 3 10} ] [201 {1 5,2 10,4 10,6 10} [204 {1 4,2 5,3 8,4 9}]]} "Minor" {[200 {1 5,2 10,3 10,4 10}] [203 {1 5,2 10,3 10}] [204 {1 4,2 5,3 8}]}})` - major-only will be:-` {201 value} (because it doesn't exists in minor), 204 (since the major's value is not subset of minor's value for key 204)` - minor-only will be :-`{203 value} (Since it does not exists in major),204 entry(because the subset condition failed`)

👍 4
valerauko15:07:57

my very inefficient and naive solution would be to reduce first to produce major-only by iterating over major's keys, then doing the same for minor-only with minor's keys

marlenefdez16:07:54

Can anyone see what's wrong with this function? I keep getting the error: IllegalArgumentException Don't know how to create ISeq from: clojure.core$array_map clojure.lang.RT.seqFrom I've already exhausted everything I would know to do to debug this 😥

marlenefdez16:07:24

(defn find-even-index "You are going to be given an array of integers. Your job is to take that array and find an index N where the sum of the integers to the left of N is equal to the sum of the integers to the right of N. If there is no index that would make this happen, return -1." [arr] (if (= 0 (reduce + array-map)) 0 (loop [i 1 a arr] (cond (= i (count a)) -1 (= (reduce + (take i a)) (reduce + (drop (dec i) a))) i :else (recur a (inc i))))))

marlenefdez16:07:11

(defn find-even-index
  "You are going to be given an array of integers. Your job is to take
  that array and find an index N where the sum of the integers to the left
  of N is equal to the sum of the integers to the right of N. If there is
  no index that would make this happen, return -1."
  [arr]
  (if (= 0 (reduce + array-map)) 0
      (loop [i 1
             a arr]
        (cond
          (= i (count a)) -1
          (= (reduce + (take i a)) (reduce + (drop (dec i) a))) i
          :else
          (recur a (inc i))))))
sorry here's the same code w/ better formatting

marlenefdez16:07:07

and here's the codewar question i'm trying (but failing) to implement: https://www.codewars.com/kata/5679aa472b8f57fb8c000047/train/clojure

dpsutton16:07:46

(reduce + array-map) what do you expect this code to do

dpsutton16:07:50

the signature of reduce is ([f coll] [f val coll]). array-map is a function not a collection

dpsutton16:07:46

and it mirrors exactly your message: IllegalArgumentException Don't know how to create ISeq from: clojure.core$array_map clojure.lang.RT.seqFrom Illegal argument: I need an iseq (read collection type (first and rest i believe). and you gave me the function clojure.core$array_map (clojure.core/array-map)

marlenefdez16:07:39

wow! @dpsutton thank so much! i see now that i accidentally autocompleted that line and somehow did not notice that when I reviewed it many times