#clojure logs

2013-03-03

00:03akhudekHm, 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?)
00:09amalloyeven better, akhudek: the tag names are stored as keywords, so all they cost you is a pointer, which you'd have to pay anyway
00:10akhudekamalloy: good point, forgot about that
00:12derekvlearning a new language while doing TDD is the worst thing ever
00:12mybuddymichaelderekv: Easy solution. Don't do TDD.
00:12mybuddymichael:-)
00:12derekvrequired
00:18derekvI tried print a collection to a string by doing a (reduce #(conj (print-item %) "\n") "Your items\n" items)
00:18derekvbut it doesn't like that.
00:18derekvrather it was more like (reduce #(conj % (print-item %1) "\n") "Your items\n" items)
00:19derekvthats not how conj work apperently
00:20tomoj% and %1 are the same, use %1 and %2 (or if you insist % and %2). and use str instead of conj
00:21tomojbut it sort of looks like you're trying to do (clojure.string/join \newline (map print-item items)) ?
00:22derekvtomoj, that looks good.
00:22tomojor say (->> items (map print-item) (cons "Your items") (clojure.string/join \newline))
00:23derekvgotchya
00:24derekvI knew there was a nice functional way to do it.
00:24derekvgetting late in the day
00:24derekvwhat is the name of the ->> function if I looked it up?
00:25mybuddymichaelderekv: Threading macros.
00:26jeremyheilerderekv, -> is "thread first" and ->> is "thread last"
00:26derekvIts just rearranging things for readability?
00:26jeremyheileryeah
00:50TimMcOr for unreadability. :-)
00:51TimMc&(((((((-> x (fn [] x))))))))
00:51lazybot⇒ #<sandbox20321$eval58027$x__58028 sandbox20321$eval58027$x__58028@1e30afc>
00:53frenchyphow to I print to repl in a seesaw callback function?
01:35shriphanihi. 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 ?
01:44mattmossshriphani: 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.
01:46shriphanimattmoss: 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)
01:49mattmossshriphani: My use is fairly simple... so I just use require to bring in the particular classes I need.
01:49shriphanimattmoss: and your local jar is a java jar?
01:49mattmossYup.
01:50shriphanimattmoss: thanks a lot. I'll report back if it succeeded or failed.
01:50mattmossThe 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.
01:51mattmossGood luck!
01:53shriphanigenerally, what is the deal with the artifactId?
01:54shriphaniWhat is it supposed to signify i.e. ?
01:55akhudekshriphani: it is from java land
01:56akhudekthe group id is intended to be the group that created it (e.g. com.mycompany)
01:56akhudekthe artifact id is the thing itself
01:57akhudeke.g. library name
01:57akhudekclojure authors often ignore this and set the group and artifact to be the same
01:58akhudekwhen you specify [my-library "1.0"] in lein, it just expands it such that both the group and artifact id are my-library
01:59shriphanihmm. I seee.
01:59shriphanimattmoss: is the repo supposed to be in the root of the lein project ?
02:00shriphaniI put it in ~ and mvn had no problems building it.
02:01shriphanibut lein deps complains.
02:02shriphanioh wow maven created a "~" directory in my folder. omg.. the jvm is a harsh place.
02:13akhudekshriphani: why not just mvn install?
02:13akhudekor install the jar via mvn directly if it's a single jar
02:14akhudekhttp://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
02:14akhudekboth those method should install to your local repostiory and lein will pick it up automatically
02:15shriphaniakhudek: I did a deploy:deploy-file thingy that mattmoss gave me
02:15shriphanibut lein deps is dying.
02:15shriphaniand I can't decipher the error. Do you want to take a look @ my project.clj ?
02:16akhudekyou are trying to do a project local repo?
02:17akhudekinstead of using your user local repo?
02:17shriphaniwell I just want to use a jar. I don't really care..
02:17akhudekif it's one jar with no dependencies
02:18akhudekjust use the 3rd-party-jars-local link I pasted
02:18shriphaniah ok. And then how do I use it in clojure?
02:19akhudekin lein deps add an entry: [group-id/artifact-id "version"]
02:19akhudekwhere the group, artifact, and version match whatever you put on the command line
02:19akhudekpackaging should be jar
02:20akhudekno need for any extra repo links
02:21shriphaniok lein deps exited without barfing. So that's good right?
02:21akhudekyes
02:21akhudekshould be good to go I think
02:22shriphaniso if lein deps had an entry of the form: local/heideltime "1.0.0", how do I use it? Like any other clojure jar ?
02:22akhudekyes, it will have a namespace like all java libraries and clojure libraries
02:23akhudekso either impoort the right classes as with standard java interop
02:23akhudekor if it's a clojure lib then require the right things
02:23akhudek(though if it was a clojure lib you could have just did "lein install" to get it to install locally!)
02:24shriphanino it is a java lib.
02:24shriphanihmm I used the same namespace as I have in eclipse and lighttable is complaining.
02:25akhudekin an :import?
02:25shriphaniin an (import)
02:25akhudekshould be (import '[my.namespace Class])
02:25akhudekI think
02:26akhudeknote the space
02:27shriphaniumm that's what I have
02:27shriphaniis it a light table thing?
02:27akhudekcould be, not sure, did you try it in a normal repl?
02:27shriphanilein run on the file didn't complain
02:28akhudektry lein repl
02:28akhudekand importing it manually
02:28shriphaniClassNotFoundException de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone java.net.URLClassLoader$1.run (URLClassLoader.java:202)
02:28shriphani:_(
02:29shriphanibtw, I didn't use the group or the artifact in the import statement.
02:29shriphanithe groupid was local and artifact was heideltime
02:29shriphaniis that a problem or will maven sort things out ?
02:30akhudekhm, that shouldn't matter
02:30shriphaniI see.
02:30akhudekis the library in the list when you do lein deps :tree
02:30shriphaniand I just pasted the (import .**) in my repl. that was right wasn't it ?
02:30shriphani [local/heideltime "1.0.0"]
02:30shriphaniyup
02:31akhudekwhat is (import .**) supposed to do?
02:31akhudekimport a bunch of things?
02:31akhudeknot sure if that works in clojure
02:31shriphaniumm no.
02:31shriphaniI did: (import '(de.unihd.dbs.heideltime.standalone HeidelTimeStandalone))
02:31akhudekah, ok, that looks right too
02:31akhudekodd
02:32shriphaniis there like a make clean I am supposed to do ?
02:32akhudeklein clean
02:32akhudekit can help get rid of weirdness sometimes
02:33shriphaniand then deps again ?
02:33akhudekdeps isn't really needed in lein2
02:33shriphaninope classnotfound
02:33akhudekthink it just checks things now
02:34akhudekis the right jar sitting in ~/.m2/repository?
02:34shriphanils ~/.m2/repository/heideltime/heideltime/1.0/
02:34shriphani_maven.repositories heideltime-1.0.jar
02:34lazybotbin data dev etc home lib media opt sbin selinux src sys var
02:34shriphaniis that a problem ?
02:35shriphaniwow... i could make lazybot run commands on a root dir ?
02:35akhudekhaha, it's probably just chirping up something someone told it previously
02:35shriphaniwell I have 1.0.0 in my project.clj
02:36akhudekthat looks like it should be accessed by [heideltime "1.0"]
02:36shriphanicould the number of periods be a problem ?
02:36shriphaniso [local/heideltime "1.0"] right ?
02:36shriphanihmm lein deps couldn't resolve it..
02:37shriphaniand in the error msg, no mention of ~/.m2
02:37shriphanijust clojars and repo1
02:37akhudekno, just [heideltime "1.0"]
02:37akhudekit never mentions .m2
02:37shriphaniok that works (for lein deps at least)
02:38akhudekthat's the local repository that everything gets stored in
02:38akhudekeven the things you pull from clojars
02:38akhudekor other maven repositories
02:39shriphaniaaaah ! ClassNotFoundException org.apache.uima.UimaContext java.net.URLClassLoader$1.run (URLClassLoader.java:202)
02:39shriphaniugh.
02:39akhudekhaha, well, there is probably a maven source for uima somewhere
02:39shriphanibut that happened when I asked it to do heideltime
02:39shriphaniI mean in the repl I pasted: (import '(de.unihd.dbs.heideltime.standalone HeidelTimeStandalone))
02:40akhudekguess it's a dependency
02:40shriphanibut I used that jar in java (eclipse) when I added ti as an external lib.
02:40shriphaniso how did it work then?
02:42akhudekmaybe eclipse pulled the dependency automatically for you?
02:42shriphanihmm.. I am also an eclipse noob so I won't try to answer that.
02:42shriphanioh god. so much pain.
02:43shriphaniok I added it to project.clj and did lein deps and I get the same error in the repl.
02:43shriphaniwhat is wrong now...
02:43akhudekare you sure you installed the right jar?
02:44shriphaniwell there is only 1 jar...
02:44shriphanithat I am trying to install..
02:45shriphanithe name changed in ~/.m2 though
02:45shriphanithe local file has a name that contains much of the namespace in it.
02:45shriphaniin ~/.m2 it is just heideltime-1.0.har
02:45shriphanijar *
02:46akhudekis there a .m2/local/heideltime ?
02:46shriphaninope.
02:46shriphanijust ~/.m2/repository/heideltime
02:46akhudekwhat was your maven install string again?
02:47shriphanimvn install:install-file -DgroupId=local -DartifactId=heideltime -Dversion=1.0.0 -Dpackaging=jar -Dfile=de.unihd.dbs.heideltime.standalone.jar
02:49shriphaniakhudek: should it have created a ~/.m2/local ?
02:49akhudekI thought so :-/
02:50shriphaniugh. there's a local-repository where it dumped some stuff from a previous command
02:50shriphanithat has a local/
02:50shriphanilet me rm that thing and try again
02:50shriphaninstalling /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
02:50shriphaniwooo!
02:51shriphaninow ~/.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 ?
02:51akhudeklooks right
02:52akhudekchange your lein dep to match
02:52shriphaniso local/heideltime
02:52akhudekand try it out in the repl
02:52akhudekyes, with version 1.0.0
02:53shriphaniClassNotFoundException de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone java.net.URLClassLoader$1.run (URLClassLoader.java:202)
02:53shriphaniugghh!
02:54akhudek:-(
02:54shriphanidammit!
02:55shriphanilein repl must be run from the project root isn't it?
02:55akhudekyes
02:56shriphaniwhy does it never work :_(
02:58shriphaniakhudek: any other ideas ?
02:58akhudekcheck lein deps :tree again
02:59akhudekif it looks right, then I am at a loss
03:00akhudektry lein clein and restart the repl
03:00shriphani [local/heideltime "1.0.0"]
03:00shriphaniis in :tree
03:02shriphaniyeah still fails...
03:02shriphanican I just import everything from the namespace ?
03:02shriphaniwhat's the syntax ?
03:03akhudekno
03:03akhudekdon't think so
03:03akhudeklein classpath
03:03akhudekshould show the jar
03:04akhudekif it is in the list, then you should have access to it and the problem is something else
03:04shriphani/Users/shriphani/.m2/repository/local/heideltime/1.0.0/heideltime-1.0.0.jar
03:04shriphaniyup its in there.
03:04shriphaniughh..
03:05akhudekthen the namespace or class name must be different in that version, or the jar might be corrupt?
03:05shriphanican eclipse see this maven repo then?
03:05akhudekyes
03:05shriphanior does that require some magic too?
03:06akhudekthat might be where that other jar came from actually
03:06akhudekinstalled via eclipse
03:06akhudekbtw, looking at the soruce, the standalone version does require uima
03:08shriphanithe source of waht ?
03:08shriphaniheideltime ?
03:08akhudekyes
03:08shriphanihmm..
03:08shriphaniwell I have that in my project.clj
03:08shriphani [org.apache.opennlp/opennlp-uima "1.5.2-incubating"]
03:08shriphani
03:08shriphanioh wait that might not be what it wants eh ?
03:09akhudekif I had to guess, the other library that you have in your .m2, the first one we tried, was from eclipse
03:09akhudekand is probably correct
03:09akhudekhttps://code.google.com/p/heideltime/source/browse/src/de/unihd/dbs/heideltime/standalone/HeidelTimeStandalone.java?r=00785fb7d205c2dd5a3b7ea855d556ee836c93ee
03:10shriphanihmm. So if I pull the right uima from maven, I should be good to go ?
03:10shriphanifrom here i.e. :http://mvnrepository.com/artifact/org.apache.uima
03:10akhudekperhaps, though I'm not sure what is going on with your local jar that you installed
03:10akhudeklein will automatically check the main maven repository btw
03:10akhudekso just put in the dep for it
03:11akhudekin any case, I must go
03:11akhudekhope you manage to get it working!
03:11shriphaniah man. thanks for the help.
03:11Pupnik-which of the clojure books is generally recommended?
03:12Pupnik-(for someone new to functional programming)
03:15akhudekPupnik-: 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
03:15akhudeknight!
03:15Pupnik-clojure programming is the other new one i found
03:21shriphaniinteresting the jar file mvn installed has nothing but a META-INF and a README.md in it.
03:29shriphaniakhudek: I got it to work. you were right, the jar was broken.
03:37cliftoni come from Ruby, and Clojure Programming (O'Reilly) is the best programming book I've ever read
03:37cliftonreally great examples, fast pace, completeness, it's just a great book
03:48Pupnik-thanks
03:57Ember-I liked Programming Clojure
03:57Ember-this http://pragprog.com/book/shcloj2/programming-clojure
04:00Pupnik-ok so thats 2 votes for programming clojure and 1 for clojure programming
04:00Pupnik-anyone read both?
04:01Pupnik-(although i suppose thats unlikely really)
04:01Pupnik-what was your background before reading it Ember- ?
04:08Ember-Pupnik-: java background
04:09Ember-and web
05:13shriphan`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.
05:13shriphan`am I supposed to not use new or something ?
05:14Ember-,(java.io.File. "foo")
05:14clojureboteval service is offline
05:14Ember-&(java.io.File. "foo")
05:14lazybot⇒ #<File foo>
05:14Ember-I usually use that syntax
05:16shriphan`Ember-: was that for me?
05:16Ember-yes
05:17shriphan`well that didn't work...
05:17Ember-&(.doubleValue (java.lang.Integer 3))
05:17lazybotjava.lang.ClassCastException: java.lang.Class cannot be cast to clojure.lang.IFn
05:17shriphan`the method is overloaded... that a problem ?
05:17Ember-&(.doubleValue (java.lang.Integer. 3))
05:17lazybot⇒ 3.0
05:18shriphan`(.process (HeidelTimeStandalone. Language/ENGLISH DocumentType/COLLOQUIAL OutputType/TIMEML) "Friday 2012")
05:18shriphan`The constructor returns an object alright.
05:18shriphan`the .process complains that it doesn't exist.
05:19shriphan`yet when I do .getMethods on HeidelTimeStandalone, it is cool.
05:19Ember-well, are you absolutely sure it *does* exist :)
05:19shriphan`i.e. I see a .process in that list.
05:19terommaybe it's a private method+
05:19terom?
05:19Ember-or protected
05:19shriphan`no. public.
05:20Ember-sounds wierd
05:20shriphan`#<Method public java.lang.String de.unihd.dbs.heideltime.standalone.HeidelTimeStandalone.process(java.lang.String,de.unihd.dbs.heideltime.standalone.components.ResultFormatter)
05:21Ember-you're passing only one parameter
05:21Ember-it requires two
05:21Ember-String and ResultFormatter
05:21shriphan`weird. the source exposes a single arg method.
05:21Ember-well, that method you pasted requires two
05:22shriphan`hmm. so that not-found error msg is standard ?
05:22shriphan`i mean even when the sig is diff from the call ?
05:23Ember-if you have a one arg method signature which is public you should be able to call it no problemo
05:23Ember-and I'm 100% certain you can. I'd double check that your java class is actually the same you think it is
05:23Ember-maybe your clojure code sees an old version without the single arg method
05:27shriphan`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.
05:27shriphan`Also, it returns and then throws an exception. Most fascinating thing ever.
05:29Ember-shriphan`: I'd look into that then
05:29shriphan`yea it is definitely confused.
05:57borkdudeEmber- did you already solve your problem?
05:57Ember-yeah, did it the old fashioned way in the end
05:57Ember-not pretty but works
05:58Ember-I did check your refheap paste
05:58Ember-I had to write my own zipper to make it work and even then it didn't really do what I needed
05:58Ember-finally I gave up and decided to write it just for this case
05:59borkdudeEmber- you can see the path it takes, but those are not equal to keys for get-in.
05:59Ember-indeed
05:59borkdudeEmber- your approach: just try a lot of keys, brute force or smth?
06:00Ember-borkdude: depth-first search for a pre defined structure
06:00Ember-map-indexed + bunch of other stuff
06:00Ember-recursive function calls, stack consuming
06:00Ember-not a problem in my case
06:00Ember-stack will NOT end in this case :)
06:00borkdudeok
06:01Ember-I'd guess worst case scenario is something like 20 nested function calls
06:02Ember-but I did learn a lot about zippers on the way
06:03Ember-so definetly not wasted time :)
06:03Ember-especially since this is my own personal project without tight deadlines
07:29jimkcaranyone in here that can answer a vim/clojure question?
07:32jimkcarits 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.
08:19clojure-newHello, can you tell what i'm doing wrong? http://cljbin.com/paste/51334e2ae4b0f3b237b3f7a9
08:20clojure-newI'm trying to require feedparser-clj.core as feed but fail.
08:28borkdudeI saw this https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint.clj contains load statements
08:28borkdudeis that supposed to be?
08:29clojure-newborkdude: I don't get it.
08:29jimkcar@clojure-new in your main defn :feed/title should be feed/title
08:29jimkcaryou don't use a colon there
08:31clojure-newjimkcar: http://cljbin.com/paste/513350c3e4b0f3b237b3f7aa It still triggers error. And in console:
08:31clojure-newException in thread "main" java.lang.RuntimeException: No such var: feed/title, compiling:(rss/core.clj:6)
08:32clojure-newCaused by: java.lang.RuntimeException: No such var: feed/title
08:33borkdudeclojure-new it says that in the namespaces feed there is no var (function) called title
08:33jimkcardoesn't look to be a function called title in feed
08:34jimkcarlooks like you're trying to extract the :title from feed/feed-parse return value
08:35clojure-newjimkcar: Yep.
08:35clojure-newWith 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)
08:35jimkcarhttp://cljbin.com/paste/513351dde4b0f3b237b3f7ac
08:37clojure-newclojure-new: Yeah, but now it complains about feed/feed-parse...
08:37clojure-newjimkcar: Oh, wrong function name, sorry. It works now, thanks!
08:38jimkcarlooks like there is a parse-feed function and a make-feed function but no feed-parse
08:38jimkcarcool
10:11ayiaHi 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:11ayian 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:51callenbotayia: it's an or
10:52ayiacallenbot: but what then?
10:52TimMcayia: At the first iteration, that would be (or (+ 1 1) 2) -> (or 2 2) -> 2
10:52callenbotayia: it returns the result of incrementing the accumulator, or if the 'or' returns false, it'll just return the second argument.
10:52callenbotwhich I believe in this case is the acum
10:52callenbotaccum*
10:59ayiacallenbot: 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:01ayiathe original call should be something like: reduce #(or (+ % 1) %2) 0 (list 1 2 3)
11:07callenbotayia: decompose the function literal into a defn with print statements
11:08callenbotayia: form hypotheses - then test them.
11:08ayiacallenbot: thanks friend! The easiest way... Don't know why I did not get this by my own...
11:09callenbotayia: Iuno. Programmers tend to get...get stuck in loops...
11:09callenbotayia: avoid that.
11:43t-goossensFor 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:45clojure-newIs there guys familiar with lanterna/clojure-lanterna? Can you explain why this produces column of c's and not a b c column?
11:45clojure-new(for [str '("a" "b" "c") row [0 1 2]] (do (s/put-string screen 0 row str) (s/redraw screen)))
11:46gfrederickslynaghk: ping
11:58octagonclojure-new: it's because of the for loop you have there
11:58octagon,(for [str '("a" "b" "c") row [0 1 2]] (prn [row str]))
11:58clojureboteval service is offline
11:59gfredericks,(println "eval service is offline")
11:59clojureboteval service is offline
11:59johndeoFInally 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:59octagonclojure-new: try that in your repl, and look at how you get [0 "c"] [1 "c"] [2 "c"] at the end
12:01brumis there a leiningen template for creating mvc projects with dependencies like ring added
12:01brumnot 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:04mpfundsteinis 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:05gfredericksmpfundstein: don't use use
12:05gfredericks(:require [clojure.java.io :as io] [clojure.string :as s])
12:05mpfundsteinyou mean in the beginning?
12:05gfredericksyeah line 9
12:05mpfundsteinok
12:05mpfundsteinwhat is the reason?
12:05gfredericksthen you'll add prefixes to the usages of the vars in the respective namespaces
12:06gfrederickse.g., line 42 becomes s/split
12:06gfredericksthen it's more explicit what your symbols are referencing
12:06mpfundsteinaah ok
12:06mpfundsteinthats awesome
12:06gfredericksreader => io/reader
12:06clojure-newoctagon: Oh, indeed...
12:07mpfundsteingfredericks: ok super, thanks for the info
12:07mpfundsteinany more feedback :-)
12:07gfredericksyou can also (:require [clojure.java.io :refer [reader]]) if you like the naked symbols -- that way it's still explicit within the file
12:07mpfundsteini feel for example that i use (def every line to "redef outlet-map and total-transactions" is somhow unelegant
12:07mpfundsteingfredericks: i write that down, very good
12:08gfredericksoh yeah don't do that
12:08gfredericksonly def at the top level, not inside a function
12:08clojure-newoctagon: But how can i fix it? I want for loop that iterates over '("a" "b" "c") and [0 1 2] simultaneosly.
12:08mpfundsteingfredericks: but how do i redef than outlet-map
12:08gfredericksclojure-new: ##(map vector '("a" "b" "c") [0 1 2])
12:08mpfundsteini need it to be persistent until the end
12:09gfredericksmpfundstein: 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:09mpfundsteini have 2 states
12:09mpfundsteintotal-transactions
12:09mpfundsteinand outlet-map
12:09mpfundsteini read the source file
12:09clojure-newgfredericks: What does ## means?
12:09mpfundsteina csv
12:09mpfundsteindepeneding on two rows i have to add up certain values
12:09gfredericksclojure-new: I was trying to get lazybot to eval the expression
12:09gfredericksclojure-new: map vector will zip them up for you so you can loop over the pairs
12:09mpfundsteintotal-transactions (which is actually the sum of the last column)
12:09clojure-newAh.
12:10mpfundsteinand outlet-map which is a very small tree (outlet_a (category a, category b), outlet_b (category a, ... etc
12:10johndeompfundstein: What does it mean to use a leading '-' in front of function names?
12:11smnirvenanybody have any experience using clojure.java.jdbc and postgres/postgis ?
12:11mpfundsteinjohndeo: than its private
12:11gfrederickssmnirven: minus the postgis part, yes
12:11johndeothx
12:11gfredericksmpfundstein: a) use (defn ^:private foo-bar ...) for private fns
12:11smnirvengfredericks: yeah im mostly scratching my head trying to figure out how to do geometry inserts
12:11gfredericksb) basically every do you have is unnecessary
12:12gfredericksc) 42 and 43 can be a single let
12:12mpfundsteingfredericks: ok, why? (i started clojure yesterday so sorry if i am a bit n00bish)
12:12gfredericksd) switch outlet-map and total-transactions to using atoms for the time being, and think about whether you really need state
12:12mpfundsteingeoffeg: yes 42 and 43 one let.. true
12:13mpfundsteingfredericks: atom ok
12:13mpfundsteinso (def outlet-map (atom hash-map)) ?
12:13gfredericksso 12 is (def outlet-map (atom {}))
12:13gfredericksand 45 is
12:13gfredericks(swap! outlet-map insert-in-map (second hash) (nth hash 2) transactions)
12:13mpfundsteinyeah i saw swap
12:13mpfundsteinin a article
12:14mpfundsteinbut the author doesnt explain what it does
12:14gfrederickssimilarly 47 is (swap! total-transactions + transactions)
12:14mpfundsteindas is swap outlet-map with the return value of insert-in-map ?
12:14gfredericksyeah
12:14mpfundsteinwhat is the diff of def than
12:14gfredericksand the current value gets passed in as the first arg
12:14mpfundsteinin def i just assign new and the old one gets gc'ed right?
12:14gfredericksyes but that's not how def is meant to be used
12:14TimMcmpfundstein: -insert-in-map can be (assoc cache outlet (-sum-in-map (get cache outlet {}) vod-type transactions))
12:14mpfundsteingfredericks: i understand
12:15mpfundsteinTimMc: ok, i have to think about that :-)
12:15gfredericksdef is for defining things just once, like your top-level functions
12:15mpfundsteingfredericks: ok, so its good style to not use it again, got it
12:15gfredericksexactly
12:15mpfundsteingfredericks: super
12:15mpfundsteingfredericks: any more ? :D
12:15mpfundsteinTimMc: i will try that, thx for the input
12:16TimMcmpfundstein: -sum-in-map can be similarly modified
12:16mpfundsteinTimMc: yeah, i had a hard time figuring out how to finally do it, if key exists work on value, otherwise create value
12:16gfredericksupdate-in with fnil
12:16mpfundsteinTimMc: thought already that it must be easier
12:17myehm, trying to use lein with a maven project, lein-maven can't be installed, lein-nevam given null pointer exception :-\
12:17TimMcmpfundstein: Nota bene: My suggestions there assume that there won't be a nil in cache.
12:17TimMc&(get {:a nil} :a 0)
12:17mpfundsteinTimMc: what is that?
12:18mpfundsteinTimMc: the &
12:18TimMcbot eval trigger
12:18TimMcBut the bot is dead or something.
12:18TimMc$ping
12:18mpfundsteinah k
12:18mpfundstein:D
12:18mpfundsteinyesterday it was '
12:18mpfundstein'(println "hello")
12:18mpfundsteinok wrong assumption
12:18mpfundstein^^
12:18gfredericksboth the dang bots are dead
12:18TimMc,(+ 1 2) ;; and clojurebot is down as well
12:18clojureboteval service is offline
12:19mpfundsteinhey , he responded
12:19mpfundstein:-
12:19mpfundstein)
12:19TimMcOh, lazybot isn't even in the channel.
12:19mpfundsteinok thanks guys, i will no go on with my study of clojure
12:19mpfundsteinany tips :-)
12:19mpfundstein?
12:19mpfundstein(avoid state hrhr)
12:19gfredericks:)
12:19TimMcmpfundstein: So yeah, take a look at (get {:a nil} :a 0) vs. (or (get {:a nil} :a) 0).
12:20TimMcDon't use the suggestion I made unless you understand why those behave differently. :-)
12:20mpfundsteinTimMc: that for sure
12:20mpfundsteinTimMc: i am not naive ;-)
12:20gfredericksdoes anybody know of a cljs lib for seeded randomness, or should I create one?
12:22TimMcmpfundstein: 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:23mpfundsteinTimMc: true, but as it is for my learning i consider it as good input
12:24mpfundsteinTimMc: the danger would be if i would blind-eyed take it as a definite answer and use in my programs
12:24gfredericksit seems rather stark that clojure.core's random functions don't have a *rand* var they rely on :(
12:25smnirvenhey folks, im trying to get clojure.java.jdbc/execute! to work, anyone used that function?
12:27frozenlockIs 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:27smnirvengfredericks: okay, im going crazy, i know I just need an extra set of eyes to figure out why this doesnt work
12:27smnirvengfredericks: https://gist.github.com/smnirven/5077092
12:28gfrederickssmnirven: you never closed off your list of column names
12:28smnirvenUGHHHHHHHHH
12:29smnirvengod i knew it was something stupid like that
12:33smnirvengfredericks: okay, one more weird thing - when I try to load my file in nrepl, it says "No such var: sql/execute!"
12:34gfredericksyou have (:require [clojure.java.jdbc :as sql])?
12:34smnirvenaye
12:35gfredericksI have no ideas then
12:35gfredericksunless it's private
12:35gfrederickswell that's probably not it
12:36smnirvenyeah doesnt look like it
13:04noncomhi anyone familiar with Luminus web framework and creating forms in it?
13:06edtsechnoncom: hi, it just uses hiccup for that
13:06noncomyeah, there is a single problem for me: how do i specify a link for action that is relative to the root address?
13:07nightflyA regular relative link?
13:08frozenlockin 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:10noncomoh, thanks!
13:18gfredericksit's just being translated into the href attribute directly, so it's subject to how the browser interprets it
13:18smnirvengfredericks: just fyi, i switched it up to use do-commands and that seems to be doing the trick
13:19gfredericksah right
13:24dobladezok, not really a Clojure question, but: Anybody using edn on client-side javascript?
13:25dobladezI'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:41sritchiedo you guys have any good tips on configuring a ring app to force https for every URL?
13:42sritchieor is that a bad idea, and should I restrict https to certain URLs only
13:42weavejestersritchie: Create some middleware that redirects if the URL scheme is :http
13:42sritchieweavejester: okay, and that's recommended over .htaccess tricks?
13:42augustlare there any ways to exclude dependencies from "lein uberwar", alternatively are there CLI tools to remove .jars from a .war?
13:43weavejestersritchie: Well, you can do it via any mechanism, it amounts to the same thing
13:43augustlerr, "lein ring uberwar"
13:44weavejesteraugustl: A war file is just a zip, so easily modified with zip/unzip. You could use profiles to exclude jars as well.
13:44weavejesteraugustl: I don't think there's an option for it, yet...
13:46sritchieweavejester: for heroku clojure apps, can one just add ".htaccess" to the resources folder?
13:46weavejestersritchie: I don't think so.
13:47sritchieI guess I could configure the middleware to only run in "production" mode
13:47sritchieso no SSL cert is needed locally
13:47sritchiejust trying to figure out best practices here
13:48weavejestersritchie: 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:48sritchieweavejester: gotcha, makes sense
13:49dobladezsritchie: cemerick/friend has requires-schemes middleware that does channel security
13:50dobladezsritchie: https://github.com/cemerick/friend#channel-security
13:50sritchieoh, cool
13:50sritchieokay, great, there's my middleware.
13:51sritchiethanks guys
13:52augustlweavejester: ah, profiles makes sense. I guess leiningen can exclude dependencies etc
13:53weavejesteraugustl: I believe so
13:53augustltrying 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:53weavejesterThat sounds like a job for a profile
13:54augustlcool!
13:56smnirvenanybody every use the postgres postgis functions with clojure.java.jdbc?
13:58nightflyI'm sure they have. Go ahead and ask you question.
14:02augustlsmnirven: only used basic mysql with clojure.java.jdbc 0.23
14:02smnirvenim continually beating my head against the wall cause I need to use a postgis geometry query inside of with-query-results
14:03smnirvenand when the query reaches postgres it interprets it as a varchar
14:03smnirvenlet put what im trying todo in a gist
14:06smnirvennightfly: augustl https://gist.github.com/smnirven/5077704
14:09smnirvenwhen 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:11myeanyone using autodoc with leiningen2?
14:11myeI get an error when I put it in :user :plugins [lein-autodoc "0.9.0"]
14:12augustlsmnirven: and I guess you've tried running a similar query in the postgres console?
14:12smnirvenaugustl: yep
14:12smnirvenaugustl: here's my query in the postgres console
14:13smnirvenSELECT eggs.*, (ST_Distance(eggs.point, 'POINT(-78.51500 38.00705)'::geometry)) AS distance from eggs
14:13smnirvenaugustl: that works splendidly in the postgres console
14:13tomoj'POINT (? ?)' is quoted, so they're not parameters
14:15smnirventomoj: its almost like I need to build up the POINT variable as its own string, and send that as the query param
14:16tomojor maybe ST_Point(?, ?) ?
14:16smnirventhere we go
14:16smnirvenI think I got it
14:16smnirven["SELECT eggs.*, (ST_Distance(eggs.point, ?::geometry)) AS distance FROM eggs" (str "POINT(" lng " " lat ")")]
14:16smnirventomoj: seems like a hack but it worked
14:19augustlah
14:30derekv 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:31derekvoh hey look it works if i crank up the memory
14:31derekvon an input size 21, have a feeling it wouldn't work for eg 30
14:38weavejesterderekv: Are you holding onto the head of the seq?
14:39weavejesterderekv: That's the usual cause of a lazy algorithm consuming more memory than it should.
14:40derekvweavejester, ok... I've got a set, and I use subsets on that, then I filter, then I reduce.
14:40derekvwhich should leave me with one set (the optimum)
14:41weavejestersubsets from where?
14:41derekvcontrib.combinitorics
14:42derekvi'll paste
14:42derekvhttps://www.refheap.com/paste/12043 this is just the knapsack problem
14:43derekvand I just went for an obiovious to me brute force solution to start
14:43derekvstill pretty new to functional programming and especially clojure so I'm not sure how to guage the cost of things.
14:45weavejesterThat looks okay, actually...
14:45weavejesterHow large is "dolls"?
14:46derekvworks fine on inputs like 5 or 6, but i have a functional test thats got 21
14:46weavejesterderekv: A size of 21 runs out of memory?
14:46derekvThat makes it think for a minute, and abort with default jvm settings. if i crank up xmx it finishes.
14:46derekvyea.
14:46weavejesterSo (count dolls) => 21
14:46weavejester?
14:46derekvyes.
14:47derekvlet me get the exact error...
14:47weavejesterHmm, subsets *looks* lazy enough
14:48weavejesterAnd you're not holding onto the head of the seq
14:48derekvIt says its lazy in the doc.
14:51weavejesterderekv: 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:54derekvhttps://www.refheap.com/paste/12044 this is the error, but I think thats just a normal out of memory error
14:59derekvis 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:59derekvbut reduce is just a recursion with accumulator right?
14:59weavejesterderekv: Oh, that's not a normal out of memory error
15:00weavejesterThat's an error thrown when too much time is spent GCing
15:00derekvJvmIsStupidAndWhyDoesntItSolveAllMyProblemsForMeException
15:00weavejesterspecificially "if more than 98% of the total time is spent in garbage collection and less than 2% of the heap is recovered"
15:00derekvhmm
15:01derekvThat would still imply that a bunch of memory is being held at least temporarily right?
15:02weavejesterderekv: Ohh, hum, you have some odd things in your code
15:02derekvno doubt
15:02derekvbut not on purpose.
15:02weavejesterderekv: You're using the very old clojure.contrib library, which was deprecated years ago
15:02weavejesterderekv: You probably want to use clojure.math.combinatorics instead: https://github.com/clojure/math.combinatorics
15:03derekv*sigh, I guess thats the drawback to the hyperavailability of solutions and example code on the internet
15:03derekvweavejester, nice I'll take a look
15:03weavejesterDoll doesn't need to be a record, because you're not doing anything with protocols per se
15:03weavejesterI'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:05weavejesterIt's a little strange you're returning a one-element set from your solver function...
15:05weavejesterYou could also use preconditions inetad of solver-argument-validator
15:07weavejesterBut… I'm not sure why the app would be spending so much time GCing...
15:07derekvweavejester, I tried the preconditions thing but couldn't get the syntax to work off the examples I was looking at.
15:08weavejesterderekv: It would be something like...
15:08derekvThe 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:08weavejester{:pre [(number? max-weight) (pos? max-weight) (coll? dolls)]}
15:09weavejester,(set [1 2 3])
15:09clojureboteval service is offline
15:09weavejester~(set [1 2 3])
15:09ibdknox&(set [1 2 3])
15:09weavejesterHum, you might be right. I might be misremembering the syntax.
15:09ibdknoxlazybot isn't here
15:10ibdknoxThis must be the apocalypse
15:10ibdknoxRaynes: where's lazybot?
15:10derekvweavejester, 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:10RaynesVacation.
15:11ibdknoxWe all need one
15:11weavejesterderekv: Fair enough :)
15:11weavejesterOn another note, has anyone heard of a project that uses git as a microblogging system?
15:11Raynes&(+ 3 3)
15:11lazybot⇒ 6
15:12derekvweavejester, microblogging not sure... there's a bunch of static site generators that support blogging and integrate with git
15:12yogthosweavejester: that's more or less what I'm doing with the luminus docs site
15:12ibdknoxweavejester: https://github.com/cloudhead/toto
15:12ibdknoxgfredericks:
15:13ibdknoxgfredericks: whoops, what bug?
15:13weavejesterI mean, not a microblog website built on git, but a microblog system build from git and terminal commands
15:13derekvI was trying to find one that kept a seperation between the articles and the code , like seperate repositories
15:14weavejesterI'm building one, and I don't think it's been done before, but it's always possible I've missed something.
15:14derekvweavejester, oh... you could rig something up with org-mode, git and remember if you live in emacs
15:14ibdknoxI'm not sure I understand what that means :)
15:14gfredericksibdknox: a scoping bug with (doseq [... :let [f #(...)]] ...)
15:14gfredericksmaking a gist now
15:15weavejesterIn the system I've got, I'm abusing git commits as microblog entries.
15:15weavejesterSo I can type: git upto add "Doing something"
15:15weavejesterTo view the entries: git upto log
15:15yogthosweavejester: 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:16weavejesterAnd to sync with a remote: git upto link git@…; git upto sync
15:16ibdknoxhaha
15:17derekvYou 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:17gfredericksibdknox: https://gist.github.com/fredericksgary/5078092
15:17yogthosgithub does provide a nice webui for editing your md files :)
15:18yogthosI just ended up doing this https://github.com/yogthos/luminus/blob/master/src/luminus/util.clj
15:18clojure-newsjl: Hello, i'm using your library(clojure-lanterna) and it's great! But is it possible to hide cursor?
15:18weavejesterderekv: 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:19ibdknoxgfredericks: huh, nice catch
15:20gfrederickslooks like for does not have the same issue
15:22gfrederickslooks like it's CLJS-39; I must not have the latest code? :/
15:23gfrederickssupposedly fixed back in september
15:23ibdknoxI'm on the latest
15:23ibdknoxand it's definitely happenin
15:23ibdknoxg
15:23derekvis all of clojure.contrib out of date?
15:25derekvwhere do I get that nice defnk macro
15:28weavejesterderekv: You don't really need it for modern Clojure versions, as you can use destructuring
15:28weavejesterAlthough I guess the syntax might not be as nice.
15:34ivandid you know jdk.map.althashing.threshold exists http://docs.oracle.com/javase/7/docs/technotes/guides/collections/changes7.html
15:46derekvhmm it always craps out on the reduce is bag-weight
15:51derekvwhat would be better than defrecord for my items?
15:51derekvif this was C i'd just use a struct, that was what I was going for
15:54xeqihttps://github.com/cemerick/clojure-type-selection-flowchart
15:56xeqi,"no eval? denied!"
15:56clojurebot"no eval? denied!"
15:56hiredmanclojurebot: oomkiller?
15:57hiredmanclojurebot: oomkiller?
15:57xeqi,(+ 1 2)
15:57clojurebot3
15:57clojurebotGabh mo leithscéal?
15:57xeqihmm, guess it works now
15:57hiredmanclojurebot: oomkiller is what you get for running on a t1.micro
15:57clojurebotYou don't have to tell me twice.
15:58akhudekthat chart is great!
16:00gfredericksibdknox: oh good to know; I'm terrible at telling what version I'm on or running tests out of the project
16:00gfrederickshow do we handle regressions on jira? new ticket or old ticket?
16:00gfredericksoh actually I think my bug is subtler than this one
16:14Raynesibdknox: ohai
16:18ibdknoxRaynes: hola
16:19Raynesibdknox: How is the paredit contracting going?
16:19RaynesI may have already asked this.
16:19RaynesApologies if I have.
16:19ibdknoxfell through
16:19RaynesShame.
16:19ibdknoxI added auto-pair completion myself
16:19ibdknoxI might add slurp and barf
16:19RaynesI bet it was like "Oh. Oh wait. I have to do this in javascript? Yeah, no."
16:20ibdknoxhaha
16:20ibdknoxnah, he just got busy with other things
16:36derekvhey 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:37RaynesA map?
16:38derekvmap is lighter than record?
16:38RaynesIf you don't need a type there is rarely a reason to use a record.
16:38derekvjust curioust, probably the problem isn't with the data objects i'm using
16:38derekvok
16:44gfrederickshttp://dev.clojure.org/jira/browse/CLJS-481
16:47derekvactually 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:00bwsHey looking for some help with an error during clojure koans
17:01bwsI 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:02bwscopy pasting that in a repl returns true
17:03bws(= [0 1 2 3 4] (range 5)) is the problem that returns the error. Any helps appreciated. Thanks.
17:11lekuworks for me bws
17:12bwsThanks for trying it out leku
17:12bwsIt works for me in the regular repl, but as a whole the koans script doesn't work for me when I enter that.
17:12RaynesCould you paste the whole thing on https://www.refheap.com?
17:13bwsI'm trying to see if any of the previous solutions might somehow be causing some error.
17:13bwsBut this only happens when I enter the solution to this question. If I delete it, it doesn't whine.
17:14RaynesWe might be able to help, but we definitely need to see it in context.
17:14bwsRaynes https://www.refheap.com/paste/12051
17:14bwsThat's the one file (10th one in the exercise)
17:15lekuwhat version of clojure are you using?
17:15lekuand java
17:15lekujava -version
17:15RaynesWhy would that matter?
17:15bwsclj 1.5
17:15lekujust wondering
17:15lekuwhy wouldn't it?
17:15bwsjava 1.7
17:15lekuthose aren't good things to know?
17:16bwsWell if it helps any, I did tyr it in clj 1.5 repl with the expected output
17:16RaynesThis looks fine. Not sure what is going on.
17:17bwsThat's what's driving me crazy!
17:17lekulol i bet
17:17lekui've had some weird crap happen to me lately too
17:17lekufrustrating
17:17RaynesI would expect that this is a problem with the koans.
17:18lekuand clj 1.5 perhaps?
17:18lekuit was just released pretty recently right?
17:18lekuI just did the koans up to 10 I think a few days ago in 1.4
17:18lekuworked fine
17:19bwsI mean the solution seems straightforward, there's definitely something funky going on with the koans runner or something perhaps.
17:19bwsUp until this one I didn't see any issues.
17:20bwsGoing to dive into the runner script
17:21Raynesbws: Yeah, `lein koan run` is giving me the same failure in this situation. I call broken koans.
17:21jcromartieso I'm doing a presentation on Tuesday night on where FP fits in web programming
17:21bwsAlright thanks for the confirmation.
17:21RaynesI'm pretty sure I know how to program in Clojure, so...
17:21Raynes:p
17:22jcromartieI'm going to touch on Compojure and some of the functional aspects of Backbone and Underscore for JS code...
17:22jcromartiebut I'm pretty much talking out my butt here
17:22jcromartieany thoughts?
17:22bwsHehe.. I'll just see if I can find out what the issue is. A little more learning. Thanks Raynes and leku
17:22Raynesjcromartie: Well, I'd start by not talking out of your ass. If you think you're doing that they probably will too. :p
17:23jcromartieI'll try
17:23jcromartieI mean the obvious starting point is that the request/response cycle lends itself to simple functions
17:23jcromartiewhich Compojure demonstrates nicely
17:24jcromartieand then using functional templates in Backbone gets away from stateful jQuery spaghetti
17:24Raynesjcromartie: 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:24jcromartienot that these frameworks are the only options
17:24jcromartieyah
17:24jcromartieI am going to put together a little concurrent chat server
17:24jcromartieand show how it's a few lines of code, and handles some large number of concurrent connections
17:25jcromartiewith no hiccups and no errors
17:25jcromartieas long as you keep things nice and pure
17:26derekvmy app is spinning all four cpus pretty hard
17:26derekvit doesn't automatically parrellelize somehowe does it?
17:27derekvi can't even spell that word.
17:33jcromartiederekv: what is your app? can you show code?
17:39bwsRaynes and leku: Confirmed with the author of clojure-koans, there is a bug in there.
17:40RaynesExcellent.
17:40derekvjcromartie, yea http://tinyurl.com/cu8lfhw
17:40RaynesWell, not excellent.
17:40RaynesBut great that you confirmed it.
17:40derekvjcromartie, cpu is expected not sure why it runs out of memory
17:41derekvor rather crashes due to gc overhead limit
17:41bwsNow to figure out how to pull updated changes from the author's github repo into mine.
17:41bwsAdding upstream seems to be the solution.
17:42derekvand not sure why it uses all four cpus unless 300% is GC
17:42jcromartiederekv: 300% would be 3 cores, no?
17:42derekvjcromartie, thats what I meant yea sorry
17:43derekvjcromartie, it uses > 300% when running, closer to %400, on a 4core machine
17:45seangroveIs it possible to do deep destructing to avoid code like this? https://www.refheap.com/paste/5592dbe0999cd64c75c49db3e
17:45seangrove(let [profile (get (first (get profile "profile")) "merges")] ...)
17:45jcromartiederekv: are you getting any OOM crashes?
17:46jcromartiederekv: I'm pretty sure that none of the combinatorics functions yield infinite seqs
17:46jcromartiederekv: but they can be very *very* large
17:46jcromartieand if you give them an infinite seq, then you will have problems
17:46derekvjcromartie, yes. usually GC overhead limit crash, sometimes heap space. it finishes if i turn up heap. input size 21
17:47derekvjcromartie, I thought it was lazy, but I was trying to figure that out ...
17:47derekvthe subset function
17:49derekv21 should yield a couple million combinations I think, but they shouldn't all be in memory
17:49jcromartieyeah, they're lazy
17:49jcromartiethey're all lazy
17:50derekvi figure you could get subsets by mapping bits in an int to items, then counting 0 - 2^n
17:50derekvso there'ss at least one way to do it without eating memory
17:51jcromartiederekv: but you're not giving any of those combinatorics functions an infinite seq, right?
17:51jcromartiederekv: how about some println debugging
17:51derekvjcromartie, good thought
17:52derekvi don't see how it should get anything infinate
17:52lekubws where was the bug?
17:52sw1nnanyone 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:53bwsleku: The author said he'll fix it, I have no clue where it was. I'm independently trying to figure out.
17:53lekuweird..
17:54lekuwonder how i got through them the other day
17:54bwsMaybe some recent change
17:55bwsI forked it last night.
17:57tomojseangrove: please put a newline before `profiles` :)
17:57seangrovetomoj: where the docstring should be?
17:58tomojno I mean (map (fn ....) \newline coll) when (fn ...) is multiline
17:58tomojbtw, your map fn appears to always return nil?
17:58seangroveOh, yes, that's just a wip
17:59seangroveI saw the (get (first (get ....))) and thought some deep destructing would really help clean it up
17:59seangroveNot sure if that works in clojure though, so just asking
17:59tomojit looks like [list-id {"profile" [{"merges" merges}]}] ?
18:00seangrove{"profile" [{"merges" [...]}]}
18:00seangroveso a combination of arrays of maps with strings as keys
18:01tomojer
18:01tomojI meant [list-id {[{merges "merges"}] "profile"}]
18:01tomojas the params
18:03seangroveprofiles looks like {"list-id" {"profile" [{"merges" [{}]}]}}
18:03tomoj&((fn [[list-id {[{:strs [merges]}] "profile"}]] [list-id merges]) [[1 {"profile" [{"merges" [1 2 3]}]}]])
18:03lazybot⇒ [[1 {"profile" [{"merges" [1 2 3]}]}] nil]
18:03seangrovePorting some ruby code to clojure that's dealing with a 3rd-party api
18:03amalloyseangrove: i don't think you're understanding tomoj's suggestion
18:03seangroveamalloy: I don't think so either :)
18:03tomojwell, close, I think..
18:03seangrovetomoj: That's great, thanks
18:04seangroveI'll take that and run with it... certainly much nicer than my code
18:04seangroveIs it possible to do the same thing inside of a `let` binding though?
18:05seangroveAh, yes, that should work :)
18:05seangroveThanks for that, sorry to be so thick
18:06deeplloydon 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:15alandipertdeeplloyd: setting to anything non-empty will disable the warning
18:15alandipertdeeplloyd: e.g. # LEIN_ROOT="true" lein ...
18:15deeplloydok yea i just did 1 and it worked
18:16deeplloydjust wanted to double check because il forget that mod down the line
18:16deeplloydif i run as not root i get a shit load of errors
18:17TimMcdeeplloyd: Out of curiosity... why as root?
18:17amalloydeeplloyd: that's because you installed as root
18:18amalloydefinitely recommend installing as the user who's going to run it; just put it in ~/bin or somewhere
18:18deeplloydi am required by pacman/aur to makepkg as non root, but in order to install i need to be root to run pacman
18:25lekuanyone familiar with nanite?
18:28derekvits something in my input function
18:28derekvi thought actually there'd be no problem there since i use slurp
18:28derekvsomething about my input function makes the rest of it blow up
18:30derekvso 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:01muhooi'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:28Rich_MorinClojure 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:33tomoj"arities"? "overloads"?
19:33Raynestomoj: Arities.
19:33tomojis that metonymy?
19:37TimMcPretty much.
19:37amalloy$dict metonymy
19:37lazybotamalloy: 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:39TimMc$dict synecdoche
19:39lazybotTimMc: 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:40TimMcAll these violent examples.
19:40TimMcAlso, I had no idea that an amalloy was a figure of speech.
19:41Rich_MorinCalling the section of a function that handles a particular "arity" an "Arity" seems a lot like synecdoche. Is this common usage?
19:43ayiaHi 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:44TimMcayia: concat is prety close
19:45TimMcJust be warned that adding stuff onto the end of a seq tends to be relatively expensive.
19:49ayiaTimMc: Thanks! What is it expensive? Is it expensive for all collections? or just for vector?
19:49TimMcSpecifically for sequences, which are not vectors.
19:49ayiaTimMc: oh...
19:49TimMc~seqs and colls
19:49clojurebotseqs and colls is http://www.brainonfire.net/files/seqs-and-colls/main.html
19:50TimMcSequences are not random access. You have to walk or rebuild them to read or modify them.
19:51TimMclazy 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:52ayiaTImMc: so "more expensive" belongs only to sequences that are not lazy, correct?
19:54TimMcNo, I only mentioned the lazy seq things because it's a way of *avoiding* appending.
19:54TimMcIf you're doing a lot of appending, perhaps you should be conj'ing onto a vector.
19:54TimMc&(conj [1 2 3] :a)
19:54lazybot⇒ [1 2 3 :a]
19:55TimMcThat's an O(log n) operation. (Relatively fast.)
19:56ayiaTimMc: 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:58TimMcThe 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:00TimMcayia: This has some relevant info: http://clojure.org/data_structures#Data%20Structures-Collections
20:01ayiaTimMc: yes, i asked about performance and "when use what"... big thanks for links! You helped me a lot!
20:02TimMcvectors are fast for: append, random read, random update, count
20:02TimMcseqs are fast for: add/remove head
20:11gfrederickshow are IPersistentList and IPersistentStack different?
20:11gfredericksoh it's an interface
20:12gfrederickswell they both are
20:12gfrederickslet's pretend I haven't said anything yet this evening.
20:15derekvthis pretty much does it right here (filter #(let [s (reduce + %)] (and (> 200 s) (< 250 s))) (subsets (range 11 160 7)))
20:15derekveats memory till the jvm chokes
20:16gfredericks(and (> 200 s) (< 250 s)) is always false ain't it?
20:17Iceland_jackShould it be (> 200 s 250) ?
20:17gfredericksthat's even falser
20:17Iceland_jack*<
20:18derekvyea probably, its not finishing i'm just trying to isolate it
20:18yediweavejester: thanks
20:19weavejesteryedi: What did I do?
20:19yediweavejester: lein-beanstalk
20:19weavejesteryedi: Ohh
20:20derekv(filter #(let [s (reduce + %)] (= 88 s)) (subsets (range 0 44 22))
20:20derekvanouther type
20:20derekvtypo
20:20derekvgoing to bed
20:20weavejesterI really need to make the configuration of lein-beanstalk better
20:21weavejesterThe default environments are bad, and the config map could be improved.
20:24bwsRaynes leku: The author mentioned there was something funky going on with Clojure 1.3 behavior.
21:05yediwhy might lein-beanstalk hang after creating the application war?
21:51gfredericksdid you move to a different country?
21:52dabdno i didn't change anything
21:52ivanwhat does `locale` say?
21:52dabdwhere can i find it?
21:53ivanit comes with linux
21:53gfredericksclojurescript does not like js/undefined
21:53dabdi am running it on windows atm
21:54ivanhttp://stackoverflow.com/questions/5182451/how-to-format-double-with-dot
21:54dabdi 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:09fbernierclojure noob here.. this seems to return a sequence, when what I want is the map inside the sequence .. how do I fetch it?
22:09fbernier(fn [x y] (first (for [index y]
22:09fbernier {index x})))
22:10fbernieroops .. without the first
22:12dabdif I evaluate (java.util.Locale/getDefault) it shows
22:13dabdit returns* #<Locale en_US>
22:13dabdI'm not in the US but (format "%.1f" 0.5) should show 0.5 and not 0,5 right?
22:16gfredericksfbernier: y is a map and x is a key?
22:17fberniergfredericks: yes
22:17gfredericksfbernier: (get y x) should work
22:17gfredericksor maybe even (y x) or (x y) depending on details
22:20fberniergfredericks:actually its a 4clojure problem...
22:20fbernier(= (__ 0 [:a :b :c]) {:a 0 :b 0 :c 0})
22:20holohi
22:21gfredericksfbernier: you're supposed to assemble a map from a keylist and a val?
22:23fbernier"Write a function which takes a default value and a sequence of keys and constructs a map."
22:25gfredericksfbernier: so for always returns a sequence. That's what it's for.
22:25gfredericksfunctions you might be interested in looking at include hash-map, zipmap, into, reduce, assoc...
22:26fberniergfredericks: ok thanks, got it with this but I get it's far from optimal:
22:26gfredericksyou won't need all of those, there's just several different approaches you could have
22:26fbernier(fn [x y] (into {} (for [index y]
22:26fbernier {index x})))
22:37tomojI wonder if it makes sense to have function that turn reducers into kvreducer
22:39FoxboronJust came across Clozure. Obvious rip off?
22:39brehautno
22:40amalloyFoxboron: is it obvious we ripped the name off of them?
22:40Foxboronamalloy: was more thinking the other way around
22:40amalloyonly if rich has a time machine
22:40derekvclozure is older i think
22:40amalloyby a decade
22:41Foxboronamalloy: i do consider that plausible
22:42Foxboronderekv: from what i am reading is that the language it self is from the 80's. But they changed name in 2012.
22:50ChongLirich definitely has a time machine
22:51ChongLiexcept I think his ideas are ripped off from the future!
22:54dcolishhah, yeah clozure is a just a little older
23:00frenchypI am just starting to play with Seesaw.
23:00frenchypI am trying to print debug information to the REPL from an event handler.
23:00frenchypI understand that event handlers run in the UI thread, whose *out* isn't bound to my REPL.
23:00frenchypSo 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:00frenchypMy code is at https://www.refheap.com/paste/12062
23:00frenchypAm I missing anything obvious?
23:01lekuhey this is an emacs/paredit question I think, but how do I force it to delete a parens?
23:02jaoleku, C-u <BACKSPACE>
23:02frenchypleku: if parens are unbalanced or empty it works, otherwise it doesn't let you.
23:02jaoor C-u C-d
23:02lekuthx
23:02frenchypjao: oh cool
23:02lekufinally
23:02lekuthank you
23:03jaoyou're welcome
23:17TimMcleku: Selecting and then hitting C-w also works.
23:34lekui'm having a problem fetching some json data with clj-http and then parsing it with cheshire
23:34lekuhttps://www.refheap.com/paste/12064
23:35TimMcleku: I'm guessing client/get returns a response map.
23:35RaynesYes.
23:35lekuyeah
23:35Raynesieure: (:body ..)
23:37lekubasically I just want to get the data out of "values"
23:40lekuis json the best format to maybe get this data?
23:40lekuI think I have a few options
23:40RaynesProbably.
23:40RaynesUnless edn is another option.
23:41lekulooks like XML, tab-delimited, or JSON
23:41RaynesYes, json is your best option.
23:41Raynes(-> (client/get "http://waterservices.usgs.gov/nwis/iv?sites=05331580&amp;period=P7D&amp;format=json&quot; {:accept :json}) :body parse-string)
23:41Raynesleku: ^
23:41lekunice
23:42lekuthanks
23:42RaynesAlso, to whoever ieure is, sorry for pinging you a minute ago. I mean't leku.
23:42RaynesAnd now, I guess.
23:42lekuoh ah hah
23:42lekuwas wondering..
23:42lekuwicked
23:42lekuthanks
23:52cliftonwhat is the newer site that is an alternative to clojars?