#clojure log - May 21 2016

The Joy of Clojure
Main Clojure site
Google Group
List of all logged dates

0:41 tolstoy: ,(map type (map quote [1 2 *]))

0:41 clojurebot: #error {\n :cause "Unable to resolve symbol: quote in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: quote in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: quote in this...

0:42 tolstoy: ,(map type (map #(quote %) [1 2 *]))

0:42 clojurebot: (clojure.lang.Symbol clojure.lang.Symbol clojure.lang.Symbol)

3:20 DoubleMan: Freeware Videogame for windows http://www.indiedb.com/games/unlimited-runner/downloads/unlimited-runner-v10

3:22 dysfun: ,(map type '[1 2 *])

3:22 clojurebot: (java.lang.Long java.lang.Long clojure.lang.Symbol)

3:22 dysfun: tolstoy: ^^

3:22 tolstoy: Eh?

3:23 dysfun: i admit i was confused for a moment by the output of yours til i ran it through in my head

3:23 tolstoy: I was just wondering if quoting a vector quoted each element of the vector.

3:24 ,(+ '1 '2)

3:24 dysfun: yes, but it won't change the type of it if you do it like i did

3:24 clojurebot: 3

3:25 tolstoy: Right. My attempt was to see what _would_ change the type of it.

3:25 DoubleMan: Freeware Videogame for windows http://www.indiedb.com/games/unlimited-runner/downloads/unlimited-runner-v10

3:25 dysfun: (map type '['1 2])

3:25 ,(map type '['1 2])

3:25 clojurebot: (clojure.lang.PersistentList java.lang.Long)

3:25 dysfun: wut?

3:26 tolstoy: Huh.

3:26 dysfun: i don't even...

3:26 ,(type '1)

3:26 clojurebot: java.lang.Long

3:27 dysfun: (type (first '['1]))

3:27 ,(type (first '['1]))

3:27 clojurebot: clojure.lang.PersistentList

3:28 tolstoy: Maybe it expands '1 to (quote 1) then quotes that, so it's a list?

3:29 dysfun: ,'['1]

3:29 clojurebot: [(quote 1)]

3:29 tolstoy: ,(type '(quote 1))

3:29 clojurebot: clojure.lang.PersistentList

3:39 TEttinger: wowza. wowza. bo-bowza. I need to test Clojure and Lein with this, but I'm getting what appear to be much better startup times using a subset of the modular JRE from JDK 9

3:39 http://zulu.org/zulu-9-pre-release-downloads/

3:39 dysfun: sweet :)

3:40 TEttinger: not quite instant with a GUI app, but much better than Zulu 8, which is basically the same as Oracle Java 8

3:40 dysfun: the gui stuff is huge

3:40 TEttinger: I have a compact1 profile that's 20 MB

3:40 maybe 30, not sure

3:40 30

3:42 dysfun: i know some people who deploy a compact1 to production

3:42 as an 'agent' process

3:45 tolstoy: What does that modular stuff mean? A smaller set of classes such that it doesn't take as long to find the one you want to load?

3:46 TEttinger: I know only that it allows you to make smaller JREs for distribution, which is very relevant on Mac's App Store

3:46 dysfun: essentially there are three compact build profiles. each one has progressively more of the stdlib included

3:46 TEttinger: I think it also helps with speed, though I didn't expect it to

3:46 oh no

3:46 not that dysfun

3:47 that's the "baby's first project jigsaw" that they were making for JDK 8

3:47 dysfun: and as i recall, a compact profile has fewer problems with distribution rights

3:48 tolstoy: Why would fewer classes make things faster?

3:48 TEttinger: compact3 doesn't have AWT or Swing, for example. I just successfully used a module for desktop and base only, I made it with this command

3:48 bin\jlink.exe --exclude-files=*.diz --vm=server --modulepath jmods/ --addmods java.desktop --output ../desktop/

3:48 (windows)

3:48 dysfun: well they've since expanded the build profiles so it's not just libraries but configuration

3:48 i don't know how far down the rabbit hole they've gone though

3:48 TEttinger: java.desktop actually has less than compact1 by default, you can easily add compact1 in it

