Fork me on GitHub
#beginners
<
2016-11-01
>
keatondunsford00:11:15

Hey y’all. Can someone copy and paste their project.clj file that’s in their .lein directory? I think I broke mine on accident and ended up breaking all of my Lein. 😩

seancorfield01:11:52

Do you mean profiles.clj?

seancorfield01:11:45

Mine just has

{:user {:plugins [[lein-ancient "0.6.7"]
                  [lein-localrepo "0.5.3"]
                  [lein-try “0.4.1”]]}}

keatondunsford02:11:05

Oops yeah that’s what I meant. Is that the newest version of profiles.clj?

kauko06:11:25

What do you mean by "newest version"? It should be empty by default.

vandr0iy15:11:45

How does one pattern match a map whose key is arbitrary? for example, I got a data structure, about which I know that it's gonna be a map with only one key-value pair, and its value will be a vector. How do I match it?

dominicm15:11:54

With only one key-value pair ever?

dominicm15:11:35

will get you the key, or (second (first m)) will get you the value

dominicm15:11:05

You probably want to do something like this though:

(let [[k v] (first m)
  ...)

vandr0iy15:11:45

requires fiddling, but does the trick, thanks! @dominicm Would be really nice to destructure the maps without knowing directly their exact keys, though. I found myself needing this feature pretty often

dominicm15:11:51

@vandr0iy Well, a hashmap, is a sequence of MapEntry, which you can think of as looking like this:

[
[k v]
[:foo :bar]
]

dominicm15:11:40

I'm not sure how destructuring without knowing the key would look. Unless you're talking about core.match

vandr0iy15:11:12

how would I do that with core.match?

dominicm15:11:21

It's just a library to describe how to match on certain things.

dominicm15:11:43

@vandr0iy What is it you want to do (idealistic syntax)?

vandr0iy15:11:26

(match [{:foo ["bar" "baz"]}]
             [k :guard keyword?] (println "it's a keyword: " k)
             [{k vals}] (println "key:" k "vals:" vals))
something like this

dominicm17:11:15

Maybe you're looking for specter. Or generally a filter keys function.

loganmhb18:11:44

although if you want to traverse the structure recursively you’ll need to combine it with specter, clojure.walk, or some kind of manual recursion

loganmhb18:11:09

if you know how deep the map is going to be, you can match on a pattern like [{(k :guard keyword?) v}] …

neurogoo21:11:14

If I start clojure server from emacs how do I see errors? I am trying debug why my http get requests are not working

jswart21:11:53

Look for cider buffers in the buffer list.

jswart21:11:17

its one of those, but I forget which. I don’t use emacs as much lately