#clojure log - Mar 03 2013

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

0:03 akhudek: Hm, I don't suppose there is any clojure xml library that keeps the structure compressed in memory (e.g. use a dictionary for tag names and store it in binary?)

0:09 amalloy: even better, akhudek: the tag names are stored as keywords, so all they cost you is a pointer, which you'd have to pay anyway

0:10 akhudek: amalloy: good point, forgot about that

0:12 derekv: learning a new language while doing TDD is the worst thing ever

0:12 mybuddymichael: derekv: Easy solution. Don't do TDD.

0:12 :-)

0:12 derekv: required

0:18 I tried print a collection to a string by doing a (reduce #(conj (print-item %) "\n") "Your items\n" items)

0:18 but it doesn't like that.

0:18 rather it was more like (reduce #(conj % (print-item %1) "\n") "Your items\n" items)

0:19 thats not how conj work apperently

0:20 tomoj: % and %1 are the same, use %1 and %2 (or if you insist % and %2). and use str instead of conj

0:21 but it sort of looks like you're trying to do (clojure.string/join \newline (map print-item items)) ?

0:22 derekv: tomoj, that looks good.

0:22 tomoj: or say (->> items (map print-item) (cons "Your items") (clojure.string/join \newline))

0:23 derekv: gotchya

0:24 I knew there was a nice functional way to do it.

0:24 getting late in the day

0:24 what is the name of the ->> function if I looked it up?

0:25 mybuddymichael: derekv: Threading macros.

0:26 jeremyheiler: derekv, -> is "thread first" and ->> is "thread last"

0:26 derekv: Its just rearranging things for readability?

0:26 jeremyheiler: yeah

0:50 TimMc: Or for unreadability. :-)

0:51 &(((((((-> x (fn [] x))))))))

0:51 lazybot: ⇒ #<sandbox20321$eval58027$x__58028 sandbox20321$eval58027$x__58028@1e30afc>

0:53 frenchyp: how to I print to repl in a seesaw callback function?

1:35 shriphani: hi. I am trying to use lein-localrepo to install a jar on my filesystem but the coords come up nil and I can't import it in my source. Any ideas ?

1:44 mattmoss: shriphani: I don't know about lein-localrepo... I used https://gist.github.com/stuartsierra/3062743 on my project to install jars manually, paying attention to stuart's comment at the bottom. Worked fine for me.

1:46 shriphani: mattmoss: I see. And how do you use it from clojure source (sorry I'm a noob here and I am not sure if I should import or require or use)

1:49 mattmoss: shriphani: My use is fairly simple... so I just use require to bring in the particular classes I need.

1:49 shriphani: mattmoss: and your local jar is a java jar?

1:49 mattmoss: Yup.

1:50 shriphani: mattmoss: thanks a lot. I'll report back if it succeeded or failed.

1:50 mattmoss: The mvn command in that link will create a local repo, and then install it to the usual maven repo (usually ~/.m2 ?), from which the project will get its deps.

1:51 Good luck!

1:53 shriphani: generally, what is the deal with the artifactId?

1:54 What is it supposed to signify i.e. ?

1:55 akhudek: shriphani: it is from java land

1:56 the group id is intended to be the group that created it (e.g. com.mycompany)

1:56 the artifact id is the thing itself

1:57 e.g. library name

1:57 clojure authors often ignore this and set the group and artifact to be the same

1:58 when you specify [my-library "1.0"] in lein, it just expands it such that both the group and artifact id are my-library

1:59 shriphani: hmm. I seee.

1:59 mattmoss: is the repo supposed to be in the root of the lein project ?

2:00 I put it in ~ and mvn had no problems building it.

2:01 but lein deps complains.

2:02 oh wow maven created a "~" directory in my folder. omg.. the jvm is a harsh place.

2:13 akhudek: shriphani: why not just mvn install?

2:13 or install the jar via mvn directly if it's a single jar

2:14 http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

2:14 both those method should install to your local repostiory and lein will pick it up automatically

2:15 shriphani: akhudek: I did a deploy:deploy-file thingy that mattmoss gave me

2:15 but lein deps is dying.

2:15 and I can't decipher the error. Do you want to take a look @ my project.clj ?

2:16 akhudek: you are trying to do a project local repo?

2:17 instead of using your user local repo?

2:17 shriphani: well I just want to use a jar. I don't really care..

2:17 akhudek: if it's one jar with no dependencies

2:18 just use the 3rd-party-jars-local link I pasted

2:18 shriphani: ah ok. And then how do I use it in clojure?

2:19 akhudek: in lein deps add an entry: [group-id/artifact-id "version"]

2:19 where the group, artifact, and version match whatever you put on the command line

2:19 packaging should be jar

2:20 no need for any extra repo links

2:21 shriphani: ok lein deps exited without barfing. So that's good right?

2:21 akhudek: yes

2:21 should be good to go I think

2:22 shriphani: so if lein deps had an entry of the form: local/heideltime "1.0.0", how do I use it? Like any other clojure jar ?

2:22 akhudek: yes, it will have a namespace like all java libraries and clojure libraries

2:23 so either impoort the right classes as with standard java interop

2:23 or if it's a clojure lib then require the right things

2:23 (though if it was a clojure lib you could have just did "lein install" to get it to install locally!)

2:24 shriphani: no it is a java lib.

2:24 hmm I used the same namespace as I have in eclipse and lighttable is complaining.

2:25 akhudek: in an :import?

2:25 shriphani: in an (import)

2:25 akhudek: should be (import '[my.namespace Class])

2:25 I think

2:26 note the space

2:27 shriphani: umm that's what I have

2:27 is it a light table thing?

2:27 akhudek: could be, not sure, did you try it in a normal repl?

2:27 shriphani: lein run on the file didn't complain

2:28 akhudek: try lein repl

2:28 and importing it manually

2:28 shriphani: ClassNotFoundException de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone java.net.URLClassLoader$1.run (URLClassLoader.java:202)

2:28 :_(

2:29 btw, I didn't use the group or the artifact in the import statement.

2:29 the groupid was local and artifact was heideltime

2:29 is that a problem or will maven sort things out ?

2:30 akhudek: hm, that shouldn't matter

2:30 shriphani: I see.

2:30 akhudek: is the library in the list when you do lein deps :tree

2:30 shriphani: and I just pasted the (import .**) in my repl. that was right wasn't it ?

2:30 [local/heideltime "1.0.0"]

2:30 yup

2:31 akhudek: what is (import .**) supposed to do?

2:31 import a bunch of things?

2:31 not sure if that works in clojure

2:31 shriphani: umm no.

2:31 I did: (import '(de.unihd.dbs.heideltime.standalone HeidelTimeStandalone))

2:31 akhudek: ah, ok, that looks right too

2:31 odd

2:32 shriphani: is there like a make clean I am supposed to do ?

2:32 akhudek: lein clean

2:32 it can help get rid of weirdness sometimes

2:33 shriphani: and then deps again ?

2:33 akhudek: deps isn't really needed in lein2

2:33 shriphani: nope classnotfound

2:33 akhudek: think it just checks things now

2:34 is the right jar sitting in ~/.m2/repository?

2:34 shriphani: ls ~/.m2/repository/heideltime/heideltime/1.0/

2:34 _maven.repositories heideltime-1.0.jar

2:34 lazybot: bin data dev etc home lib media opt sbin selinux src sys var

2:34 shriphani: is that a problem ?

2:35 wow... i could make lazybot run commands on a root dir ?

2:35 akhudek: haha, it's probably just chirping up something someone told it previously

2:35 shriphani: well I have 1.0.0 in my project.clj

2:36 akhudek: that looks like it should be accessed by [heideltime "1.0"]

2:36 shriphani: could the number of periods be a problem ?

2:36 so [local/heideltime "1.0"] right ?

2:36 hmm lein deps couldn't resolve it..

2:37 and in the error msg, no mention of ~/.m2

2:37 just clojars and repo1

2:37 akhudek: no, just [heideltime "1.0"]

2:37 it never mentions .m2

2:37 shriphani: ok that works (for lein deps at least)

2:38 akhudek: that's the local repository that everything gets stored in

2:38 even the things you pull from clojars

2:38 or other maven repositories

2:39 shriphani: aaaah ! ClassNotFoundException org.apache.uima.UimaContext java.net.URLClassLoader$1.run (URLClassLoader.java:202)

2:39 ugh.

2:39 akhudek: haha, well, there is probably a maven source for uima somewhere

2:39 shriphani: but that happened when I asked it to do heideltime

2:39 I mean in the repl I pasted: (import '(de.unihd.dbs.heideltime.standalone HeidelTimeStandalone))

2:40 akhudek: guess it's a dependency

2:40 shriphani: but I used that jar in java (eclipse) when I added ti as an external lib.

2:40 so how did it work then?

2:42 akhudek: maybe eclipse pulled the dependency automatically for you?

2:42 shriphani: hmm.. I am also an eclipse noob so I won't try to answer that.

2:42 oh god. so much pain.

2:43 ok I added it to project.clj and did lein deps and I get the same error in the repl.

2:43 what is wrong now...

2:43 akhudek: are you sure you installed the right jar?

2:44 shriphani: well there is only 1 jar...

2:44 that I am trying to install..

2:45 the name changed in ~/.m2 though

2:45 the local file has a name that contains much of the namespace in it.

2:45 in ~/.m2 it is just heideltime-1.0.har

2:45 jar *

2:46 akhudek: is there a .m2/local/heideltime ?

2:46 shriphani: nope.

2:46 just ~/.m2/repository/heideltime

2:46 akhudek: what was your maven install string again?

2:47 shriphani: mvn install:install-file -DgroupId=local -DartifactId=heideltime -Dversion=1.0.0 -Dpackaging=jar -Dfile=de.unihd.dbs.heideltime.standalone.jar

2:49 akhudek: should it have created a ~/.m2/local ?

2:49 akhudek: I thought so :-/

2:50 shriphani: ugh. there's a local-repository where it dumped some stuff from a previous command

2:50 that has a local/

2:50 let me rm that thing and try again

2:50 nstalling /Users/shriphani/Documents/heritrix-inspector/de.unihd.dbs.heideltime.standalone.jar to /Users/shriphani/.m2/repository/local/heideltime/1.0.0/heideltime-1.0.0.jar

2:50 wooo!

2:51 now ~/.m2/repository/local/heideltime/1.0.0/ has _maven.repositories heideltime-1.0.0.jar heideltime-1.0.0.pom in it. that's good right ?

2:51 akhudek: looks right

2:52 change your lein dep to match

2:52 shriphani: so local/heideltime

2:52 akhudek: and try it out in the repl

2:52 yes, with version 1.0.0

2:53 shriphani: ClassNotFoundException de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone java.net.URLClassLoader$1.run (URLClassLoader.java:202)

2:53 ugghh!

2:54 akhudek: :-(

2:54 shriphani: dammit!

2:55 lein repl must be run from the project root isn't it?

2:55 akhudek: yes

2:56 shriphani: why does it never work :_(

2:58 akhudek: any other ideas ?

2:58 akhudek: check lein deps :tree again

2:59 if it looks right, then I am at a loss

3:00 try lein clein and restart the repl

3:00 shriphani: [local/heideltime "1.0.0"]

3:00 is in :tree

3:02 yeah still fails...

3:02 can I just import everything from the namespace ?

3:02 what's the syntax ?

3:03 akhudek: no

3:03 don't think so

3:03 lein classpath

3:03 should show the jar

3:04 if it is in the list, then you should have access to it and the problem is something else

3:04 shriphani: /Users/shriphani/.m2/repository/local/heideltime/1.0.0/heideltime-1.0.0.jar

3:04 yup its in there.

3:04 ughh..

3:05 akhudek: then the namespace or class name must be different in that version, or the jar might be corrupt?

3:05 shriphani: can eclipse see this maven repo then?

3:05 akhudek: yes

3:05 shriphani: or does that require some magic too?

3:06 akhudek: that might be where that other jar came from actually

3:06 installed via eclipse

3:06 btw, looking at the soruce, the standalone version does require uima

3:08 shriphani: the source of waht ?

3:08 heideltime ?

3:08 akhudek: yes

3:08 shriphani: hmm..

3:08 well I have that in my project.clj

3:08 [org.apache.opennlp/opennlp-uima "1.5.2-incubating"]


3:08 oh wait that might not be what it wants eh ?

3:09 akhudek: if I had to guess, the other library that you have in your .m2, the first one we tried, was from eclipse

3:09 and is probably correct

3:09 https://code.google.com/p/heideltime/source/browse/src/de/unihd/dbs/heideltime/standalone/HeidelTimeStandalone.java?r=00785fb7d205c2dd5a3b7ea855d556ee836c93ee

3:10 shriphani: hmm. So if I pull the right uima from maven, I should be good to go ?

3:10 from here i.e. :http://mvnrepository.com/artifact/org.apache.uima

3:10 akhudek: perhaps, though I'm not sure what is going on with your local jar that you installed

3:10 lein will automatically check the main maven repository btw

3:10 so just put in the dep for it

3:11 in any case, I must go

3:11 hope you manage to get it working!

3:11 shriphani: ah man. thanks for the help.

3:11 Pupnik-: which of the clojure books is generally recommended?

3:12 (for someone new to functional programming)

3:15 akhudek: Pupnik-: Pragamming Clojure is good for people coming from langauges like ruby/python and includes the web stack. Joy of Clojure is great for a more technical treatment

3:15 night!

3:15 Pupnik-: clojure programming is the other new one i found

3:21 shriphani: interesting the jar file mvn installed has nothing but a META-INF and a README.md in it.

3:29 akhudek: I got it to work. you were right, the jar was broken.

3:37 clifton: i come from Ruby, and Clojure Programming (O'Reilly) is the best programming book I've ever read

3:37 really great examples, fast pace, completeness, it's just a great book

3:48 Pupnik-: thanks

3:57 Ember-: I liked Programming Clojure

3:57 this http://pragprog.com/book/shcloj2/programming-clojure

4:00 Pupnik-: ok so thats 2 votes for programming clojure and 1 for clojure programming

4:00 anyone read both?

4:01 (although i suppose thats unlikely really)

4:01 what was your background before reading it Ember- ?

4:08 Ember-: Pupnik-: java background

4:09 and web

5:13 shriphan`: Hi. I am having some issues calling a public method of an object. Calling (.getMethods ..) on the classname shows the method but when I do (.fname (new ClassName constr_args) <fname_args>), it complains that it can't find the function name.

5:13 am I supposed to not use new or something ?

5:14 Ember-: ,(java.io.File. "foo")

5:14 clojurebot: eval service is offline

5:14 Ember-: &(java.io.File. "foo")

5:14 lazybot: ⇒ #<File foo>

5:14 Ember-: I usually use that syntax

5:16 shriphan`: Ember-: was that for me?

5:16 Ember-: yes

5:17 shriphan`: well that didn't work...

5:17 Ember-: &(.doubleValue (java.lang.Integer 3))

5:17 lazybot: java.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn

5:17 shriphan`: the method is overloaded... that a problem ?

5:17 Ember-: &(.doubleValue (java.lang.Integer. 3))

5:17 lazybot: ⇒ 3.0

5:18 shriphan`: (.process (HeidelTimeStandalone. Language/ENGLISH DocumentType/COLLOQUIAL OutputType/TIMEML) "Friday 2012")

5:18 The constructor returns an object alright.

5:18 the .process complains that it doesn't exist.

5:19 yet when I do .getMethods on HeidelTimeStandalone, it is cool.

5:19 Ember-: well, are you absolutely sure it *does* exist :)

5:19 shriphan`: i.e. I see a .process in that list.

5:19 terom: maybe it's a private method+

5:19 ?

5:19 Ember-: or protected

5:19 shriphan`: no. public.

5:20 Ember-: sounds wierd

5:20 shriphan`: #<Method public java.lang.String de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.process(java.lang.String,de.unihd.dbs.heideltime.standalone.components.ResultFormatter)

5:21 Ember-: you're passing only one parameter

5:21 it requires two

5:21 String and ResultFormatter

5:21 shriphan`: weird. the source exposes a single arg method.

5:21 Ember-: well, that method you pasted requires two

5:22 shriphan`: hmm. so that not-found error msg is standard ?

5:22 i mean even when the sig is diff from the call ?

5:23 Ember-: if you have a one arg method signature which is public you should be able to call it no problemo

5:23 and I'm 100% certain you can. I'd double check that your java class is actually the same you think it is

5:23 maybe your clojure code sees an old version without the single arg method

5:27 shriphan`: Ember-: that is possible. I had to screw around too much with maven to get it working and I manually moved this jar in there.

5:27 Also, it returns and then throws an exception. Most fascinating thing ever.

5:29 Ember-: shriphan`: I'd look into that then

5:29 shriphan`: yea it is definitely confused.

5:57 borkdude: Ember- did you already solve your problem?

5:57 Ember-: yeah, did it the old fashioned way in the end

5:57 not pretty but works

5:58 I did check your refheap paste

5:58 I had to write my own zipper to make it work and even then it didn't really do what I needed

5:58 finally I gave up and decided to write it just for this case

5:59 borkdude: Ember- you can see the path it takes, but those are not equal to keys for get-in.

5:59 Ember-: indeed

5:59 borkdude: Ember- your approach: just try a lot of keys, brute force or smth?

6:00 Ember-: borkdude: depth-first search for a pre defined structure

6:00 map-indexed + bunch of other stuff

6:00 recursive function calls, stack consuming

6:00 not a problem in my case

6:00 stack will NOT end in this case :)

6:00 borkdude: ok

6:01 Ember-: I'd guess worst case scenario is something like 20 nested function calls

6:02 but I did learn a lot about zippers on the way

6:03 so definetly not wasted time :)

6:03 especially since this is my own personal project without tight deadlines

7:29 jimkcar: anyone in here that can answer a vim/clojure question?

7:32 its more of an annoyance than anything else but for some reason when I can't get vim to put closing parens on the end of the line. They always seem to end up on their own line.

8:19 clojure-new: Hello, can you tell what i'm doing wrong? http://cljbin.com/paste/51334e2ae4b0f3b237b3f7a9

8:20 I'm trying to require feedparser-clj.core as feed but fail.

8:28 borkdude: I saw this https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint.clj contains load statements

8:28 is that supposed to be?

8:29 clojure-new: borkdude: I don't get it.

8:29 jimkcar: @clojure-new in your main defn :feed/title should be feed/title

8:29 you don't use a colon there

8:31 clojure-new: jimkcar: http://cljbin.com/paste/513350c3e4b0f3b237b3f7aa It still triggers error. And in console:

8:31 Exception in thread "main" java.lang.RuntimeException: No such var: feed/title, compiling:(rss/core.clj:6)

8:32 Caused by: java.lang.RuntimeException: No such var: feed/title

8:33 borkdude: clojure-new it says that in the namespaces feed there is no var (function) called title

8:33 jimkcar: doesn't look to be a function called title in feed

8:34 looks like you're trying to extract the :title from feed/feed-parse return value

8:35 clojure-new: jimkcar: Yep.

8:35 With this http://cljbin.com/paste/513351b3e4b0f3b237b3f7a i've got, Exception in thread "main" java.lang.RuntimeException: No such var: feed/feed-parse, compiling:(rss/core.clj:6)

8:35 jimkcar: http://cljbin.com/paste/513351dde4b0f3b237b3f7ac

8:37 clojure-new: clojure-new: Yeah, but now it complains about feed/feed-parse...

8:37 jimkcar: Oh, wrong function name, sorry. It works now, thanks!

8:38 jimkcar: looks like there is a parse-feed function and a make-feed function but no feed-parse

8:38 cool

10:11 ayia: Hi guys. I am struggling the 4clojure.com, the "Count a Sequence" problem (https://www.4clojure.com/problem/22). In the solutions of users I follow I found the following one: reduce #(or (+ % 1) %2) 0. But I can't understand why it works... Can anybody explain me? I know that reduce applies consequentially given function position to each element of the given sequence and the result of previous "application"… So let we have '(1 2 3) as a seq. The

10:11 n at first iteration the #(or (+ % 1) %2) will get 0 and 1 as arguments, and all these arguments will be evaluated as (+ (0 1) 1), or what? I can't get this...

10:51 callenbot: ayia: it's an or

10:52 ayia: callenbot: but what then?

10:52 TimMc: ayia: At the first iteration, that would be (or (+ 1 1) 2) -> (or 2 2) -> 2

10:52 callenbot: ayia: it returns the result of incrementing the accumulator, or if the 'or' returns false, it'll just return the second argument.

10:52 which I believe in this case is the acum

10:52 accum*

10:59 ayia: callenbot: I can't understand why the first iteration will be (or (+ 1 1) 2) -> ... "%" in the (+ % 2) should be (0 1), shouldn't it? since the function gets two arguments: 0 and first element of the sequence, 1...

11:01 the original call should be something like: reduce #(or (+ % 1) %2) 0 (list 1 2 3)

11:07 callenbot: ayia: decompose the function literal into a defn with print statements

11:08 ayia: form hypotheses - then test them.

11:08 ayia: callenbot: thanks friend! The easiest way... Don't know why I did not get this by my own...

11:09 callenbot: ayia: Iuno. Programmers tend to get...get stuck in loops...

11:09 ayia: avoid that.

11:43 t-goossens: For all belgian clojurians (or other people interested in this) : i'm pleased to announce the first every belgian clojure meetup group. Starting this month! http://lanyrd.com/2013/belgiumclj

11:45 clojure-new: Is there guys familiar with lanterna/clojure-lanterna? Can you explain why this produces column of c's and not a b c column?

11:45 (for [str '("a" "b" "c") row [0 1 2]] (do (s/put-string screen 0 row str) (s/redraw screen)))

11:46 gfredericks: lynaghk: ping

11:58 octagon: clojure-new: it's because of the for loop you have there

11:58 ,(for [str '("a" "b" "c") row [0 1 2]] (prn [row str]))

11:58 clojurebot: eval service is offline

11:59 gfredericks: ,(println "eval service is offline")

11:59 clojurebot: eval service is offline

11:59 johndeo: FInally taking some time to check out Leiningen. I downloaded the script and now I'm going thru the tutorial at https://github.com/technomancy/leiningen/blob/stable/doc/TUTORIAL.md

11:59 octagon: clojure-new: try that in your repl, and look at how you get [0 "c"] [1 "c"] [2 "c"] at the end

12:01 brum: is there a leiningen template for creating mvc projects with dependencies like ring added

12:01 not that it takes much work, just coming from ruby to clojure and want to play around and make sure i have everything set up correctly

12:04 mpfundstein: is someone in the mood to do a code review (https://gist.github.com/MarkusXite/f99abde7f67eca751d63) .. datasource included + expected outcome. I am mostly interested where stuff can be more in the clojure-way and where i can improve it (clojure n00b)

12:05 gfredericks: mpfundstein: don't use use

12:05 (:require [clojure.java.io :as io] [clojure.string :as s])

12:05 mpfundstein: you mean in the beginning?

12:05 gfredericks: yeah line 9

12:05 mpfundstein: ok

12:05 what is the reason?

12:05 gfredericks: then you'll add prefixes to the usages of the vars in the respective namespaces

12:06 e.g., line 42 becomes s/split

12:06 then it's more explicit what your symbols are referencing

12:06 mpfundstein: aah ok

12:06 thats awesome

12:06 gfredericks: reader => io/reader

12:06 clojure-new: octagon: Oh, indeed...

12:07 mpfundstein: gfredericks: ok super, thanks for the info

12:07 any more feedback :-)

12:07 gfredericks: you can also (:require [clojure.java.io :refer [reader]]) if you like the naked symbols -- that way it's still explicit within the file

12:07 mpfundstein: i feel for example that i use (def every line to "redef outlet-map and total-transactions" is somhow unelegant

12:07 gfredericks: i write that down, very good

12:08 gfredericks: oh yeah don't do that

12:08 only def at the top level, not inside a function

12:08 clojure-new: octagon: But how can i fix it? I want for loop that iterates over '("a" "b" "c") and [0 1 2] simultaneosly.

12:08 mpfundstein: gfredericks: but how do i redef than outlet-map

12:08 gfredericks: clojure-new: ##(map vector '("a" "b" "c") [0 1 2])

12:08 mpfundstein: i need it to be persistent until the end

12:09 gfredericks: mpfundstein: I haven't understood the code yet so I don't know why you're using state -- probably you don't need it in the first place

12:09 mpfundstein: i have 2 states

12:09 total-transactions

12:09 and outlet-map

12:09 i read the source file

12:09 clojure-new: gfredericks: What does ## means?

12:09 mpfundstein: a csv

12:09 depeneding on two rows i have to add up certain values

12:09 gfredericks: clojure-new: I was trying to get lazybot to eval the expression

12:09 clojure-new: map vector will zip them up for you so you can loop over the pairs

12:09 mpfundstein: total-transactions (which is actually the sum of the last column)

12:09 clojure-new: Ah.

12:10 mpfundstein: and outlet-map which is a very small tree (outlet_a (category a, category b), outlet_b (category a, ... etc

12:10 johndeo: mpfundstein: What does it mean to use a leading '-' in front of function names?

12:11 smnirven: anybody have any experience using clojure.java.jdbc and postgres/postgis ?

12:11 mpfundstein: johndeo: than its private

12:11 gfredericks: smnirven: minus the postgis part, yes

12:11 johndeo: thx

12:11 gfredericks: mpfundstein: a) use (defn ^:private foo-bar ...) for private fns

12:11 smnirven: gfredericks: yeah im mostly scratching my head trying to figure out how to do geometry inserts

12:11 gfredericks: b) basically every do you have is unnecessary

12:12 c) 42 and 43 can be a single let

12:12 mpfundstein: gfredericks: ok, why? (i started clojure yesterday so sorry if i am a bit n00bish)

12:12 gfredericks: d) switch outlet-map and total-transactions to using atoms for the time being, and think about whether you really need state

12:12 mpfundstein: geoffeg: yes 42 and 43 one let.. true

12:13 gfredericks: atom ok

12:13 so (def outlet-map (atom hash-map)) ?

12:13 gfredericks: so 12 is (def outlet-map (atom {}))

12:13 and 45 is

12:13 (swap! outlet-map insert-in-map (second hash) (nth hash 2) transactions)

12:13 mpfundstein: yeah i saw swap

12:13 in a article

12:14 but the author doesnt explain what it does

12:14 gfredericks: similarly 47 is (swap! total-transactions + transactions)

12:14 mpfundstein: das is swap outlet-map with the return value of insert-in-map ?

12:14 gfredericks: yeah

12:14 mpfundstein: what is the diff of def than

12:14 gfredericks: and the current value gets passed in as the first arg

12:14 mpfundstein: in def i just assign new and the old one gets gc'ed right?

12:14 gfredericks: yes but that's not how def is meant to be used

12:14 TimMc: mpfundstein: -insert-in-map can be (assoc cache outlet (-sum-in-map (get cache outlet {}) vod-type transactions))

12:14 mpfundstein: gfredericks: i understand

12:15 TimMc: ok, i have to think about that :-)

12:15 gfredericks: def is for defining things just once, like your top-level functions

12:15 mpfundstein: gfredericks: ok, so its good style to not use it again, got it

12:15 gfredericks: exactly

12:15 mpfundstein: gfredericks: super

12:15 gfredericks: any more ? :D

12:15 TimMc: i will try that, thx for the input

12:16 TimMc: mpfundstein: -sum-in-map can be similarly modified

12:16 mpfundstein: TimMc: yeah, i had a hard time figuring out how to finally do it, if key exists work on value, otherwise create value

12:16 gfredericks: update-in with fnil

12:16 mpfundstein: TimMc: thought already that it must be easier

12:17 mye: hm, trying to use lein with a maven project, lein-maven can't be installed, lein-nevam given null pointer exception :-\

12:17 TimMc: mpfundstein: Nota bene: My suggestions there assume that there won't be a nil in cache.

12:17 &(get {:a nil} :a 0)

12:17 mpfundstein: TimMc: what is that?

12:18 TimMc: the &

12:18 TimMc: bot eval trigger

12:18 But the bot is dead or something.

12:18 $ping

12:18 mpfundstein: ah k

12:18 :D

12:18 yesterday it was '

12:18 '(println "hello")

12:18 ok wrong assumption

12:18 ^^

12:18 gfredericks: both the dang bots are dead

12:18 TimMc: ,(+ 1 2) ;; and clojurebot is down as well

12:18 clojurebot: eval service is offline

12:19 mpfundstein: hey , he responded

12:19 :-

12:19 )

12:19 TimMc: Oh, lazybot isn't even in the channel.

12:19 mpfundstein: ok thanks guys, i will no go on with my study of clojure

12:19 any tips :-)

12:19 ?

12:19 (avoid state hrhr)

12:19 gfredericks: :)

12:19 TimMc: mpfundstein: So yeah, take a look at (get {:a nil} :a 0) vs. (or (get {:a nil} :a) 0).

12:20 Don't use the suggestion I made unless you understand why those behave differently. :-)

12:20 mpfundstein: TimMc: that for sure

12:20 TimMc: i am not naive ;-)

12:20 gfredericks: does anybody know of a cljs lib for seeded randomness, or should I create one?

12:22 TimMc: mpfundstein: It's not a question of naïveté -- I shouldn't have made that suggestion without asking about cache. It's an inherently tricky case.

12:23 mpfundstein: TimMc: true, but as it is for my learning i consider it as good input

12:24 TimMc: the danger would be if i would blind-eyed take it as a definite answer and use in my programs

12:24 gfredericks: it seems rather stark that clojure.core's random functions don't have a *rand* var they rely on :(

12:25 smnirven: hey folks, im trying to get clojure.java.jdbc/execute! to work, anyone used that function?

12:27 frozenlock: Is there something I'm missing here? I use noir.response/json to encode a map into json. However the guy at the receiving end says the keywords with hypen '-' aren't working and ask me to convert them to underscores '_'. To my knowledge, '-' is a valid json character, is it not?

12:27 smnirven: gfredericks: okay, im going crazy, i know I just need an extra set of eyes to figure out why this doesnt work

12:27 gfredericks: https://gist.github.com/smnirven/5077092

12:28 gfredericks: smnirven: you never closed off your list of column names

12:28 smnirven: UGHHHHHHHHH

12:29 god i knew it was something stupid like that

12:33 gfredericks: okay, one more weird thing - when I try to load my file in nrepl, it says "No such var: sql/execute!"

12:34 gfredericks: you have (:require [clojure.java.jdbc :as sql])?

12:34 smnirven: aye

12:35 gfredericks: I have no ideas then

12:35 unless it's private

12:35 well that's probably not it

12:36 smnirven: yeah doesnt look like it

13:04 noncom: hi anyone familiar with Luminus web framework and creating forms in it?

13:06 edtsech: noncom: hi, it just uses hiccup for that

13:06 noncom: yeah, there is a single problem for me: how do i specify a link for action that is relative to the root address?

13:07 nightfly: A regular relative link?

13:08 frozenlock: in hiccup? IIRC "/some-url" will go to BASE-URL/some-url, while "some-url" will go yo BASE-URL/current-url/some-url (or vice versa)

13:10 noncom: oh, thanks!

13:18 gfredericks: it's just being translated into the href attribute directly, so it's subject to how the browser interprets it

13:18 smnirven: gfredericks: just fyi, i switched it up to use do-commands and that seems to be doing the trick

13:19 gfredericks: ah right

13:24 dobladez: ok, not really a Clojure question, but: Anybody using edn on client-side javascript?

13:25 I'm looking at https://github.com/shaunxcode/jsedn ; but seems to need a bit of modification to work outside of NodeJS ... Or am I missing something?

13:41 sritchie: do you guys have any good tips on configuring a ring app to force https for every URL?

13:42 or is that a bad idea, and should I restrict https to certain URLs only

13:42 weavejester: sritchie: Create some middleware that redirects if the URL scheme is :http

13:42 sritchie: weavejester: okay, and that's recommended over .htaccess tricks?

13:42 augustl: are there any ways to exclude dependencies from "lein uberwar", alternatively are there CLI tools to remove .jars from a .war?

13:43 weavejester: sritchie: Well, you can do it via any mechanism, it amounts to the same thing

13:43 augustl: err, "lein ring uberwar"

13:44 weavejester: augustl: A war file is just a zip, so easily modified with zip/unzip. You could use profiles to exclude jars as well.

13:44 augustl: I don't think there's an option for it, yet...

13:46 sritchie: weavejester: for heroku clojure apps, can one just add ".htaccess" to the resources folder?

13:46 weavejester: sritchie: I don't think so.

13:47 sritchie: I guess I could configure the middleware to only run in "production" mode

13:47 so no SSL cert is needed locally

13:47 just trying to figure out best practices here

13:48 weavejester: sritchie: If you're using Heroku, probably the best way to do it is to have some middleware that's applied if a certain environment variable is set, such as FORCE_SSL.

13:48 sritchie: weavejester: gotcha, makes sense

13:49 dobladez: sritchie: cemerick/friend has requires-schemes middleware that does channel security

13:50 sritchie: https://github.com/cemerick/friend#channel-security

13:50 sritchie: oh, cool

13:50 okay, great, there's my middleware.

13:51 thanks guys

13:52 augustl: weavejester: ah, profiles makes sense. I guess leiningen can exclude dependencies etc

13:53 weavejester: augustl: I believe so

13:53 augustl: trying to figure out how to best accommodate a tomcat7 setup where I want some of the .jars in the uberwars generated by lein ring to not be in the war, but in tomcat7's shared lib folder

13:53 weavejester: That sounds like a job for a profile

13:54 augustl: cool!

13:56 smnirven: anybody every use the postgres postgis functions with clojure.java.jdbc?

13:58 nightfly: I'm sure they have. Go ahead and ask you question.

14:02 augustl: smnirven: only used basic mysql with clojure.java.jdbc 0.23

14:02 smnirven: im continually beating my head against the wall cause I need to use a postgis geometry query inside of with-query-results

14:03 and when the query reaches postgres it interprets it as a varchar

14:03 let put what im trying todo in a gist

14:06 nightfly: augustl https://gist.github.com/smnirven/5077704

14:09 when I run my peek function, I get this error PSQLException The column index is out of range: 1, number of columns: 0. org.postgresql.core.v3.SimpleParameterList.bind (SimpleParameterList.java:53)

14:11 mye: anyone using autodoc with leiningen2?

14:11 I get an error when I put it in :user :plugins [lein-autodoc "0.9.0"]

14:12 augustl: smnirven: and I guess you've tried running a similar query in the postgres console?

14:12 smnirven: augustl: yep

14:12 augustl: here's my query in the postgres console

14:13 SELECT eggs.*, (ST_Distance(eggs.point, 'POINT(-78.51500 38.00705)'::geometry)) AS distance from eggs

14:13 augustl: that works splendidly in the postgres console

14:13 tomoj: 'POINT (? ?)' is quoted, so they're not parameters

14:15 smnirven: tomoj: its almost like I need to build up the POINT variable as its own string, and send that as the query param

14:16 tomoj: or maybe ST_Point(?, ?) ?

14:16 smnirven: there we go

14:16 I think I got it

14:16 ["SELECT eggs.*, (ST_Distance(eggs.point, ?::geometry)) AS distance FROM eggs" (str "POINT(" lng " " lat ")")]

14:16 tomoj: seems like a hack but it worked

14:19 augustl: ah

14:30 derekv: so if i have a niave bruteforce algo but it should be working lazily, I don't think it should run out of memory...

14:31 oh hey look it works if i crank up the memory

14:31 on an input size 21, have a feeling it wouldn't work for eg 30

14:38 weavejester: derekv: Are you holding onto the head of the seq?

14:39 derekv: That's the usual cause of a lazy algorithm consuming more memory than it should.

14:40 derekv: weavejester, ok... I've got a set, and I use subsets on that, then I filter, then I reduce.

14:40 which should leave me with one set (the optimum)

14:41 weavejester: subsets from where?

14:41 derekv: contrib.combinitorics

14:42 i'll paste

14:42 https://www.refheap.com/paste/12043 this is just the knapsack problem

14:43 and I just went for an obiovious to me brute force solution to start

14:43 still pretty new to functional programming and especially clojure so I'm not sure how to guage the cost of things.

14:45 weavejester: That looks okay, actually...

14:45 How large is "dolls"?

14:46 derekv: works fine on inputs like 5 or 6, but i have a functional test thats got 21

14:46 weavejester: derekv: A size of 21 runs out of memory?

14:46 derekv: That makes it think for a minute, and abort with default jvm settings. if i crank up xmx it finishes.

14:46 yea.

14:46 weavejester: So (count dolls) => 21

14:46 ?

14:46 derekv: yes.

14:47 let me get the exact error...

14:47 weavejester: Hmm, subsets *looks* lazy enough

14:48 And you're not holding onto the head of the seq

14:48 derekv: It says its lazy in the doc.

14:51 weavejester: derekv: I don't see a problem just looking at it, I'm afraid. You might want to build it up a bit at a time, to see where the issue might be.

14:54 derekv: https://www.refheap.com/paste/12044 this is the error, but I think thats just a normal out of memory error

14:59 is it possible Im holding onto it higher up in the stack? full code-> http://tinyurl.com/cu8lfhw I guess I'm not sure what holding onto the head of the seq means. unless reduce holds onto it

14:59 but reduce is just a recursion with accumulator right?

14:59 weavejester: derekv: Oh, that's not a normal out of memory error

15:00 That's an error thrown when too much time is spent GCing

15:00 derekv: JvmIsStupidAndWhyDoesntItSolveAllMyProblemsForMeException

15:00 weavejester: specificially "if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered"

15:00 derekv: hmm

15:01 That would still imply that a bunch of memory is being held at least temporarily right?

15:02 weavejester: derekv: Ohh, hum, you have some odd things in your code

15:02 derekv: no doubt

15:02 but not on purpose.

15:02 weavejester: derekv: You're using the very old clojure.contrib library, which was deprecated years ago

15:02 derekv: You probably want to use clojure.math.combinatorics instead: https://github.com/clojure/math.combinatorics

15:03 derekv: *sigh, I guess thats the drawback to the hyperavailability of solutions and example code on the internet

15:03 weavejester, nice I'll take a look

15:03 weavejester: Doll doesn't need to be a record, because you're not doing anything with protocols per se

15:03 I'm not sure whether using math.combinatorics will help, but it's worth using up-to-date code just in case there's some sort of leak in the older code.

15:05 It's a little strange you're returning a one-element set from your solver function...

15:05 You could also use preconditions inetad of solver-argument-validator

15:07 But… I'm not sure why the app would be spending so much time GCing...

15:07 derekv: weavejester, I tried the preconditions thing but couldn't get the syntax to work off the examples I was looking at.

15:08 weavejester: derekv: It would be something like...

15:08 derekv: The final (or initial, if reading top down) 'set' in the solver is just to make sure what is returned is a set... it should be a set of dolls, unless i'm misunderstanding what that does, but it seems to pass my unit tests

15:08 weavejester: {:pre [(number? max-weight) (pos? max-weight) (coll? dolls)]}

15:09 ,(set [1 2 3])

15:09 clojurebot: eval service is offline

15:09 weavejester: ~(set [1 2 3])

15:09 ibdknox: &(set [1 2 3])

15:09 weavejester: Hum, you might be right. I might be misremembering the syntax.

15:09 ibdknox: lazybot isn't here

15:10 This must be the apocalypse

15:10 Raynes: where's lazybot?

15:10 derekv: weavejester, yea I was trying that very early on and it just wouldn't work, so I gave up on it since i had like 1 hour into writing clojure at that point it was too confusing to fight with it over syntax when I had no clue why it wasn't working.

15:10 Raynes: Vacation.

15:11 ibdknox: We all need one

15:11 weavejester: derekv: Fair enough :)

15:11 On another note, has anyone heard of a project that uses git as a microblogging system?

15:11 Raynes: &(+ 3 3)

15:11 lazybot: ⇒ 6

15:12 derekv: weavejester, microblogging not sure... there's a bunch of static site generators that support blogging and integrate with git

15:12 yogthos: weavejester: that's more or less what I'm doing with the luminus docs site

15:12 * gfredericks just found the heck out of a cljs bug

15:12 ibdknox: weavejester: https://github.com/cloudhead/toto

15:12 gfredericks:

15:13 gfredericks: whoops, what bug?

15:13 weavejester: I mean, not a microblog website built on git, but a microblog system build from git and terminal commands

15:13 derekv: I was trying to find one that kept a seperation between the articles and the code , like seperate repositories

15:14 weavejester: I'm building one, and I don't think it's been done before, but it's always possible I've missed something.

15:14 derekv: weavejester, oh... you could rig something up with org-mode, git and remember if you live in emacs

15:14 ibdknox: I'm not sure I understand what that means :)

15:14 gfredericks: ibdknox: a scoping bug with (doseq [... :let [f #(...)]] ...)

15:14 making a gist now

15:15 weavejester: In the system I've got, I'm abusing git commits as microblog entries.

15:15 So I can type: git upto add "Doing something"

15:15 To view the entries: git upto log

15:15 yogthos: weavejester: should work pretty well, what I ended up doing is caching the pages locally, so if github goes down or gets slow there's no hit

15:16 weavejester: And to sync with a remote: git upto link git@…; git upto sync

15:16 ibdknox: haha

15:17 derekv: You really mean that small ... not sure why you'd need git for what amounts to a list of strings with possibly datestamps on them

15:17 gfredericks: ibdknox: https://gist.github.com/fredericksgary/5078092

15:17 yogthos: github does provide a nice webui for editing your md files :)

15:18 I just ended up doing this https://github.com/yogthos/luminus/blob/master/src/luminus/util.clj

15:18 clojure-new: sjl: Hello, i'm using your library(clojure-lanterna) and it's great! But is it possible to hide cursor?

15:18 weavejester: derekv: A static file works with only one user, but in a team you'd need to be able to sync messages without losing any.

15:19 ibdknox: gfredericks: huh, nice catch

15:20 gfredericks: looks like for does not have the same issue

15:20 * gfredericks to the jiras

15:22 gfredericks: looks like it's CLJS-39; I must not have the latest code? :/

15:23 supposedly fixed back in september

15:23 ibdknox: I'm on the latest

15:23 and it's definitely happenin

15:23 g

15:23 derekv: is all of clojure.contrib out of date?

15:25 where do I get that nice defnk macro

15:28 weavejester: derekv: You don't really need it for modern Clojure versions, as you can use destructuring

15:28 Although I guess the syntax might not be as nice.

15:34 ivan: did you know jdk.map.althashing.threshold exists http://docs.oracle.com/javase/7/docs/technotes/guides/collections/changes7.html

15:46 derekv: hmm it always craps out on the reduce is bag-weight

15:51 what would be better than defrecord for my items?

15:51 if this was C i'd just use a struct, that was what I was going for

15:54 xeqi: https://github.com/cemerick/clojure-type-selection-flowchart

15:56 ,"no eval? denied!"

15:56 clojurebot: "no eval? denied!"

15:56 hiredman: clojurebot: oomkiller?

15:57 clojurebot: oomkiller?

15:57 xeqi: ,(+ 1 2)

15:57 clojurebot: 3

15:57 Gabh mo leithscéal?

15:57 xeqi: hmm, guess it works now

15:57 hiredman: clojurebot: oomkiller is what you get for running on a t1.micro

15:57 clojurebot: You don't have to tell me twice.

15:58 akhudek: that chart is great!

16:00 gfredericks: ibdknox: oh good to know; I'm terrible at telling what version I'm on or running tests out of the project

16:00 how do we handle regressions on jira? new ticket or old ticket?

16:00 oh actually I think my bug is subtler than this one

16:14 Raynes: ibdknox: ohai

16:18 ibdknox: Raynes: hola

16:19 Raynes: ibdknox: How is the paredit contracting going?

16:19 I may have already asked this.

16:19 Apologies if I have.

16:19 ibdknox: fell through

16:19 Raynes: Shame.

16:19 ibdknox: I added auto-pair completion myself

16:19 I might add slurp and barf

16:19 Raynes: I bet it was like "Oh. Oh wait. I have to do this in javascript? Yeah, no."

16:20 ibdknox: haha

16:20 nah, he just got busy with other things

16:36 derekv: hey whats the lightest weight thing I can use to represent an aggregate collection of three things (preferabbly named), one short string and two ints

16:37 Raynes: A map?

16:38 derekv: map is lighter than record?

16:38 Raynes: If you don't need a type there is rarely a reason to use a record.

16:38 derekv: just curioust, probably the problem isn't with the data objects i'm using

16:38 ok

16:44 gfredericks: http://dev.clojure.org/jira/browse/CLJS-481

16:47 derekv: actually it can't be the problem, i got like 20 of these objects, i never 'change' them, just put them in different subsets, so the items themselves should never get dupblicated ...

17:00 bws: Hey looking for some help with an error during clojure koans

17:01 I get "clojure.lang.Keyword cannot be cast to java.lang.Number" when I try to solve the second problem in exercise 10 of the clojure koans

17:02 copy pasting that in a repl returns true

17:03 (= [0 1 2 3 4] (range 5)) is the problem that returns the error. Any helps appreciated. Thanks.

17:11 leku: works for me bws

17:12 bws: Thanks for trying it out leku

17:12 It works for me in the regular repl, but as a whole the koans script doesn't work for me when I enter that.

17:12 Raynes: Could you paste the whole thing on https://www.refheap.com?

17:13 bws: I'm trying to see if any of the previous solutions might somehow be causing some error.

17:13 But this only happens when I enter the solution to this question. If I delete it, it doesn't whine.

17:14 Raynes: We might be able to help, but we definitely need to see it in context.

17:14 bws: Raynes https://www.refheap.com/paste/12051

17:14 That's the one file (10th one in the exercise)

17:15 leku: what version of clojure are you using?

17:15 and java

17:15 java -version

17:15 Raynes: Why would that matter?

17:15 bws: clj 1.5

17:15 leku: just wondering

17:15 why wouldn't it?

17:15 bws: java 1.7

17:15 leku: those aren't good things to know?

17:16 bws: Well if it helps any, I did tyr it in clj 1.5 repl with the expected output

17:16 Raynes: This looks fine. Not sure what is going on.

17:17 bws: That's what's driving me crazy!

17:17 leku: lol i bet

17:17 i've had some weird crap happen to me lately too

17:17 frustrating

17:17 Raynes: I would expect that this is a problem with the koans.

17:18 leku: and clj 1.5 perhaps?

17:18 it was just released pretty recently right?

17:18 I just did the koans up to 10 I think a few days ago in 1.4

17:18 worked fine

17:19 bws: I mean the solution seems straightforward, there's definitely something funky going on with the koans runner or something perhaps.

17:19 Up until this one I didn't see any issues.

17:20 Going to dive into the runner script

17:21 Raynes: bws: Yeah, `lein koan run` is giving me the same failure in this situation. I call broken koans.

17:21 jcromartie: so I'm doing a presentation on Tuesday night on where FP fits in web programming

17:21 bws: Alright thanks for the confirmation.

17:21 Raynes: I'm pretty sure I know how to program in Clojure, so...

17:21 :p

17:22 jcromartie: I'm going to touch on Compojure and some of the functional aspects of Backbone and Underscore for JS code...

17:22 but I'm pretty much talking out my butt here

17:22 any thoughts?

17:22 bws: Hehe.. I'll just see if I can find out what the issue is. A little more learning. Thanks Raynes and leku

17:22 Raynes: jcromartie: Well, I'd start by not talking out of your ass. If you think you're doing that they probably will too. :p

17:23 jcromartie: I'll try

17:23 I mean the obvious starting point is that the request/response cycle lends itself to simple functions

17:23 which Compojure demonstrates nicely

17:24 and then using functional templates in Backbone gets away from stateful jQuery spaghetti

17:24 Raynes: jcromartie: You give 'em the old "Less state = easier to understand and reason about". You could also talk about how the Clojure stack is super minimal and pluggable. Show them how easy it is to switch between things like hiccup, laser, and clabango. Show them middleware and stuff.

17:24 jcromartie: not that these frameworks are the only options

17:24 yah

17:24 I am going to put together a little concurrent chat server

17:24 and show how it's a few lines of code, and handles some large number of concurrent connections

17:25 with no hiccups and no errors

17:25 as long as you keep things nice and pure

17:26 derekv: my app is spinning all four cpus pretty hard

17:26 it doesn't automatically parrellelize somehowe does it?

17:27 i can't even spell that word.

17:33 jcromartie: derekv: what is your app? can you show code?

17:39 bws: Raynes and leku: Confirmed with the author of clojure-koans, there is a bug in there.

17:40 Raynes: Excellent.

17:40 derekv: jcromartie, yea http://tinyurl.com/cu8lfhw

17:40 Raynes: Well, not excellent.

17:40 But great that you confirmed it.

17:40 derekv: jcromartie, cpu is expected not sure why it runs out of memory

17:41 or rather crashes due to gc overhead limit

17:41 bws: Now to figure out how to pull updated changes from the author's github repo into mine.

17:41 Adding upstream seems to be the solution.

17:42 derekv: and not sure why it uses all four cpus unless 300% is GC

17:42 jcromartie: derekv: 300% would be 3 cores, no?

17:42 derekv: jcromartie, thats what I meant yea sorry

17:43 jcromartie, it uses > 300% when running, closer to %400, on a 4core machine

17:45 seangrove: Is it possible to do deep destructing to avoid code like this? https://www.refheap.com/paste/5592dbe0999cd64c75c49db3e

17:45 (let [profile (get (first (get profile "profile")) "merges")] ...)

17:45 jcromartie: derekv: are you getting any OOM crashes?

17:46 derekv: I'm pretty sure that none of the combinatorics functions yield infinite seqs

17:46 derekv: but they can be very *very* large

17:46 and if you give them an infinite seq, then you will have problems

17:46 derekv: jcromartie, yes. usually GC overhead limit crash, sometimes heap space. it finishes if i turn up heap. input size 21

17:47 jcromartie, I thought it was lazy, but I was trying to figure that out ...

17:47 the subset function

17:49 21 should yield a couple million combinations I think, but they shouldn't all be in memory

17:49 jcromartie: yeah, they're lazy

17:49 they're all lazy

17:50 derekv: i figure you could get subsets by mapping bits in an int to items, then counting 0 - 2^n

17:50 so there'ss at least one way to do it without eating memory

17:51 jcromartie: derekv: but you're not giving any of those combinatorics functions an infinite seq, right?

17:51 derekv: how about some println debugging

17:51 derekv: jcromartie, good thought

17:52 i don't see how it should get anything infinate

17:52 leku: bws where was the bug?

17:52 sw1nn: anyone have any problems with nrepl-middleware/wrap-javadoc? I'm trying to pass local-paths to local javadocs and i get an exception when I do nrepl-jack-in: http://pastebin.com/KJAdH0Bw

17:53 bws: leku: The author said he'll fix it, I have no clue where it was. I'm independently trying to figure out.

17:53 leku: weird..

17:54 wonder how i got through them the other day

17:54 bws: Maybe some recent change

17:55 I forked it last night.

17:57 tomoj: seangrove: please put a newline before `profiles` :)

17:57 seangrove: tomoj: where the docstring should be?

17:58 tomoj: no I mean (map (fn ....) \newline coll) when (fn ...) is multiline

17:58 btw, your map fn appears to always return nil?

17:58 seangrove: Oh, yes, that's just a wip

17:59 I saw the (get (first (get ....))) and thought some deep destructing would really help clean it up

17:59 Not sure if that works in clojure though, so just asking

17:59 tomoj: it looks like [list-id {"profile" [{"merges" merges}]}] ?

18:00 seangrove: {"profile" [{"merges" [...]}]}

18:00 so a combination of arrays of maps with strings as keys

18:01 tomoj: er

18:01 I meant [list-id {[{merges "merges"}] "profile"}]

18:01 as the params

18:03 seangrove: profiles looks like {"list-id" {"profile" [{"merges" [{}]}]}}

18:03 tomoj: &((fn [[list-id {[{:strs [merges]}] "profile"}]] [list-id merges]) [[1 {"profile" [{"merges" [1 2 3]}]}]])

18:03 lazybot: ⇒ [[1 {"profile" [{"merges" [1 2 3]}]}] nil]

18:03 seangrove: Porting some ruby code to clojure that's dealing with a 3rd-party api

18:03 amalloy: seangrove: i don't think you're understanding tomoj's suggestion

18:03 seangrove: amalloy: I don't think so either :)

18:03 tomoj: well, close, I think..

18:03 seangrove: tomoj: That's great, thanks

18:04 I'll take that and run with it... certainly much nicer than my code

18:04 Is it possible to do the same thing inside of a `let` binding though?

18:05 Ah, yes, that should work :)

18:05 Thanks for that, sorry to be so thick

18:06 deeplloyd: on arch linux, when using lein as root i get a warning to set LEIN_ROOT. Where and to what do I set this to? Is it /usr/bin/lein ?

18:15 alandipert: deeplloyd: setting to anything non-empty will disable the warning

18:15 deeplloyd: e.g. # LEIN_ROOT="true" lein ...

18:15 deeplloyd: ok yea i just did 1 and it worked

18:16 just wanted to double check because il forget that mod down the line

18:16 if i run as not root i get a shit load of errors

18:17 TimMc: deeplloyd: Out of curiosity... why as root?

18:17 amalloy: deeplloyd: that's because you installed as root

18:18 definitely recommend installing as the user who's going to run it; just put it in ~/bin or somewhere

18:18 deeplloyd: i am required by pacman/aur to makepkg as non root, but in order to install i need to be root to run pacman

18:25 leku: anyone familiar with nanite?

18:28 derekv: its something in my input function

18:28 i thought actually there'd be no problem there since i use slurp

18:28 something about my input function makes the rest of it blow up

18:30 so I got a line like : (set (filter identity (map parse-doll (split-lines input)))) ... input comes from (slurp *in*) , so this shouldn't be an infinate seq? or is it?

19:01 muhoo: i'm dealing with a java library that has a big blob of global state, a server in fact. where's the best place to store it? an atom in a *foo* in an ns somewhere?

19:28 Rich_Morin: Clojure functions can be defined in multiple sections, each of which handles a different arity (ie, number of arguments). Is there a preferred name for these sections?

19:33 tomoj: "arities"? "overloads"?

19:33 Raynes: tomoj: Arities.

19:33 tomoj: is that metonymy?

19:37 TimMc: Pretty much.

19:37 amalloy: $dict metonymy

19:37 lazybot: amalloy: noun: A figure of speech in which one word or phrase is substituted for another with which it is closely associated, as in the use of Washington for the United States government or of the sword for military power.

19:39 TimMc: $dict synecdoche

19:39 lazybot: TimMc: noun: A figure of speech in which a part is used for the whole (as hand for sailor), the whole for a part (as the law for police officer), the specific for the general (as cutthroat for assassin), the general for the specific (as thief for pickpocket), or the material for the thing made from it (as steel for sword).

19:40 TimMc: All these violent examples.

19:40 Also, I had no idea that an amalloy was a figure of speech.

19:41 Rich_Morin: Calling the section of a function that handles a particular "arity" an "Arity" seems a lot like synecdoche. Is this common usage?

19:43 ayia: Hi guys, (cons x seq) returns a sequence where x is the first element and seq is the last. It there a function in clojure that returns a sequence where seq are the first elements and x is the last?

19:44 TimMc: ayia: concat is prety close

19:45 Just be warned that adding stuff onto the end of a seq tends to be relatively expensive.

19:49 ayia: TimMc: Thanks! What is it expensive? Is it expensive for all collections? or just for vector?

19:49 TimMc: Specifically for sequences, which are not vectors.

19:49 ayia: TimMc: oh...

19:49 TimMc: ~seqs and colls

19:49 clojurebot: seqs and colls is http://www.brainonfire.net/files/seqs-and-colls/main.html

19:50 TimMc: Sequences are not random access. You have to walk or rebuild them to read or modify them.

19:51 lazy seqs can allow you to build up a sequence starting at the head, but that's different than taking an existing seq and appending to it.

19:52 ayia: TImMc: so "more expensive" belongs only to sequences that are not lazy, correct?

19:54 TimMc: No, I only mentioned the lazy seq things because it's a way of *avoiding* appending.

19:54 If you're doing a lot of appending, perhaps you should be conj'ing onto a vector.

19:54 &(conj [1 2 3] :a)

19:54 lazybot: ⇒ [1 2 3 :a]

19:55 TimMc: That's an O(log n) operation. (Relatively fast.)

19:56 ayia: TimMc: hm... I see I am so week in this... Can you recommend me some article about all these "guts"? (so i won't waste your time) Or that article you already posted is enough?

19:58 TimMc: The thing I posted may not cover your questions -- that's really more about the relationship between sequences and collections, and I guess you're asking about performance and the appropriateness of various data structures.

20:00 ayia: This has some relevant info: http://clojure.org/data_structures#Data%20Structures-Collections

20:01 ayia: TimMc: yes, i asked about performance and "when use what"... big thanks for links! You helped me a lot!

20:02 TimMc: vectors are fast for: append, random read, random update, count

20:02 seqs are fast for: add/remove head

20:11 gfredericks: how are IPersistentList and IPersistentStack different?

20:11 oh it's an interface

20:12 well they both are

20:12 let's pretend I haven't said anything yet this evening.

20:15 derekv: this pretty much does it right here (filter #(let [s (reduce + %)] (and (> 200 s) (< 250 s))) (subsets (range 11 160 7)))

20:15 eats memory till the jvm chokes

20:16 gfredericks: (and (> 200 s) (< 250 s)) is always false ain't it?

20:17 Iceland_jack: Should it be (> 200 s 250) ?

20:17 gfredericks: that's even falser

20:17 Iceland_jack: *<

20:18 derekv: yea probably, its not finishing i'm just trying to isolate it

20:18 yedi: weavejester: thanks

20:19 weavejester: yedi: What did I do?

20:19 yedi: weavejester: lein-beanstalk

20:19 weavejester: yedi: Ohh

20:20 derekv: (filter #(let [s (reduce + %)] (= 88 s)) (subsets (range 0 44 22))

20:20 anouther type

20:20 typo

20:20 going to bed

20:20 weavejester: I really need to make the configuration of lein-beanstalk better

20:21 The default environments are bad, and the config map could be improved.

20:24 bws: Raynes leku: The author mentioned there was something funky going on with Clojure 1.3 behavior.

21:05 yedi: why might lein-beanstalk hang after creating the application war?

21:51 gfredericks: did you move to a different country?

21:52 dabd: no i didn't change anything

21:52 ivan: what does `locale` say?

21:52 dabd: where can i find it?

21:53 ivan: it comes with linux

21:53 gfredericks: clojurescript does not like js/undefined

21:53 dabd: i am running it on windows atm

21:54 ivan: http://stackoverflow.com/questions/5182451/how-to-format-double-with-dot

21:54 dabd: i noticed that when starting nrep-jack-in the nrepl-server buffer showed a message that it was retrieving clojure-1.6.0-master snapshot or something. But my proj.clj is using the latest stable version. Could it it be the cause?

22:09 fbernier: clojure noob here.. this seems to return a sequence, when what I want is the map inside the sequence .. how do I fetch it?

22:09 (fn [x y] (first (for [index y]

22:09 {index x})))

22:10 oops .. without the first

22:12 dabd: if I evaluate (java.util.Locale/getDefault) it shows

22:13 it returns* #<Locale en_US>

22:13 I'm not in the US but (format "%.1f" 0.5) should show 0.5 and not 0,5 right?

22:16 gfredericks: fbernier: y is a map and x is a key?

22:17 fbernier: gfredericks: yes

22:17 gfredericks: fbernier: (get y x) should work

22:17 or maybe even (y x) or (x y) depending on details

22:20 fbernier: gfredericks:actually its a 4clojure problem...

22:20 (= (__ 0 [:a :b :c]) {:a 0 :b 0 :c 0})

22:20 holo: hi

22:21 gfredericks: fbernier: you're supposed to assemble a map from a keylist and a val?

22:23 fbernier: "Write a function which takes a default value and a sequence of keys and constructs a map."

22:25 gfredericks: fbernier: so for always returns a sequence. That's what it's for.

22:25 functions you might be interested in looking at include hash-map, zipmap, into, reduce, assoc...

22:26 fbernier: gfredericks: ok thanks, got it with this but I get it's far from optimal:

22:26 gfredericks: you won't need all of those, there's just several different approaches you could have

22:26 fbernier: (fn [x y] (into {} (for [index y]

22:26 {index x})))

22:37 tomoj: I wonder if it makes sense to have function that turn reducers into kvreducer

22:39 Foxboron: Just came across Clozure. Obvious rip off?

22:39 brehaut: no

22:40 amalloy: Foxboron: is it obvious we ripped the name off of them?

22:40 Foxboron: amalloy: was more thinking the other way around

22:40 amalloy: only if rich has a time machine

22:40 derekv: clozure is older i think

22:40 amalloy: by a decade

22:41 Foxboron: amalloy: i do consider that plausible

22:42 derekv: from what i am reading is that the language it self is from the 80's. But they changed name in 2012.

22:50 ChongLi: rich definitely has a time machine

22:51 except I think his ideas are ripped off from the future!

22:54 dcolish: hah, yeah clozure is a just a little older

23:00 frenchyp: I am just starting to play with Seesaw.

23:00 I am trying to print debug information to the REPL from an event handler.

23:00 I understand that event handlers run in the UI thread, whose *out* isn't bound to my REPL.

23:00 So I am trying to work around that with the (let ... (binding ...)) trick from http://stackoverflow.com/a/4533791/127810 , but it isn't working.

23:00 My code is at https://www.refheap.com/paste/12062

23:00 Am I missing anything obvious?

23:01 leku: hey this is an emacs/paredit question I think, but how do I force it to delete a parens?

23:02 jao: leku, C-u <BACKSPACE>

23:02 frenchyp: leku: if parens are unbalanced or empty it works, otherwise it doesn't let you.

23:02 jao: or C-u C-d

23:02 leku: thx

23:02 frenchyp: jao: oh cool

23:02 leku: finally

23:02 thank you

23:03 jao: you're welcome

23:17 TimMc: leku: Selecting and then hitting C-w also works.

23:34 leku: i'm having a problem fetching some json data with clj-http and then parsing it with cheshire

23:34 https://www.refheap.com/paste/12064

23:35 TimMc: leku: I'm guessing client/get returns a response map.

23:35 Raynes: Yes.

23:35 leku: yeah

23:35 Raynes: ieure: (:body ..)

23:37 leku: basically I just want to get the data out of "values"

23:40 is json the best format to maybe get this data?

23:40 I think I have a few options

23:40 Raynes: Probably.

23:40 Unless edn is another option.

23:41 leku: looks like XML, tab-delimited, or JSON

23:41 Raynes: Yes, json is your best option.

23:41 (-> (client/get "http://waterservices.usgs.gov/nwis/iv?sites=05331580&period=P7D&format=json" {:accept :json}) :body parse-string)

23:41 leku: ^

23:41 leku: nice

23:42 thanks

23:42 Raynes: Also, to whoever ieure is, sorry for pinging you a minute ago. I mean't leku.

23:42 And now, I guess.

23:42 leku: oh ah hah

23:42 was wondering..

23:42 wicked

23:42 thanks

23:52 clifton: what is the newer site that is an alternative to clojars?

Logging service provided by n01se.net