3:49 not sure what the difference is between base and compact1

3:53 oh nice. "bin\java -jar leiningen-2.6.1-standalone.jar" starts up in under a second, and this computer has a rather worn-out HDD

3:53 that's with a compact3 JRE

3:54 tolstoy: Do you need a JDK with lein to compile stuff?

3:54 TEttinger: not sure!

3:54 javac isn't in this... or is it...

3:55 Ilikethisanother.gif

4:07 so in lein, how would I print the classpath?

4:07 dysfun: lein cp

4:17 TEttinger: damn... `lein` gives a huge stacktrace. Caused by: java.lang.ClassNotFoundException: sun.misc.Launcher

4:19 sun.misc should be present...

4:34 it seems it's present but no longer public on Java 9

4:38 dysfun: yay!

8:06 dimon_: after I compile my app with "lein uberjar", I get 2 files my_app.jar and my_app.1-0.1.0-SNAPSHOT.jar

8:06 what's the difference between them?

8:06 which one should I deploy to a server?

8:07 my_app.jar is 8 times smaller

8:10 Empperi: dimon_: uberjar

8:10 the larger one

8:11 the difference is the larger one has all it's dependencies included

8:11 dimon_: I see, thx.

8:11 Empperi: the smaller one has none, you'd have to include those as separate jar packages and include them via classpath in order to execute your application

8:12 might make sense if you'd have tons of applications running in the same server which used the exact same dependencies

8:12 *might*

8:12 you could end up in trouble when updating one of the apps and bumping dependencies for that - then all of your apps would get the dependencies udpated too (after reboot)

11:16 Furrane: hello

13:23 msenol: hi guys

13:23 can someone help me to call this code in clojure REPL?

13:23 http://stackoverflow.com/a/20517459/2760951

13:24 I am new to clojure, I don't know much about java interop

13:25 ridcully_: something along: (.browse (Desktop/getDesktop) (.toURI thefile))

13:25 msenol: ok thx ridcully_

13:26 dysfun: and (File. my-uri)

13:26 msenol: ok one more question

13:26 how can I import Desktop in REPL?

13:27 dysfun: do you know the full class name?

13:27 (import '[foo.bar.ns Desktop])

13:27 msenol: java documentation says full class name

13:27 java.awt.Desktop

13:28 dysfun: (import '[java.awt Desktop])

13:28 msenol: wow it is working. thx a lot dysfun

13:28 dysfun: np :)

14:21 Gh0stInTheShell: So I have this program here: http://pastebin.com/5DCMjmbP

14:22 I made it myself and it's not very good. The algorithm for finding pi is optimized but intentionally horrible.

14:22 and when I run it on the jvm it pauses noticably for depth values of 5000

14:23 but when I run it with a depth of 50 million on clojurescript it takes 300 msecs

14:24 Hello ClojureScript!

14:24 core.cljs:150 "Elapsed time: 301.400000 msecs"

14:24 core.cljs:150 3.1415926735902504

14:24 And so that is blowing my mind a little bit.

14:25 dysfun: try running it with reflection warnings enabled and see if you get any enlightening messages

14:25 if not, it's going to take a while to analyse and figure out what's supoptimal

14:26 Gh0stInTheShell: dysfun: For the JVM?

14:26 dysfun: yes

14:27 Gh0stInTheShell: OKay will check that out

14:27 The algorithm is bad on purpose, didn't expect cljs to handle it either

14:27 cljs is so fast it fixes bad *algorithms* ;)

14:27 * Gh0stInTheShell ducks.

14:28 dysfun: i expect when you run with reflection warnings you will see what it is so much slower

14:28 Gh0stInTheShell: okay checking it out

14:28 dysfun: cljs will not have to pay those penalties

14:28 ridcully_: JS only has one number format. java many. as dysfun suggested, you might have to dig deeper into what is happening behind the scenes

14:29 Gh0stInTheShell: But, I mean, my function is written as pure Lispy as I could make it, had to use recur. It frightens me to have to worry about all this Java stuff ;)

14:30 dysfun: clojure had to make a few compromises to sit on top of the jvm

