Clojurians
#clojure
<
2016-07-11
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

v4708:07:51

How would I go about turning something like:

v4708:07:36

ie, unpack the seq in place. Thanks!

delaguardo09:07:06

(defn flatten-1 [coll]
  (mapcat (fn [c]
            (if (and (sequential? c)
                     (not (vector? c)))
              c
              [c]))
           coll))
mapcat for example

v4709:07:47

Thanks @delaguardo

richiardiandrea17:07:08

Hello Clojurians! I was wondering if there is something similar to http://locust.io/ in Clojure for benchmarking requests per second, does anyone know?

rohit17:07:50

@richiardiandrea: i know of http://gatling.io/

richiardiandrea17:07:34

@rohit thanks! I also saw http://grinder.sourceforge.net/index.html and there is even some Clojure scripting in there

rohit17:07:17

…and there is a clj wrapper for it as well. https://github.com/mhjort/clj-gatling

rohit17:07:58

haven’t used it. so can’t vouch for it

rohit17:07:24

though i’ve heard good things about gatling

mhjort17:07:07

I've been developing clj-gatling for few years. It doesn't have all the features locust has but you can use clojure for writing tests

mhjort17:07:30

That was my reason for building the tool

richiardiandrea17:07:56

@mhjort: I having a look and it does look very neat, especially the data-only part

mhjort17:07:05

There's also http://github.com/mhjort/clojider for distributed load testing

mhjort17:07:53

That's a tool that can run clj-gatling load tests using aws lambda infrastructure

richiardiandrea17:07:17

yep, it looks like I found my tool of choice :wink:

mhjort17:07:37

Cool. Btw, if you have any questions don't hesitate to ask. I am currently having a vacation but after that my goal is to further develop the tool a lot based on the feedback

jsa-aerial18:07:21

@gowder: go with msgpack http://msgpack.org/index.html Works great and is simple to stream any size 'object' as well as arbitrary nested datastructures. Way better than base64 stuff.

josh.freckleton19:07:13

If I'm using the checkout workflow to have projects depend on local projects, how can I propagate changes from the required project into the requiring project? https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md#checkout-dependencies

josh.freckleton19:07:17

(right now, in my emacs cider, I have to restart cider in order to see changes... lein's a bit slow to make parallel development feasible if I have to restart every time...)

rhoslug20:07:36

Is there a recommended library for querying an anonymous FTP with Clojure?

juhoteperi20:07:08

@rhoslug: You can get quite far with just Java URL and http://clojure.java.io namespace.

juhoteperi20:07:46

(io/input-stream "") etc.

rhoslug20:07:07

I wasn't hoping to do anything very complicated, just retrieve a file cool! thanks @juhoteperi

cdine22:07:09

Is there a better online resource where I can learn about the build/compilation phase of clojure.? Almost all resources assumes Lein or Boot, which is a better way to get started, but what If I want to learn more about the internals?

austb22:07:03

The book Clojure Programming by Chas Emerick, et al. has quite a bit about the clojure reader. It’s a bit spread out throughout the book though

alexmiller22:07:35

Are you interest in how the compiler works or how it's invoked or something else?

cdine22:07:20

@austb: thanks. Let me check that out.

alexmiller22:07:22

The tools mostly just align environments to call clojure.core/compile which invokes the compiler

cdine22:07:54

@alexmiller: Yeah, about the compiler and even how its invoked.. Yeah that is what i have been trying to do..to grok clojure.main and look at how compile is invoked... thought some one must have covered that already .. may be a blog post or something... I have found one from http://flyingmachine.com which was useful.

alexmiller22:07:19

Is what's "official"

alexmiller22:07:33

clojure.main is generally just starting the repl or invoking a main so not necessarily invoking the compiler

alexmiller22:07:02

There are a number of good talks on ClojureTV that go over some of compilation and evaluation

alexmiller22:07:04

those are both useful ones I can think of

cdine22:07:38

I was trying to invoke compile function from withing a repl invoked through clojure.main and was trying to understand what happens... Thanks for the video links... I think I have watched Life of a clojure expression... will check out the other one.

alexmiller22:07:06

which goes inside how the compiler works a bit more

alexmiller22:07:12

conceptually at least

cdine22:07:42

thanks much.. have something to learn/watch tonight :slightly_smiling_face:

codonnell23:07:26

Is there a nice way to provide default implementations of a protocol's methods and then create an object which overrides a select few of them?

danburton23:07:41

Suppose I have a function f that accepts keyword arguments. And suppose I have a clojure map argz. Is there something analagous to apply that I can use such that (map-apply f argz) will do the correct thing?

danburton23:07:50

(For my actual use case, f is bidi/path-for)

danburton23:07:13

(defn map-apply [f & args]
  #_=>   (let [argz (butlast args)
  #_=>         arg-splat (last args)]
  #_=>     (apply f `[~@argz ~@(apply concat arg-splat)])))

alexmiller23:07:57

@codonnell: nothing provided. it is possible to do as protocols are really maps under the hood and you can do things like this. However, the fact that you want to do it is maybe a smell that you’re over-using protocols.

alexmiller23:07:19

@danburton did you just try using apply?

danburton23:07:04

user=> (apply bidi/path-for [["foo/" :id] :foo] :foo {:id "3" :ok "ok"})

clojure.lang.ExceptionInfo: Cannot form URI without a value given for :id parameter
user=> (map-apply bidi/path-for [["foo/" :id] :foo] :foo {:id "3" :ok "ok"})
"foo/3"

danburton23:07:04

The intended usage is (bidi/path-for [["foo/" :id] :foo] :foo :id "3").

danburton23:07:06

Just using apply would, to my understanding, treat the map as a seq of pairs, rather than treating it as the keyword arguments to the function.

alexmiller23:07:27

you can do this:

alexmiller23:07:56

(apply bidi/path-for [[“foo/“ :id] :foo] :foo (mapcat identity {:id “3” :ok “ok”}))