14:30 Gh0stInTheShell: I'm exploring and I thank you all for your direction and will look into what slows it down on the JVM.

14:30 :)

14:30 dysfun: things getting unneccesarily boxed by default was an important one

14:31 reflection was another. the java compiler will never generate a reflection lookup unless you manually write the code for it

14:31 but we wanted to have a nice dynamic language where things just work

14:31 and the cost of that is that occasionally they don't and it's a pain in the arse figuring out why

14:32 Gh0stInTheShell: Well, you have that (a nice dynamic language where things just work). I <3 Clojure. It is one of my 5 pillars of world domination.

14:33 Now if I could just learn the stuff. :)

14:33 dysfun: there are much better resources these days than when i learned clojure

14:33 where are you learning from?

14:33 Gh0stInTheShell: dysfun: My mind. The docs

14:34 dysfun: Talks at Clojure West and Clojure Conj and Strange Loop

14:34 dysfun: the docs aren't really of the quality we'd like them to be yet

14:34 Gh0stInTheShell: dysfun: on youtube mostly but sometimes in person

14:34 dysfun: They're okay :)

14:34 dysfun: i find some of those talks great for e.g. trying to understand what a single library is about

14:34 but i don't know about learning clojure from them

14:35 Gh0stInTheShell: Or making robots fly around in my unicorn editor!

14:35 dysfun: you could read some code :) here's some of mine https://github.com/irresponsible/

14:35 Gh0stInTheShell: Well I know lisp and scala and java and stuff, clojure seems to be coming pretty naturally

14:35 I read code

14:35 to help

14:37 BUt I really might just be becoming a cljs programmer because I like the speed of javascript but hate the language itself. And I know how lots of people feel about that in this channel and I'm okay with that and unwilling to abandon a possible way for me to stop writing java for work also.

14:37 The trouble with the java I write for work is it's all for Dalvik/ART

14:37 But Clojure proper still might bail me out. ;)

14:38 vermiculus: hi all :) question: what's the convention in clojure for testing your test suite?

14:38 dysfun: if you have to use the jvm, clojure is absolutely my favourite tool

14:38 ben_vulpes: vermiculus: testing your test suite?

14:38 dysfun: vermiculus: do you mean "running your tests"?

14:38 vermiculus: dysfun: nopeā€¦

14:38 i.e. I have a few small functions that I use in my tests to make them readable

14:39 ideally, I need to be able to test that they work

14:39 dysfun: oh. just write the tests afterwards

14:39 ben_vulpes: stick them in test/project/test_util.clj

14:39 then write test/project/test_test_util.clj

14:39 ... (:require test-util)) (deftest test-my-util-fn ...)

14:39 tolstoy: If the test-utils are used in lots of tests, isn't that good enough?

14:39 dysfun: yes yes, very silly

14:39 vermiculus: ben_vulpes: yeah, I was thinking something along those lines

14:39 Gh0stInTheShell: but who tests the tests fot the tests?

14:40 s/fot/for

14:40 vermiculus: Gh0stInTheShell: good point; we must go deeper!

14:40 ben_vulpes: "my tests are the integration tests for my test utilities"

14:40 Gh0stInTheShell: (inc vermiculus)

14:40 dysfun: i see all of these crap jokes i've heard a million times and they make me feel old

14:40 vermiculus: dysfun: they never get any less funny for me :)

14:40 Gh0stInTheShell: dysfun: If you've heard them a million times you are old

14:40 dysfun: i'm not even old.

14:41 Gh0stInTheShell: :)

14:41 vermiculus: ,(/ (* 3 1000000) 60 60 24 7 364.24)

14:41 clojurebot: 0.013618266693162365

14:41 tolstoy: I kinda lean towards tbaldridge's stance: test the interfaces of the large-grained concerns.

14:41 Gh0stInTheShell: They never get old for me either. Especially if they're about recursion or self-referentiality. Or Unix/Linux. :)

14:42 vermiculus: technically, dysfun doesn't have to be more than a year old.

14:42 dysfun: i heard a particle physicist joke the other day. it was even worse

14:42 vermiculus: dysfun: ooh, do tell :)

14:42 dysfun: a higgs boson went to church but was stopped at the door by the minister. "i'm sorry, but you can't visit mass" "but i am the creator of all mass!"

14:43 vermiculus: o

14:43 that's bad

14:43 dysfun: yes, it is very bad

14:43 vermiculus: XD

14:43 tolstoy: Maybe remove the punchline and it's slightly better?

14:43 dysfun: i was waiting for the punchline for a few seconds before i realised it wasn't coming

14:44 or "cat-ions are puss-itive" is pretty bad too

14:45 Gh0stInTheShell: lol

14:45 dysfun: no. that was many things but it was not lol

14:45 Gh0stInTheShell: lmao

14:46 literally about to fall out of the chair

14:46 ben_vulpes: where do you find the answers for your chem homework?

14:46 in the solute-ions manual

14:47 * dysfun twitches

14:49 TimMc: Though... testing the tests sometimes does reveal scary things.

14:49 vermiculus: TimMc: how so?

14:49 TimMc: *cough*midje*cough*

14:49 dysfun: actually, rewriting midje tests in clojure.test has put me off midje

14:49 vermiculus: midje?

14:49 clojurebot: #<RuntimeException java.lang.RuntimeException: Invalid token: :>

14:49 * vermiculus googles it

14:50 TimMc: I still like midje, but some of the behavior is a little too unintuitive.

14:50 dysfun: there were way many more failures than i expected, and i don't mean in my new tests

14:50 * dysfun was very disappointed because midje is cool as

14:50 ben_vulpes: TimMc: does midge still do that thing where it runs the tests on compile?

14:50 TimMc: Yes.

14:50 ben_vulpes: fuck

14:50 that

14:50 noise

14:51 TimMc: I feel like it could very easily be switched to not do that.

14:51 * dysfun has no idea what you're on about

14:51 TimMc: dysfun: Midje tests are like (fact ...) at the top level, and that's when they execute their bodies -- unlike clojure.test's deftest, which is defined and then later called.

14:52 dysfun: yes. why is this a problem?

14:52 Gh0stInTheShell: ,(double (pi 50))

14:52 clojurebot: 3.16119861298705

14:52 TimMc: It means, among other things, that you cannot skip a test or run just one very easily.

14:52 Gh0stInTheShell: ,(double (pi 500))

14:52 clojurebot: 3.143588659585787

14:52 TimMc: tihnk it also means you cannot load a midje test file for analysis without running the tests.

14:53 dysfun: clojure static analysis is a joke anyway

14:53 TimMc: No, I've gotten good use of eastwood, or tools to map the namespaces and var usages.

14:54 dysfun: hrm. well those won't be needed on your test suite anyway

14:56 TimMc: Not true.

14:56 * vermiculus has to run, but thanks you all for your help :)

14:57 TimMc: Just because you don't use static analysis doesn't mean it's a good idea to make an entire toolset difficult to use.

14:57 We can't always know in advance what we want...

14:57 dysfun: that is true, but i've tried static analysis of clojure a few times and i've never found it adds a great deal

14:58 TimMc: I have a tool that, given a git diff, shows me a visual graph of the namespaces involved.

14:59 I use that when I'm reviewing a pull request because it allows me to start with the low-level changes and work my way up.

14:59 dysfun: tools.namespace can do that and i'd hardly call what it does static analysis

14:59 TimMc: It involves loading clojure files.

14:59 You're the one that called it static analysis. :-P

14:59 dysfun: and reading a single form out of them...

14:59 ben_vulpes: midge + reloaded is an utter misery.

15:00 TimMc: I'll be expanding the tool to include var dependencies.

15:00 ben_vulpes: moreover running /all of an ns' tests/ on compile is a similar misery.

15:01 also it's another cutesy test runner, which i'm just sour on in principle.

15:01 TimMc: no wait

15:02 The thing I'm doing will not involve loading the files, it really is static analysis and this is irrelevant.

15:02 Eh, I don't remember the stuff it actually interferes with. :-)

15:02 tolstoy: ben_vulpes Where's the fancy DSL that helps spin up servers, throw a ton of concurrent requests against them, and make sure a "real" database is on the other end.

15:02 ben_vulpes: > spin up servers

15:02 > in muh tests

15:02 > wut

15:03 TimMc: End-to-end tests.

15:03 Gh0stInTheShell: ,(time (pi 5000))

15:03 clojurebot: #error {\n :cause "Unable to resolve symbol: pi in this context"\n :via\n [{:type clojure.lang.Compiler$CompilerException\n :message "java.lang.RuntimeException: Unable to resolve symbol: pi in this context, compiling:(NO_SOURCE_PATH:0:0)"\n :at [clojure.lang.Compiler analyze "Compiler.java" 6688]}\n {:type java.lang.RuntimeException\n :message "Unable to resolve symbol: pi in this context"...

15:03 ben_vulpes: tolstoy: fixturing?

15:03 and custom aws integration?

15:04 i honestly have no idea what you're banging on about.

15:04 tolstoy: ben_vulpes I guess it was my back-handed way of saying that these DSLs look appealing when you're testing purely functional code, but my problems are integration.

15:04 TimMc: ben_vulpes: I guess what I'd like is a library of stuff like midje has, but done in a more imperative way like clojure.test does.

15:04 Gh0stInTheShell: ,(time (double (pi 2000)))

15:05 clojurebot: "Elapsed time: 2399.306607 msecs"\n3.142092403683528

15:05 ben_vulpes: i used some 'bdd' thinger once

15:06 abstractions bit me though

15:06 Gh0stInTheShell: clojurebot is awesome :)

15:06 ben_vulpes: and i don't actually want to test form submissions

15:06 TimMc: I hate having to run everything through set and sort and other normalization chains because that makes the tests harder to read -- you have to think "OK, now which part of this is normalization and which part is the test subject?"

15:07 Being able to say (contains [:a :b :c] :in-some-order) is *fantastic* for concision.

15:07 But I'd really be fine with (contains foo [:a :b :c] :in-some-order) -- just make it explicit.

15:08 dysfun: i wonder if any of the other test frameworks steal any of the good bits from midje for the clojure.test model yet

15:08 TimMc: Midje: The Good Parts

15:09 dysfun: so i started trying to port midje to cljs

15:09 TimMc: dysfun: If you find one, let me know!

15:09 ridcully_: are there any more popular ones beside c.t and midje?

15:09 dysfun: first problem: it depends on a module whose tests are written in midje

15:09 TimMc: haha

15:09 dysfun: "ah. yes. i can see that being a problem" -- marick

15:11 tolstoy: ridcully_ https://github.com/jaycfields/expectations

15:12 dysfun: i was a bit saddened when i had to drop midje. until i found all those bugs in my midje test suite. that was pretty disturbing

15:15 "simply require expectations and your tests will be run on JVM shutdown, no call to any 'run' function is necessary."

15:15 wut?

15:17 that's even more broken than midje

15:18 mr-foobar: hi all. what is the difference between clojure channels and a message bus ? I am trying to understand the technical / implementation differences.

15:18 dysfun: message bus is a very overloaded term

15:19 and by clojure channels, i presume you mean core.async channels

15:19 mr-foobar: Yes. I am using the term Message Bus from the perspective of topics / publish / subscribe.

15:20 dysfun: okay, well there is no pubsub mechanism built into channels, but it is possible to build one using channels as the basis for it

15:20 mr-foobar: core.async seems be the same from the outside chnanels / put / take.

15:20 dysfun: there are several functions in core.async that could help

15:21 mr-foobar: I understand the usage part. I just am not able to understand how they are different.

15:21 dysfun: channels are basically simple queues of messages, conceptually

15:22 well pubsub requires that you publish topics that can be subscribed to

15:22 ridcully_: isn't there pub and sub in core.async?

15:23 dysfun: yes, but not built in to channels

15:23 mr-foobar: dysfun: ah good point. topics need to be explicit.

15:24 dysfun: a pubsub system actually performs logic for distribution

15:24 mr-foobar: they are not values as channels which can be passed around but more like strings.

15:24 dysfun: a channel is a dumb thing

15:24 it's just a plain queue that you queue data in

15:26 for instance, rabbitmq has you define various queues and then 'exchanges'. depending on which exchange you post to, it will be distributed to zero or more queues

15:26 each queue in rabbitmq is t

15:26 hus a single subscription to a 'topic'

15:27 whereas core.async channels are analogous just to the queue part of my rabbitmq analogy

15:27 mr-foobar: yup. got it !

15:27 dysfun: cool :)

15:28 mr-foobar: I suppose a Bus topic is more discoverable than channels.

15:29 With core.async I remember having to use a global map of pre-defined channels.

15:29 dysfun: well a bus is a discoverability mechanism :) you can implement your own if you like, or you can use core.async's

15:31 mr-foobar: I was watching https://channel9.msdn.com/Shows/Going+Deep/Hewitt-Meijer-and-Szyperski-The-Actor-Model-everything-you-wanted-to-know-but-were-afraid-to-ask and I ended up at CSP and clojure.async :)

15:32 * dysfun is learning lisp flavoured erlang at the minute which has actors

15:33 mr-foobar: I think CSP is more easier to approach than the actor model which is a bit recursive.

15:34 dysfun: hah, you'll have fun debugging core.async and wondering where the stack traces are ;)

16:09 msenol: hi guys

16:09 I want to access values defined via intern function, in -main method

16:09 here is my code

16:09 https://bitbucket.org/snippets/msenol86/kKRpj

16:09 it gives error

16:09 Caused by: java.lang.RuntimeException: No such var: chap-9.core/yyy

16:14 TEttinger: you didn't show that you had declared an ns when that was run, should I assume you're in the ns chap-9.core ?

16:15 ,(doc intern) ; let's see here...

16:15 clojurebot: "([ns name] [ns name val]); Finds or creates a var named by the symbol name in the namespace ns (which can be a symbol or a namespace), setting its root binding to val if supplied. The namespace must exist. The var will adopt any metadata from the name symbol. Returns the var."

16:18 msenol: yes Tettinger I am in chap-9.core

16:18 I am adding the namespace thing into bitbucket snippet one minute

16:19 ok added

16:21 TEttinger: can you try (println yyy) instead of the ns and then yyy?

16:22 msenol: Caused by: java.lang.RuntimeException: Unable to resolve symbol: yyy in this context

16:23 TEttinger: this is where I hope justin_smith or amalloy is around

16:24 msenol: ok thx :)

16:24 amalloy: *ns* isn't bound after compilation is done

16:24 so you're interning stuff into clojure.core

16:26 msenol: ummm ok

16:26 amalloy: but i guess it never even gets to that point

16:26 because the intern only happens at runtime, and you try to resolve the var at compile time

16:26 msenol: oh

16:27 is there a way to force it to resolve at runtime?

16:27 instead of at compile time?

16:28 amalloy: yes, you can call (resolve 'yyy) or whatever

16:28 msenol: oh ok

16:28 amalloy: ,resolve

16:28 clojurebot: #object[clojure.core$resolve 0x23fd5492 "clojure.core$resolve@23fd5492"]

16:28 msenol: thank yout very much amalloy :)

16:28 also thank you very much TEttinger

16:29 TEttinger: yw, also thanks amalloy!

16:34 msenol: a little problem :)

16:34 #'user/yyy

16:34 justin_smith: I thought *ns* was typically user

16:34 msenol: resolve returns that

16:34 how can i get the value of it

16:34 dysfun: @

16:34 justin_smith: msenol: @

16:34 which is shorthand for deref

16:34 msenol: wow

16:34 thx

16:34 all

16:35 I am asking these questions here becaue it is diffucult to test stuff when you are workin with -main method. you have to call lein run everytime

16:35 it is not easy as repl

16:35 again thx a lot all

16:36 justin_smith: msenol: there are very few things that are not identical in a repl vs. running from a file, and you can call -main from your repl

16:36 msenol: oh ok

16:36 clojure is great

16:36 thx for tip justing_smith :)

16:42 amalloy: justin_smith: notably though *ns* is different

16:43 and that is exactly what msenol is toying around with atm

16:43 justin_smith: ahh, right

16:45 msenol: why not provide a symbol instead of *ns* when using intern?

16:47 msenol: justin_smith: umm I want to add a value to current namespace, how can I use a symbol for that?

16:47 justin_smith: should I provide a symbol to produce another namespace?

16:48 justin_smith: msenol: if you want to put a var in a specific namespace, yes

16:48 msenol: oh ok

16:48 justin_smith: I want to make something similar to scrapy library in python

16:49 justin_smith: because *ns* at runtime in normal runs is typically user (it's even user in repls, until you make clojure switch to sometthing else)

16:49 msenol: justin_smith: in scrapy u can do this scrapy 'www.google.com'

16:49 justin_smith: and after that you can access to google.com page using variable "response" in scrapy shell

16:50 justin_smith: I want to build something like that

16:50 justin_smith: yeah, we tend to avoid things like this in clojure, preferring locality of reference rather than creating values indirectly

16:51 msenol: justin_smith: ok thx a lot

16:52 justin_smith: msenol: it would be possible to make a function that creates a var in your current namespace, but it's not simple, and the most straightforward way probably involves passing in the namespace that should get this new var - but why not use a composite return value (or just a return value) rather than an automatic var creation?

16:53 code that uses return values is much more predictable

16:55 msenol: justin_smith: yeah in first version of the function it returns a value and you have to assign it to a var in repl

16:55 (def parsed-html (my-parser ("www.google.com")))

16:55 justin_smith: it was working in this way

16:55 justin_smith: I assume there are extra parens there, but yeah

16:55 msenol: justin_smith: but I try to make it user friendly like scrapy

16:56 justin_smith: yeah one extra paren sorry

16:56 amalloy: msenol: that's not really user-friendly, it's just python-style

16:56 msenol: amalloy: ok :)

16:56 amalloy: a clojure style would be to have the function return a value, and then you call other functions on that value

16:57 possibly you def it to a var, possibly not

16:57 msenol: yeah, but I want to design a shell, so when user calls my program in command-line like this:

16:57 scrapy-clojure "www.google.com"

16:57 then user will put into a shell

16:58 after that user can call functions predefined (which works on www.google.com html)

16:58 like

16:58 (css-select "div#some_div")

16:58 and it returns a node or list of nodes

16:59 justin_smith: OK, in that case you could make sure that the vars you create are interned into the shell's primary namespace - that should be simple enough

17:00 msenol: justin_smith: oh ok. so I should create a namespace for my shell. thank you very muc

17:00 justin_smith: msenol: yeah - you could even use the main ns you are already using - just make sure to explicitly provide that ns symbol as an arg to intern - to ensure that definitions end up there

17:01 msenol: justin_smith: ok I understood

17:02 you guys are great

19:29 jumanji: hi guys how do you reduce a list of maps via a specific key value? I tried it here but not sure if I'm doing it correctly : http://stackoverflow.com/questions/37369012/clojure-given-a-list-of-maps-get-the-total-sum-value-of-a-specific-key-value

19:29 TEttinger: this is one of those things that I think gets solved easily with a transducer

19:30 Lewix: is there an easy wha to add an index to repeat

19:30 ,(repeat 5 "lewix")

19:30 clojurebot: ("lewix" "lewix" "lewix" "lewix" "lewix")

19:30 TEttinger: repeatedly takes a 0-arg fn. what I would do is a map on range

19:31 ,(map #(str "lewix" %) (range 5))

19:31 clojurebot: ("lewix0" "lewix1" "lewix2" "lewix3" "lewix4")

19:37 Lewix: TEttinger: thanks it's neat

20:32 ob_: hi is there any facility for showing docs within clojure repl?

20:34 Lewix: ob_: (doc foo)

20:34 ,(doc doc)

20:34 clojurebot: "([name]); Prints documentation for a var or special form given its name"

20:34 ob_: ty Lewix

21:05 ealfonso: how do I ask lein to take a dependency from a local jar?

23:17 tolstoy: Heh. That question. ;) Reminds me of struggling with what to do with an Oracle JDBC jar.

Logging service provided by n01se.net