#clojure logs

2012-08-16

00:31jlewisamalloy: lo and behold, the guy who wrote clj-ds rewrote PersistentHashMap.iterator to make it iterative instead of recursive... and broke it!
00:31jlewiscan't reproduce the problem with the original iterator
00:31jlewisreally scary... it like *mostly* works, until you have hundreds of megabytes in your map, and suddenly it barfs
00:40wmealing_1sounds like fun
01:52tomojanyone seen errors like this in cljs on node? https://www.refheap.com/paste/55b6635602282be89a3013d59
01:52tomojgoog.global.goog.debug is set
01:53tomoj(by goog.provide('goog.debug.Error'))
01:53tomojbut 'goog' does not refer to the same thing as 'goog.global.goog'
01:53tomojso goog.debug.Error = ... fails
01:53tomojin whitespace mode
01:54tomojI have clojurescript head on a source-path
01:55tomojoh
01:55tomojhttp://dev.clojure.org/jira/browse/CLJS-101
01:56tomoj..first result for the obvious thing to google
02:18ro_stso, what do we all use for logging? :-)
02:29zeromodulusoy, I really want to use clojure, but I run into so many problems it's discouraging. :(
02:31zeromoduluscan't figure out how to install tagsoup with leiningen
02:33zeromodulusI don't want to use ruby, but looks like I'll have to. v.v
02:33ro_stwhat do you want to do with tagsoup?
02:34tomojhttp://search.maven.org/#search%7Cga%7C1%7Ctagsoup
02:34tomoj[org.ccil.cowan.tagsoup/tagsoup 1.2.1]
02:35tomojer
02:35Cr8I really like Jsoup, which is in central, so you can pull it in with just [org.jsoup/jsoup "1.6.3"]
02:35tomoj[org.ccil.cowan.tagsoup/tagsoup "1.2.1"]
02:40Cr8(map #(.attr % "title") (.select (.get (org.jsoup.Jsoup/connect "http://en.wikipedia.org/")) "#mp-itn b a")) ; List of titles of wp news headlines
02:42ro_stah, there's also enlive
02:43Cr8https://github.com/cgrand/enlive/ yes
02:44ro_stgoogling for clojure logging is giving me plenty of old hits (contrib comes up often).
02:44ro_stanyone know of a newer clojurey approach to logging that's as awesome as the rest of the ecosystem?
02:45ro_stfound this, so far
02:45ro_sthttps://github.com/malcolmsparks/clj-logging-config
02:46Cr8I think I saw this on the list recently: https://github.com/ptaoussanis/timbre
02:46ro_stahh there we go
02:48ro_stthanks Cr8!
02:48Cr8np :)
02:55magopiando you know any (very cool) company that uses clojure and who might recruit?
02:55magopiani'm thinking something like github for rails
02:58hyPiRionhttp://thinkrelevance.com/jobs
03:00alexeymagopian: I work for such company; we are not recruiting at the moment but probably will be later in the autumn.
03:00magopianthanks hyPiRion
03:00magopianalexey: what's the name?
03:00alexeymagopian: to avoid advertising, sent as private message
03:00magopianoh ok sure ;)
03:02hyPiRionalexey: That's a strange policy for a company.
03:02hyPiRion"We do not like advertising!"
03:02alexeyNah, it's not the policy of the company
03:02ro_sthe's respecting irc etiquette
03:02alexeyI didn't want to spam the channel :)
03:03wmealing_1respect
03:03wmealing_1which country ?
03:03alexeyFinland
03:07ro_stSouth Africa, here
03:07ro_stwe just hired a guy
03:08ro_stcan't say we're like github, though. he's programmer #3 :-)
03:12magopianro_st: it's not the number i was comparing to (the number of employees)
03:13magopianbut more the "feeling"
03:21ro_stright
03:24magopianro_st: proof: in 5 years, _none_ of the employees at github have left
03:24magopianthat must mean something, right?
03:24ro_sti know
03:25ro_sti saw Zach speak at scaleconf, and i spoke with at the github sponsored beers after the conf as well
03:25ro_stwe're trying to set ourselves up the same way
03:27magopianro_st: excellent ;)
03:59ro_sthow do i pprint to a string instead of to *out* ?
04:00magopianro_st: there's a pr-str command
04:00magopianwait
04:00ro_staha! with-out-str
04:01magopianhttp://clojuredocs.org/clojure_core/clojure.core/pr-str
04:01magopianthere's quite a few different options actually ;)
04:02ro_sti'm after pretty printing at the moment
04:02ro_sta content format we have is moving from xml to plain clojure
04:07blackdogtrying to benchmark my noir hello-world app for sanity, and i'm getting apr_socket_recv: Connection reset by peer after 3-10 requests. any ideas what i might have wrong?
05:04clgvlpetit: ping?
05:34noidiwhat's a nice way to check if a collection contains every item in another collection?
05:35noidi(xxx [:foo :bar] [:foo :bar :baz]) => true, (xxx [:foo :bar] [:foo :baz]) => false
05:36babilennoidi: Convert both to sets and compare those comes to mind ... Or should do you want (not= [:a :a :b] [:a :b]) => true ?
05:37babilens/not=/xxx/ :)
05:38ro_st,(doc some)
05:38clojurebot"([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return :fred if :fred is in the sequence, otherwise nil: (some #{:fred} coll)"
05:38noidibabilen, yeah, maybe sets could do for this case
05:39noidisome returns true if, well, _some_ of the needles are found in the haystack. i want to know if _all_ needles were found :)
05:39babilennoidi: Bad approach though performance wise and you could terminate as soon as you find one element that is not in the other collection ...
05:41mduerksen_noidi: there is a clojure.set/subset? function for your use-case, but only if its ok that (clojure.set/subset? (set [1 2]) (set [1 2])) => true. this means that you have to turn your collections into sets, so you will have to decide if thats okay for you performancewise
05:41babilen,(every? #{:a :b} [:a :b])
05:41clojurebottrue
05:42babilennoidi: That ^^ still requires that you convert one coll into a set, but should be idiomatic.
05:42noidihuh? that works! :)
05:42noidinow I have to think for a bit WHY it works :)
05:42noidithanks!
05:43noidiah, that reads exactly how it needs to work
05:44noidifor every item that I'm looking for, make sure it's found in the given collection
05:46babilen,(list (#{:a :b :c} :x) (#{:a :b :c} :c))
05:46clojurebot(nil :c)
05:46babilennoidi: That might help when you want to understand it ^^^ -- Another common idiom is &(#{:a :b :c} [:a :b :x :y :x])
05:46DrPheltRightcr
05:46babilennoidi: Err, make that % (remove #{:a :b :c} [:a :b :x :y :x])
05:47noidiyeah, I'm use (some #{...} ...) often
05:47noidibut it didn't occur to me to use every? that way :)
05:48noidiit's probably because I'm so used to using `some` that way
05:49noidiso it didn't occur to me to place the things that I'm looking for last, as a seq, and the collection in which to look first, as a set
05:50noidibabilen, thanks again, that's a useful trick to know!
06:04hyPiRionAnother neat trick is the some-fn
06:04hyPiRion,(filter (some-fn integer? string?) [1 2 :foo 2.0 "string"])
06:05clojurebot(1 2 "string")
06:10hyPiRionhm. ##(filter #(<= 0 (.indexOf [1 5 "foo"] %)) [1 2 "foo" 3 4 5 "bar" "baz"])
06:10lazybot⇒ (1 "foo" 5)
06:16nbeloglazov&(doc int?)
06:16lazybotjava.lang.RuntimeException: Unable to resolve var: int? in this context
06:16hyPiRioninteger
06:16hyPiRion&(doc integer?)
06:16lazybot⇒ "([n]); Returns true if n is an integer"
06:16nbeloglazovJust checked
06:20nbeloglazov$(source integer?)
06:20nbeloglazov&(source ingeter?)
06:20lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
06:20nbeloglazov&source integer?
06:20lazybotjava.lang.RuntimeException: Unable to resolve symbol: source in this context
06:20nbeloglazov:(
06:21hyPiRion,(source integer?)
06:21clojurebotSource not found
06:21hyPiRionI think it's clojailed.
06:21hyPiRionEither that, or jar'd, so that it's unavailable.
06:23clgv$source integer?
06:23lazybotinteger? is http://is.gd/BopmnQ
06:24clgvbut that task needs an update
06:38clgvis there already an equivalent for clojure.contrib.repl-utils/show? last time I checked there was not... :(
06:43hyPiRionclgv: What did it do?
06:43clgvhyPiRion: print all methods of a given object/class
06:43clgvwith argument infos etc
06:47clgvwell, I guess I port it to one of my tool libs
06:47hyPiRionYeah, the source's available, so why not.
07:24clgvneeds a bit of rework though. there is some weird code in there ;)
07:48ludstonIs there a setting to kill the *SLIME Compilation* buffer after an errorless compile?
07:49hyPiRionC-b "*Sl" TAB C-x k RET ?
07:49ludstonGood one.
07:49ludstonlol
07:50hyPiRionYou could probably just make a binding yourself, it seems easier.
07:50ludstonI'll try that then
07:51hyPiRionIt doesn't seem like the most standard way of working with Slime though. Is there any reason why you would like that feature?
07:53ludstonBecause it jumps up and takes over my repl if I have errors, and then doesn't go away again when I don't need it any more
07:54ludstons/repl/buffer
07:54hyPiRionoh
08:01ivaraasenanyone here read "Effective Java" by Joshua Bloch?
08:05antifuchshugod: I'm just peeking at ritz again, and I notice you've changed the RPC code structure (:
08:05nbeloglazovivaraasen: I have. What is the question?
08:05antifuchshugod: is rpc.clj responsible for both swank and nrepl now?
08:44ivaraasennbeloglazov: would you recommend the book to a CS student? I've only skimmed through a couple of chapters. seems to promote a semi-functional style, at least immutability.
09:05CheironHi, I have a clojure application that uses Hector Cassandra library. I decided to extract Hector code into its own lein project. Clojure code still require subproject code but to make it possible?
09:07nbeloglazovivaraasen: Yes, I would recommend it. Of course if you're using java. It has many nice advices and tricks
09:09hugodantifuchs: I haven't really changed rpc.clj at all - it is solely for the swank protocol
09:09antifuchsah, great then (:
09:09hugodnrepl is handled by pulling in the nrepl lib
09:09antifuchsI'm currently hacking on the swank-clojure rpc, but should be straightforward to port anyway
09:10hugodthey are essentially the same
09:11hugodantifuchs: ritz.nrepl provides a nrepl server that can run a debugger
09:11antifuchscool
09:23antifuchsso, um. is there anything re. object identity I'm missing when my tests fail with:
09:23antifuchs actual: (not (= (:keyword "string") (:keyword "string")))
09:23antifuchsthat looks the same to me, and the REPL returns false when I try to eval this (quoted)
09:26@Chouser,(= (:keyword "string") (:keyword "string"))
09:26clojurebottrue
09:26@Chouserwhat do you mean, "(quoted)"?
09:27@Chouser,(:keyword "string")
09:27clojurebotnil
09:27@Chouser,'(:keyword "string")
09:27clojurebot(:keyword "string")
09:28hyPiRionThe result should be false, no?
09:28hyPiRion,(not (= (:keyword "string") (:keyword "string")))
09:28clojurebotfalse
09:29hyPiRion,(not (= nil nil))
09:29clojurebotfalse
09:31magopian,(not= nil nil)
09:31clojurebotfalse
09:34ludston,(def who-is-awesome 'ludston)
09:34clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
09:34ludstonSadface.
09:34Sweden_jackOuch
09:37augustlgot a Java object with a .getCount() and .getItemAtIndex() type API that I want to list in a clojure vector. What are good ways to do that?
09:37augustlI'm thinking something like making a lazy sequence that is capped at .getCount() and then map that lazy sequence
09:39ro_styou know you work for the right people when they love Rich Hickey's talks just as much as you do
09:41augustl(map fn... (range n)) seems good
09:45hyPiRionaugustl: Could you use iterator-seq or enumerator-seq?
09:48ludston,(loop [damn-your-insulting-ways true] (recur damn-your-insulting-ways))
09:48clojurebotExecution Timed Out
09:48ludstonMwhahahaha
09:48hcastrodoes anyone know how to prevent the return value of -main from printing to stdout?
09:48hyPiRionI can make you more awesome, ludston
09:48hyPiRion(inc ludston)
09:48lazybot⇒ 1
09:49ludston(def imnotsureibelieveyoubutokletstrythiscouldgetburnedbutwatchoutbois true)
09:49ludston,(def imnotsureibelieveyoubutokletstrythiscouldgetburnedbutwatchoutbois true)
09:49clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
09:50ludston(inc ludston)
09:50lazybotYou can't adjust your own karma.
09:50ludstonAwwww
09:50hyPiRion&'(inc ludston)
09:50lazybot⇒ (inc ludston)
09:50hyPiRion,'(inc ludston)
09:50clojurebot(inc ludston)
09:50lazybot⇒ 2
09:50hyPiRionloophole
09:50ludstonThis is the best day ever.
09:50ludston,'(inc ludston)
09:50clojurebot(inc ludston)
09:50lazybot⇒ 3
09:52Fossiyeah
09:52Fossithe bots should ignore each other
09:53Fossii think one of them does
09:53Fossiso you can't pingpong
09:53hyPiRionheh
09:53ludstonIt's probably impossible to get lazybot to put a comma down
09:53Fossiah, lazybot also "escapes" by printing the arrow first
09:54hyPiRion&(prn "foo")
09:54lazybot⇒ "foo" nil
09:54ro_sti want to sort a map by its keys. i have the keys in order in a vector. how would i do this?
09:54ludston,(print ",(print 'blah')")
09:54clojurebot,(print 'blah')
09:54@Chouser&(prn (symbol ",") '(inc chouser))
09:54lazybot⇒ , (inc chouser) nil
09:55hyPiRionheh.
09:55nbeloglazov,(sort-by first {:b 1 :c 2 :a 3})
09:55Fossifoo ,(+ 1 1)
09:55clojurebot([:a 3] [:b 1] [:c 2])
09:55ludston,(print "&(print 'blah')")
09:55clojurebot&(print 'blah')
09:55lazybot⇒ blah'nil
09:56gfredericksis it bad form for a library to (defmethod print-method <some common type> ...)?
09:56hyPiRionro_st: You could do ##(sort-by #(.indexOf [:b :a :c] %) {:a 1 :b 5 :c 6})
09:56lazybot⇒ ([:a 1] [:c 6] [:b 5])
09:56ro_stahh indexOf
09:56ro_stdidn't realise i had to use a java call
09:56ro_stthanks hyPiRion
09:57trptcolin:w
09:57trptcolinoops. sorry :)
09:57hyPiRion,(println "&(prn :foo)")
09:57clojurebot&(prn :foo)
09:57lazybot⇒ :foo nil
09:57@Chouserthat's going to search the vector many many times
09:58hyPiRionYeah, it's O(n²)
09:58hyPiRionmultiplied by a log
09:58@Chouser(map {:a 1 :b 5 :c 6} [:b :a :c])
09:59@ChouserYou want vals or key/val pairs?
09:59magopianmaybe you could build a new map
09:59ludston&(print (str '##' '(print "boo")')
09:59lazybot⇒ (quote (print "boo"))
09:59magopianlike Chouser said
09:59gfredericks,(into {} (map-indexed list [:b :a :c]))
09:59clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to java.util.Map$Entry>
09:59magopianwell, nearly like he said ;)
09:59ludston&(print (str "##" '(print "boo")')
09:59lazybotjava.lang.RuntimeException: Unmatched delimiter: )
09:59@Chouser,(map #(find {:a 1 :b 5 :c 6} %) [:b :a :c])
09:59clojurebot([:b 5] [:a 1] [:c 6])
10:00hyPiRionYeah, that's faster.
10:00nbeloglazov,(doc find)
10:00clojurebot"([map key]); Returns the map entry for key, or nil if key not present."
10:00@Chousern log n instead of n^2 log n
10:00magopiannice ;)
10:00hyPiRionIt would be better with keep though
10:01hyPiRion,(keep (partial find {:a 1 :b 5 :c 6}) [1 2 :b :a :c])
10:01clojurebot([:b 5] [:a 1] [:c 6])
10:01hyPiRion,(map (partial find {:a 1 :b 5 :c 6}) [1 2 :b :a :c])
10:01clojurebot(nil nil [:b 5] [:a 1] [:c 6])
10:02@ChouserI guess it depends on whether or not you want to know about bad keys in your vector
10:02gfredericks,(map-indexed (comp vec reverse list) [:b :a :c])
10:02clojurebot([:b 0] [:a 1] [:c 2])
10:02ro_stnot all keys in the vector are in the map
10:02gfredericks,(into {} (map-indexed (comp vec reverse list) [:b :a :c]))
10:02clojurebot{:b 0, :a 1, :c 2}
10:02ro_sti just want the keys that _are_ in the map to be in the proscribed order
10:02gfredericks,(zipmap [:b :a :c] (range))
10:02clojurebot{:c 2, :a 1, :b 0}
10:02@Chouserah, then hyPiRion's got it exactly right
10:03cshellsorted map?
10:08@Chousercshell: interesting idea.
10:08robermannIn order to use the last ccw Eclipse plugin do I need to intall lein2 too, or lein1 is enough?
10:08@Chouser,(let [vec-order (zipmap [:b :a :c] (range))] (into (sorted-map-by #(< (vec-order %1) (vec-order %2))) {:a 1 :b 5 :c 6}))
10:08clojurebot{:b 5, :a 1, :c 6}
10:09hyPiRionIt really depends on the vector and the map though.
10:10hyPiRionThen again, all of these solutions are.
10:13ro_stif i have ([:a 1] [:b 2]) and i want {:a 1 :b 2}, it's (apply hash-map seq) right?
10:13ro_stbut that'll probably tear the sort up again
10:13hyPiRiontry out the ordered-map
10:13ro_stwill do
10:13hyPiRionIt's not in core though.
10:14@Chouserro_st: not apply hash-map. You'd want (into {} the-seq), but yes that will lose any order you gave it.
10:14ro_stsorted-map-by? it is
10:14ro_sttrying that..
10:14@Chouserapply hash-map is for when you have interleaved key/vals like [:a 1 :b 2]
10:15hyPiRionOh, the anonymous fn is kind of bothersome.
10:15@Chouserthen name it? :-)
10:15hyPiRion,(let [vec-order (zipmap [:b :a :c] (range))] (into (sorted-map-by (comparator vec-order)) {:a 1 :b 5 :c 6}))
10:15clojurebot{:b 5, :c 6, :a 1}
10:16@Chouserhyperboreean: ah, nice.
10:16@Chouserwait, that's not what I thought comparator did
10:17hyPiRion$source comparator
10:17lazybotcomparator is http://is.gd/dalGK8
10:18@Chouserpred is called with two args
10:18@Chouserto compare
10:18hyPiRionIt's more or less your anonymous function.
10:18@Chouseryou're supplying vec-order as the pred, but vec-order doesn't compare two args
10:19@Chouserbut the return value of your example looks right. I'm trying to figure out why
10:19hyPiRionOh, I see
10:20ro_sti'm trying to use [:a :b :c] as my vec-order
10:20hyPiRion({:a 1 :b 5} 1 :b}
10:20hyPiRionIt's the optional argument at work.
10:20ro_stah i need to zipmap
10:21@Chouserat work hiding the mistake, yes.
10:21@Chouser,(let [vec-order (zipmap [:b :c :a] (range))] (into (sorted-map-by (comparator vec-order)) {:a 1 :b 5 :c 6}))
10:21clojurebot{:b 5, :c 6, :a 1}
10:22@Chouserwait, that still looks right
10:22hyPiRiontry with [:c :a :b]
10:23@Chouseroh, actually you original example returned the wrong order but I didn't catch it. *sigh*
10:23@Chouser[:b :a :c] returned {:b 5, :c 6, :a 1}
10:23@Chouserok, so comparator isn't quite what is wanted here
10:24hyPiRionto put it mildly
10:24@Chouserin fact I think comparator is never needed because fns do that automatically
10:24TimMc&(map (comp :added meta) [#'*' #'*])
10:24lazybot⇒ ("1.0" "1.2")
10:25antifuchsyayy, almost got the most recent slime to connect
10:25hyPiRionChouser: Oh, I think it's needed for java interop
10:25@Chouser,(.compare (fn [a b] (> a b)) 2 1)
10:26clojurebot-1
10:26hyPiRion,(.compare > 2 1)
10:26clojurebot-1
10:26hyPiRioneven
10:27ro_stso that works (sorted-map-by #(< (vec-order %1) (vec-order %2)))
10:27@Chouserfn's implement java.util.Comparator and do something sensible when the fn returns boolean.
10:27fbru02i have a datomic question, simple one, let's say you got 2 peers and one value , peer one updates the value and keeps that cached in the machine, how does peer2 know that the value changed ?? is there a notification kinda thing ?
10:27ro_stnow i'm trying to walk a nested graph of maps
10:27ro_st(clojure.walk/prewalk (fn [x] (if (map? x) (sorter x) x)) mm)
10:28ro_stwould using sorted-map-by cause complications in doing this?
10:28ro_stif i don't use the sorter fn in the postwalk (not a prewalk) it comes out just fine
10:29hyPiRionChouser: So comparator isn't needed at all anymore, then?
10:29ro_stbut as soon as i use sorter, i get Evaluation aborted. which is super helpful
10:30ro_stfbru02: i believe the transactor is notified and the value only actually becomes available to everyone (including the source) process once the transactor commits
10:30ro_stdon't quote me on that, though :-)
10:31fbru02ro_st: oh i see , interesting that the source has to "wait" on the transactor , I guess that the transactor also has a list on which peers to notify on an update
10:32@ChouserhyPiRion: I can't think why it would be, but maybe I'm missing something.
10:32ro_sti could be dead wrong. but based on my understanding of the talks and reading i've seen and done, the transactor is the only thing that does writes
10:32ro_stwhich means that the only way to see new values is for the transactor to write it first
10:33@ChouserhyPiRion: But it's been this way a long time: https://github.com/clojure/clojure/commit/67975cdedfa8a2f7780062cb67182aff32e7679e
10:33ro_sti don't think the transactor notifies peers; i think your app would write and forget about it, or continue to use the value it already has a reference to post-write, or write, and then requery, causing the data to be retrieved again
10:34ro_stdo visit #datomic, anyhow
10:36robermannany counterclockwise user here? I followed the installation instructions but the leiningen project created by the plugin is empty (no src folder). Is it correct?
10:37fbru02ro_st: thanks !
10:39antifuchsok, so I have some local changes to swank-clojure that I want to try out. "lein run" doesn't work, and "lein swank" loads the mainline swank clj jar. how can I run my locally patched copy?
10:41hyPiRionChouser: Well, thank you for clearing up what it does. I always though it was implemented as (fn [f] (fn [x y] (.compare (f x) (f y))))
10:43dnolenonce again Yegge reveals that he never actually bothered to learn anything about Clojure ...
10:43ro_stdnolen: oh that is SOOOOOooo 24 hours ago -grin-
10:43@ChouserhyPiRion: That would be a useful function, but I don't think it's in core.
10:44zerokarmaleftdnolen: again? what was the first time?
10:44dnolenro_st: ? you mean 7 hours ago right.
10:45ro_stoh, has something new happened?
10:46ro_stchouser and cemerick discussed it in the podcast, and they definitely didn't record and release it less than 7 hrs ago :-)
10:46ivaraasendnolen: have you seen the survey based on part 1 of Yegge's essay?
10:46dnolenivaraasen: yes
10:46dnolenro_st: https://plus.google.com/u/0/110981030061712822816/posts
10:49ro_stso he doesn't want to ask for 'permission'. i guess he should be using windows 98 then, where any app can use any app's memory
10:50dnolenro_st: Clojure has atoms - his point makes no sense.
10:50magopianis yegge saying anything bad about clojure?
10:50dnolenro_st: it even has unsynchronized mutables
10:50magopiansorry, i missed the beginning of the discussion (or the context ;)
10:51dnolenmagopian: no he's not saying anything bad - he's just not saying anything that makes any sense.
10:51magopianhaha ;)
10:51wmealing_1going senile ?
10:51magopiani like his talk on "how to market yourself" or something like that
10:51magopians/like/liked
10:51hyPiRiondnolen: I thought his argument was that the language was liberal, but the community was not.
10:52dnolenhyPiRion: in some alternative universe where his points make sense ... maybe.
10:52magopiani still didn't find time to watch rich's last video
10:53hyPiRiondnolen: Yeah, it's a pretty confusing line of arguments.
10:53ro_stmagopian: watch it. it's great
10:55magopianro_st: i will, definitely
10:55magopianjust need to carve out some time :/
10:55ro_stcan do it audio-only
10:55clojurebotexcusez-moi
10:55magopianhey, clojurebot is french speaking, nice :)
11:00@ChouserAh, here's where comparator was introduced, almost a year before AFn gained the ability itself: https://github.com/clojure/clojure/commit/ad7a155a4950c93dfdc8c7168b77e8f73dba7e1e
11:04ro_sthyPiRion, Chouser: thanks for the sort advice. i got it going with postwalk - the error was that the map had keys not in the sort vector
11:05@Chouserah! yeah, that could do it.
11:06ro_stclojure amazes me every day
11:06ro_sti wonder what on earth i would have done with out it
11:06ro_stand i don't understand why everyone isn't using it :-)
11:07borkdudero_st enjoy a walk outside? reading a newspaper?
11:07@Chouserborkdude: no, probably coding in Java.
11:07ro_stnews?
11:07@Chouser:-P
11:07ro_struby, probably. we were going to use rails for the backend but i just couldn't bring my self to 'rails new'
11:08scriptorborkdude: just implement your news reader in clojure
11:08ro_stthen clojurebook came out and that was that #relief
11:09Wild_CatRails isn't so bad, from what I've seen.
11:09Wild_Cat(and on the Python side, Pyramid rocks)
11:09blackdogWild_Cat: it very much depends on where you're standing:)
11:10ro_sttoo much magic. not composable.
11:10Wild_CatI can't say much, though, I've never used Rails myself.
11:10scriptorI definitely got into django much faster than I did with rails
11:10Wild_CatI suppose it has the same flaws as Django, though
11:10blackdogro_st: also, not enough immutability. or types.
11:10Wild_Cat(seeing that Django started as a Rails clone)
11:10scriptorwasn't a fan of every tutorial starting with scaffolding
11:10ro_stblackdog: or any immutability :-)
11:11scriptorWild_Cat: it did? they're very different
11:11blackdogro_st: alter your type structure at runtime? Yessir, you're the boss...
11:11ro_st-grin-
11:11Wild_Catscriptor: my history is kinda fuzzy, but I think so, yeah. Both are tightly-integrated and couple frameworks, heavily optimized for the use case of SQL-backed CRUD webapps
11:12Wild_Cat...and both get more painful the more you deviate from that use case.
11:12scriptorWild_Cat: true, but that also describes a lot of frameworks
11:12Wild_Catfair enough :p
11:13Wild_Catthat's the thing I really like about Pyramid, to be fair: you can change the templating engine or the ORM with no effort.
11:13ivaraasenI went from Django to Flask myself. far more pleasant
11:13blackdogthere is a real benefit to imposed standards, though
11:13blackdogeven if a particular approach is not the best thing from a technical perspective, it means that everyone's working the same vein
11:13Wild_Catblackdog: oh, sure. And the important part is, Pyramid *does* provide sensible defaults that work out of the box.
11:14Wild_Catbut since I don't use a SQL database (I use DynamoDB with a custom mapper; another project here uses Mongo), I'm extremely glad I'm not forced into those defaults.
11:15blackdogsure, you need a variety of frameworks
11:16Wild_CatI suppose my point is, sensible defaults are essential, but locking the user into them even when it makes sense is bad.
11:17Wild_Catwhich, apparently, is also the approach taken by Noir, which is why I need to try it soon.
11:18@ChouserHaha! The survey mentioned in the comments to Yegge's last post has a "favorite language" question, but Clojure is not an option.
11:18clojurebotAck. Ack.
11:18blackdogreally depends on what you're trying to do. you could make Rails general enough to handle the Mars rover, but it would probably not be a net win
11:18blackdogChouser: that post was almost uniquely annoying
11:21magopiannice to see there's also quite a few python coders around here ;)
11:21ivaraasenChouser: notice how Yegge's supposed "liberal programmers" dominate every age group in the survey, with no linear relationship
11:21magopianblackdog: you were talking about the mars rover, do you mean it's programmed using clojure?
11:21clojurebotpackage.el is part of Emacs now: http://repo.or.cz/w/emacs.git/blob_plain/HEAD:/lisp/emacs-lisp/package.el
11:22blackdogmagopian: nah, making a more general point about frameworks :)
11:22magopianok ;)
11:22magopiani wonder what it's programmed with
11:22blackdogmars rover is all C
11:22magopianoh ok
11:22blackdogin a particularly punishing dialect
11:22magopianrootz ;)
11:23jcromartieivaraasen: where's the survey?
11:23weavejesterAre any Clojar admins around?
11:23blackdogmagopian: there's a fascinating document on the style they programmed it in - it looks a lot like a simple messaging system like erlang, but without dynamic memory allocation
11:23blackdoghttp://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf
11:23magopianwell, i can see why there would be no dynamic memory allocation ;)
11:24magopianthanks for the link
11:24blackdogreally embarrassing to get an out-of-memory exception on mars:)
11:24ivaraasenjcromartie: http://sweaxis.org/
11:24@Chouserivaraasen: hm, sure enough.
11:24ivaraasensummary of the survey: http://sweaxis.org/stats/age
11:28ivaraasenapplying American political metaphors to software engineering sounds like a horrible idea right from the get-go
11:28blackdogivaraasen: it's massively oversimplified
11:29blackdogas is the political spectrum, which i suppose means it's quite a good analogy
11:29antifuchsyayyyyy, got a connection with latest slime from quicklisp and swank-clojure (:
11:29scriptorivaraasen: how many people is that survey based on?
11:29antifuchsivaraasen: applying them to anything including american politics is a horrible idea (:
11:30ivaraasenscriptor: based on 750 data points a couple of hours ago I think
11:30scriptorthey don't completley fit american politics either
11:33zerokarmalefthttp://lars-lab.jpl.nasa.gov/JPL_Coding_Standard_C.pdf <= good grief, no malloc
11:34blackdogzerokarmaleft: a good idea, if you're restricted in ram and the cost of failure is high... :)
11:35zerokarmaleftblackdog: true, fascinating link
11:35ivaraasenzerokarmaleft: can't you just declare buffer sizes at compile time?
11:35@Chousermaybe NASA didn't think of that. :-)
11:35blackdogivaraasen: yes. they separate initialisation and runloop phases.
11:35ivaraaseninteresting
11:36blackdogbut for that, you don't need malloc anyway - if you know it statically, you can declare it as a stack variable
11:36scriptorI heard a lot of the C was generated as well
11:36magopianhas anybody done the problem 82 on 4clojure ? it's a tough one, i believe i'm nearly there \o/
11:36scriptoranyone know with what?
11:37ivaraasenscriptor: Python I've heard
11:37ivaraasenprobably just a rumour though
11:38@Chousermagopian: that's a relatively tough one. I enjoyed it.
11:45magopianChouser: i am enjoyng it ;)
11:46magopiani'm just missing the "find all possible combinations of words" now ;) (and i know how to program it, just need to ;)
11:46magopianChouser: did you solve all the problems?
11:46@Chouseron 4clojure? Yes, but then they added more.
11:46magopian147 it seems, out of the 151, excellent ;)
11:47magopian82 is my 131'th
11:47magopianstill some work left :)
11:48gtrakanyone ever fixed a XSS issue with compojure? I have a jetty servlet cross-origin-filter, but the browser is choking because an OPTIONS request (part of the XSS handshake) returns 404.
11:52TimMc"XSS handshake"?
11:52TimMcYou're trying to enable CORS?
11:54clojure-newcomerhi guys… is it possible/easy to dispatch on regular expression matching with multimethods ? currently dispatch on string value, but would like more flexibility
11:54gtrakTimMc: yes
11:54llasramclojure-newcomer: With multimethods, you can dispatch on anything computationally possible :-)
11:55gtrakTimMc: it's really only for development at the moment... server running in a VM, JS on the windows host
11:55clojure-newcomerllasram: col
11:55clojure-newcomerllasram: *cool even
11:58zerokarmaleftblackdog: someone needs to add Rule 32. Enjoy the Little Things to that document :D
11:58dnolenclojure-newcomer: that is not possible in a nice way.
11:59dnolenclojure-newcomer: multimethods lets you match on values generated by the dispatch fns, but you can't really do any kind of general predicate matching.
12:00llasramdnolen, clojure-newcomer: Oh yeah, I may have misunderstood the question. I was envisioning the dispatch function applying a regex to the arguments and then using the match to emit a concrete dispatch value
12:02clojure-newcomerhmmm…. ok, will have to think of a way round this
12:03llasramclojure-newcomer: What are you trying to do?
12:04clojure-newcomerllasram: I'm dispatching originally based on a function passed in, but then switched to a request uri
12:04clojure-newcomerllasram: wondering, can I get the symbolic name of a function as a string ?
12:04clojure-newcomerllasram: then I will not need regular expressions etc
12:04nelson-hi, Anyone here using emacs-prelude with ac-slime?
12:05nelson-I cannot get them to work properly, some completions throw Class not found exception
12:06llasramclojure-newcomer: Can you provide a concrete example? I'm not quite following :-)
12:06clojure-newcomerllasram: just wondering whether I can get the name of a function (or multi method) as a string ?
12:07clojure-newcomerllasram: using meta or something
12:07llasramclojure-newcomer: Kind of, but it's almost certainly a bad idea
12:07clojure-newcomerllasram: oh… why ?
12:08gtraklooks like compojure isn't responding to OPTIONS requests, and there's no OPTIONS macro... so my 404 handler is catching it
12:09llasramclojure-newcomer: Makes your code harder to reason about while winding implementation-naming details together with external interface. There's cleaner ways of getting similar effects
12:09llasramAt a higher level, do you have a concrete example of what you're trying to do?
12:10clojure-newcomerllasram: I see, increases complexity
12:10clojure-newcomerllasram: I'm dispatching to negotiate API version, and content-type of response based on 'accept'
12:13llasramAccept defines a strict preference-priority, doesn't it? Is there a reason not to just have a map of content-type to response-function, then dispatch to the highest-priority type present in the map?
12:14clojure-newcomerllasram: yes, although I will need to ensure the version is correct for the response type I choose
12:15llasramOk, so a map per API version, which just has the allowed types in it?
12:15gtrak.... how do I make compojure handle OPTIONS?
12:16clojure-newcomerllasram: I see… simplify down to simpler building blocks
12:17llasramclojure-newcomer: Yeah, hopefully :-). multimethods are very powerful, but not necessarily the best fit for all dispatch problems
12:39antifuchsis there a built-in thing in 1.2.1 that splits strings at a particular delimiter? I'd love to use clojure.string/split, but that name doesn't exist in 1.2.1 ):
12:40technomancyantifuchs: it was added in 1.2.0
12:40antifuchsodd!
12:40antifuchsI think I may have to experiment further
12:47antifuchssooo, Caused by: java.lang.ClassNotFoundException: clojure.string
12:47antifuchswhat does that mean? Do I have to include something special in project.clj?
12:48raek_antifuchs: I think you are doing something like (require clojure.string) instead of (require 'clojure.string)
12:48antifuchsooh, it's not on the require list
12:48raek_unlike 'ns', 'require' is a function and not a macro
12:49antifuchshanging it on the ns declaration did it.
12:49antifuchsthanks, raek ((:
13:03rplevyis anyone else getting an error when lein goes to fetch dependencies right now?
13:04rplevy"Caused by: org.sonatype.aether.resolution.VersionRangeResolutionException: No versions available for org.clojure:clojure:jar:[1.2.1,1.3.0] within specified range"
13:05llasramrplevy: I saw on the mailing list that some maven central metadata seems to have gotten b0rked again
13:06rplevybooo
13:06technomancyhuh, looks fine here
13:06technomancymaybe a problem with a local mirror?
13:07technomancyalso: maybe it's time to host Clojure on clojars, because this is starting to become a regular occurrence. =\
13:08technomancyrplevy: maybe it's been fixed and your cache has the busted metadata? can you try `lein -U deps`?
13:12rplevyhrrmm lein -U deps doesn't seem to help
13:14technomancyhuh, just ran it on a fresh m2 here; works fine
13:14technomancydoes http://repo.maven.apache.org/maven2/org/clojure/clojure/maven-metadata.xml list all the correct versions for you?
13:14technomancy(to rule out geographic mirror issues)
13:15TimMcgtrak: I think I remember someone asking about this in the past. Check the logs.
13:15rplevyI deleted my .m2 too...
13:15gtrakok
13:15gtrakI'm currently trying to hack it
13:16gtrakbut I don't quite understand how clout works, it's choking on the :options method
13:16rplevytechnomancy: that file only lists version 1.2
13:17technomancyrplevy: looks like others on the mailing list are seeing it
13:18technomancyrplevy: can you paste traceroute to repo.maven.apache.org along with a curl of the affected page?
13:20redingerWe had a problem this morning with lein2 (not in lein1). Had to add sonatype back into our project.clj
13:20technomancyI'm going to publish it to clojars
13:20technomancythis is just silly
13:25rplevytechnomancy: https://gist.github.com/3371828
13:25technomancyhttp://clojars.org/repo/org/clojure/clojure/
13:25rplevyawesome
13:26gtrakTimMc: OK, got it, turns out you can put regular functions in under defroutes... and compojure calls 'some' to find the first one that returns a truthy response, so, just a standard ring-handler does the trick
13:35technomancyso I don't feel like following through with Central now that the workaround is on clojars, but if someone else wants to follow up you can do so here: https://issues.sonatype.org/browse/MVNCENTRAL
13:36redingertechnomancy: great! Any chance you want to put alphas out there as well? :)
13:37technomancyredinger: ok
13:38redingerI'm more than happy to push them up when released if that would help
13:38technomancyactually I don't have them on my box, just the poms
13:38technomancyI can pull them in via a dummy project
13:39rplevyI wonder what the root cause of this mvn central screwiness is
13:39rplevysince it happened before too
13:41TimMcgtrak: Yay for composability!
13:41rplevyI guess that's for them to figure out, hence the issue being created.
13:42technomancyredinger: ok, 1.5 alphas are up
13:42redingertechnomancy: Thanks!
13:43technomancyredinger: is it usually stuart sierra who handles the releases? would it make sense to add him to the clojars group?
13:43redingerYeah, he's been doing the 1.5 releases
13:44technomancyhm; if he has a clojars account, it's not obvious what it is
13:44technomancyI'll wait to see if he responds to the mailing list thread I guess
14:06jweisshttps://www.refheap.com/paste/4415 <- what if i sometimes run on eclipse and swank isn't loaded? is there a way to write this middleware so it will always compile and just do nothing if swank isn't there?
14:07jweissi'm not sure how to call binding with a symbol it might not be able to resolve.
14:07jweissmaybe i should just let it fail, and catch the error.
14:09jweissnah i can't do that because it won't even compile.
14:09technomancyyou could look at how binding is implemented and make a version that works with dynamically-resolved vars
14:09S11001001progv supremacy :)
14:09technomancyif you don't mind being hugely sketchy
14:10jweissit's probably better to just add swank as a dep. even though eclipse won't use it.
14:10jweissa dev dep
14:11S11001001jweiss: if you're loading from source you could just have a macro expand differently depending on whether swank is present
14:15jweissS11001001: i'll try that thanks
14:16dnoleneven Groovy gets to have the fun! http://blog.bloidonia.com/post/29552846202/using-clojure-and-core-logic-from-groovy
14:18nz-gtrak: compojure has OPTIONS macro, so it should work just like with other http methods.
14:19gtrakhuh...
14:19gtrakmaybe my version just doesn't
14:19gtrak1.0.4
14:20gtrakyep...
14:20gtrakwell, at least I learned something by digging :-)
14:20nz-latest is 1.1.1
14:21nz-https://github.com/weavejester/compojure/blob/master/src/compojure/core.clj#L140
14:21gtrakyea... I only wasted a couple hours on that ;-), thanks for letting me know though
14:21nz-and it works at least in 1.1.0
14:24nz-gtrak: it seems to be one of the latest additions to compojure
14:25gtrakthe *one* time I forget to pull the latest version for something :-)
14:27SegFault1X|work2I really enjoy Rich Hickey's tech talks. He's a really entertaining and informative speaker.
14:28Iceland_jackSegFault1X|work2: Definitely
14:28SegFault1X|work2Whether or not I agree with some of his conclusions, I consistently enjoy watching them.
14:28nz-is it possible some how to manipulate compojure routes as data
14:29nz-Basically I'd like to automatically generate api documentation from the routes
14:29gtraknz-: you can learn from what I just figured out :-)... compojure macros generate ring handlers, then it runs the 'some' function to select the first that matches
14:29SegFault1X|work2gtrak: That's surprisingly straight forward.
14:30gtrakif you wanted to generate more detailed api documentation, you could possibly wrap the macros
14:32gtrakthis is how I reinvented OPTIONS actually: https://gist.github.com/3372429
14:33SegFault1X|work2It would be neat if you could just incorporate metadata into the routes, then generate the documentation from the route metadata.
14:33gtraknote I used a function instead of a macro
14:34SegFault1X|work2That way the documentation still lives in code, but it's not necessarily tied to the route structure.
14:35_fogus_self-quotation is the only way to fly
14:36emezeske_fogus_: Is that something you said yourself?
14:36_fogus_"Self-quotation is the only way to fly" --me
14:37SegFault1X|work2I like recursive quotes. :)
14:37_fogus_(Me 2012)
14:37emezeske""Self-quotation is the only way to fly" --me" --fogus
14:38gtraklet's all start speaking in quines please
14:38emezeskehaha
14:38SegFault1X|work2Oh you mean turn #clojure into reddit? Got it. :)
14:38nz-http://jng.imagine27.com/index.php/2009-09-18-203946_clojure_quine.html
14:38gtrakha
14:40SegFault1X|work2I have no idea how that works.
14:42scriptorhuh, it's actually pretty simple
14:44scriptorSegFault1X|work2: it creates an anonymous function and calls it with the second half of that expression
14:44scriptorif you replace it with '2' or something like that
14:44nz-rather verbose way to do it
14:44scriptor,((fn [x] (list x (list (quote quote) x))) 2)
14:44clojurebot(2 (quote 2))
14:45Gnosis-when working with a vector or array, does drop do any processing per element skipped, like it would with a list, or is it a constant time operation?
14:45scriptorso if instead of 2 you feed it the anonymous function, you get ((fn …) (quote (fn …)))
14:45hiredman,(doc drop)
14:45clojurebot"([n coll]); Returns a lazy sequence of all but the first n items in coll."
14:46SegFault1X|work2scriptor: Yup, I'm playing with it now.
14:46SegFault1X|work2scriptor: You're right, it is pretty easy.
14:46scriptorSegFault1X|work2: yea, sorry if I just stated the obvious, just wanted to explain it to make sure I got it myself
14:46jolyscriptor: that's a whole lot nicer than the character-based quines I've seen for other languages
14:47Gnosis-hiredman: how does it skip those first n items, though? does it get them and throw them away, even for collections that support random addressing?
14:48Gnosis-random access*
14:48nz-http://asiajin.com/blog/2009/09/22/uroboros-programming-with-11-programming-languages/
14:48scriptorGnosis-: I think it does
14:48Gnosis-oh
14:50scriptorGnosis-: essentially, it keeps a counter and calls rest until the counter reaches 0
14:50SegFault1X|work2Gnosis-: Clojuredocs.org has the source if you want to see what's /actually/ happening.
14:51SegFault1X|work2Gnosis-: http://clojuredocs.org/clojure_core/clojure.core/drop just scroll to the bottom and click Source
14:51Gnosis-okay, thanks
14:56aaelonystruggling to get in incremental counter i using for. How can I get i to increment in something like the following? (for [x [:x1 :x2 :x3 :x4 :x5 :x6] :let [i 0] ] (assoc {} x (inc i))) => ({:x1 1} {:x2 1} {:x3 1} {:x4 1} {:x5 1} {:x6 1}) ... I'd like to see ({:x1 1} {:x2 2} {:x3 3} {:x4 4} {:x5 5} {:x6 6})
14:58emezeske,(into {} (map vector [:x1 :x2 :x3 :x4 :x5 :x6] (range)))
14:58clojurebot{:x1 0, :x2 1, :x3 2, :x4 3, :x5 4, ...}
14:59emezeske,(into {} (map vector [:x1 :x2 :x3 :x4 :x5 :x6] (range 1)))
14:59clojurebot{:x1 0}
14:59aaelonyis it possible using for ?
14:59Bronsa,(into {} (map vector [:x1 :x2 :x3 :x4 :x5 :x6] (rest (range))))
14:59clojurebot{:x1 1, :x2 2, :x3 3, :x4 4, :x5 5, ...}
14:59emezeskeBronsa: hah, thanks :)
14:59Bronsa:)
14:59raekaaelony: for assumes you want to calculate each value independently from the others
15:00emezeskeaaelony: In your "for", "i" is not a variable, it is just the value 0 being bound to the name "i"
15:00emezeskeaaelony: So on each iteration of the for body, "i" evaluates to 0 again
15:01emezeskeaaelony: If you really want a mutable variable, you'll need to use an atom or something like that
15:02emezeske,(let [i 0] [(inc i) (inc i) (inc i) (inc i)])
15:02clojurebot[1 1 1 1]
15:02emezeskeaaelony: ^ i is always zero, it is not ever modified.
15:02aaelonymaybe I'm going about this wrongly. I have a for statement that is doing a lot of things, mostly creating an aggregate output mapping. I want to keep track of what's contributing to the aggregates, so I'd like an iteration i that I can stuff into a vector that goes into the map. is there a better way?
15:02aaelonyperhaps an atom or var is the way to go...
15:03emezeskeaaelony: I would do something like (for [[x i] (map vector xs (range))] ...)
15:03aaelonyemezeske: that looks good, thanks!
15:04emezeskeaaelony: Yep! For the record, an atom would definitely work, but something like the above is just more idiomatic (it's more in the functional style)
15:05gfredericksyegge doesn't know about atoms does he?
15:05aaelonyemezeske: that's exactly what I was after! :)
15:06Gnosis-what's a good way to profile?
15:12ivaraasenGnosis-: I mostly use the time function. jvisualvm is nice too
15:16hiredmanprofiling and benchmarking are different
15:16hiredmanjvisualvm is good for profiling, criterium is a neat benchmarking library
15:28Gnosis-ah, those are some good ideas. thanks!
15:34michaelr525hello
15:36jmolettest
15:46muhoo_hmm, lein preview8 doesn't include nrepl anymore
15:48hiredmanmuhoo: seems unlikely
15:48muhoohttps://www.refheap.com/paste/4418
15:48muhoothat's with preview8.
15:48muhoowith preview7, works just fine
15:50muhoolein deps :tree are identical for both.
15:51DanBellanyone want to explain to me why (re-find #"[a-z][0-9]" "a1b2c3") returns a match but (re-match #"[a-z][0-9]" "a1b2c3") doesn't?
15:52ChousukeDanBell: re-find finds a substring that matches the regexp, and re-match tests if the whole string matches the regexp?
15:53ChousukeDanBell: first one should find "a1", but the regexp won't match the whole thing
15:53DanBelloh, so "matches" is a verb in the singular, not a plural noun?
15:53DanBellit *seemed* to have duplicate functionality with re-sew, ha
15:54DanBell*re-seq
15:55muhoohiredman: it's something in my profiles.clj causing grief, apparently.
15:55DanBellty houser
15:57muhoohiredman: hmm, apparently not. with no profiles.clj at all, still happens. FileNotFoundException, for clojure/tools/nrepl/server.clj
16:05muhooonly in trampoline mode, works without trampoline
16:15technomancymuhoo: huh, trampoline repl works here
16:16technomancycan you repro on a fresh project?
16:17xeqitechnomancy: I can repoduce on a fresh project
16:17technomancyI do see that it's using reply beta6 for some reason
16:18xeqihttps://www.refheap.com/paste/4421
16:18technomancyoh never mind, I was using a snapshot
16:22technomancyok, this is the same problem as https://github.com/technomancy/leiningen/issues/695
16:24muhootechnomancy: thanks, makes sense.
16:25muhoois there a workaround?
16:25technomancyfor the time being, probably just an explicit nrepl dependency in defproject =\
16:25technomancyprofiles are getting ignored by the trampoline task
16:25muhooi tried that, but then it complained about not being able to find complete/core.clj
16:25muhooand i wondered how deep that rabbit hole went
16:26i_sif I have to make a change to a library, and then want to use that changed library in my project, whats the best way to do it?
16:26technomancymuhoo: ok, this should do it: [reply "0.1.0-beta10" :exclusions [org.clojure/clojure]]
16:26muhootrying now
16:27muhootechnomancy: works, thanks!
16:29scriptorhmm, playing with time, it looks like (map (partial * 2) (range 1000)) can be anywhere from 3-4 times as fast as the equivalent with an anonymous function
16:31S11001001scriptor: did you dorun?
16:31scriptorS11001001: nope
16:32scriptorprobably should?
16:32S11001001(fn ...) implies the first-time construction of a newly created class
16:32hugodantifuchs: how is rpc.clj hacking going?
16:32muhoo(do (dorun run run) (do (dorun run))
16:32S11001001if you want to time function call time, calls to the relevant function must overwhelm that consing
16:33scriptorah
16:33S11001001this is one of the very, very, very few times I would encourage use of loop :)
16:34dnolenscriptor: partial is nearly always slower - you need to pick a larger n and force w/ doall or dorun to see.
16:35rplevyalso, if you have a nested structure, the forcing of evaluation is not automatically recursive, you need to make sure you force the laziness in those sub structures
16:36scriptoryep, after binding the function before calling map and calling dorun the partial one is slower
16:39muhooi_s: the easiest i've found is to use the checkouts dir in the project
16:40muhooi_s: i.e. if i'm working on foo, and also a library bar, then "cd foo; mkdir checkouts; ln -s ../bar checkouts/bar"
16:42i_sill try that muhoo, thanks!
16:45jmlI feel a bit silly for not being able to figure this out from the docs, but say I have a clojure program (e.g '(println "foo")'), how do I turn that into something I can run from the command-line
16:46hyPiRionjml: What kind of operative system do you use?
16:46jmlhyPiRion: linux
16:47nz-jml: make a main method (defn -main [] <code goes here> )
16:47technomancyrunning Clojure from the command line is currently kinda crap compared to most non-java languages
16:47muhoojml: "lein new foo", then have a look at foo/src/foo/core.clj -main.
16:47nz-jml: then lein run -m name-of-your-namespace
16:48hyPiRionIf you want to have some scripting-like way of executing it, you can do "clojure filename"
16:50jmlthanks all
16:50hyPiRionAnd if you want to omit the "clojure" part, you can add a "#!/usr/bin/clojure" on top of the file, then make it executable
16:51jmllein seems pretty important.
16:52technomancyI wonder if you can do a shebang with lein
16:53jmlso packages are often shipped as binaries
16:53hyPiRionhm
16:53jmlas scripts, rather?
16:55hyPiRionClojure starts up pretty slow, so scripts aren't that widespread, I suppose.
16:56hyPiRionIn addition, Clojure is simple, not easy. Usually you would sacrifice for simplicity for some easiness in small programs.
16:56dnolenjml: by packages do you mean libraries?
16:56jmldnolen: I mean things like Debian packages
16:57technomancyjml: libraries for dependency management are nearly always shipped as source, inside jar files
16:59jmlwhat about client-side programs?
16:59dnolenjml: no convention as far as I know because platforms differ greatly
17:00S11001001I would ship an uberjar and hope everyone can figure out how to run them :)
17:00hyPiRionI would uberjar leiningen projects if I would ship client-side though.
17:00jmlah hah, I see.
17:00technomancyjml: `lein help tutorial` covers some of the common distribution methods
17:00technomancynear the end
17:01nz-jml: with uberjar you can just execute the thing like this: java -jar my-uber.jar
17:01S11001001double-click works pretty often
17:04Cr8for scripty type things, just for personal use, I've used nailgun
17:09nz-http://www.martiansoftware.com/nailgun/
17:09nz-that?
17:10Cr8yes
17:11Cr8i'd have a nail in my misc namespace that would do dispatch
17:11technomancymuhoo: I think your issue is fixed in master; can you confirm the patch works for you?
17:14antifuchshugod: great! I started hacking on swank-clojure, and am currently able to connect with this month's quicklisp's slime
17:15antifuchsthe P and L parts of slime-repl don't work currently
17:15antifuchsbut it's coming together - reading and evaling works (;
17:18l1xhey guys what is the datatype if is see #<some strings> when I println the variable? I thought it is a vector
17:19scriptorwhat variable and what does it contain?
17:19S11001001l1x: you can tell based on what's in those strings
17:20l1xit is coming from the JMX library and it looks like this #<ObjectName hadoop:service=DataNode,name=DataNodeInfo>
17:20antifuchshugod: I think it should be pretty trivial to port over to ritz; also, my stuff seems to clean up&simplify a lot of things (:
17:21nDuffl1x: Easiest way to tell the type is to look at (type your-variable). That said, in this context, it would presumably be a javax.management.ObjectName
17:22l1xnDuff: amazing! this is what i was looking for!
17:31hugodantifuchs: so you're porting swank-clojure to a recent slime? ritz was working against a more recent slime than swank-clojure. Are you finding many changes required in swank-clojure?
17:31antifuchsjust stuff to support the updated net code, and then a few arglists that changed, so far
17:32hugodone thing was the support for swank::%cursor-marker%
17:32jmlare there API / reference docs for clojure.test
17:32antifuchsI'm not really done yet - there's some confusion with how returned values are formatted, so can't really judge how much work is left (:
17:32hugodslime changed the net encoding recently?
17:34jmloh hey, google is great.
17:34symuynGetting frustrated at partition: hey, what's a good way to turn (0 1 2 3 4 5) into ((0 1 2) (1 2 3) (2 3 4) (3 4 5) (4 5) (5))?
17:34symuynWhich partition can't do, as far as I can tell, heh
17:34antifuchshugod: not really recently
17:34antifuchsit was 1.5 years ago
17:35antifuchsjust, both ritz and swank-clojure still require a 2010 slime (:
17:35metellus,(partition 3 1 '(0 1 2 3 4 5))
17:35clojurebot((0 1 2) (1 2 3) (2 3 4) (3 4 5))
17:35metellus,(partition-all 3 1 '(0 1 2 3 4 5))
17:35clojurebot((0 1 2) (1 2 3) (2 3 4) (3 4 5) (4 5) ...)
17:35symuynOh, wow
17:35i_smuhoo: i'm getting a FileNotFoundException with the checkouts directory approach. Is there something special I have to do if the project name is multipart? In this case, the directory is called "friend", and the artifact (or whatever its called) is com.cemerick/friend
17:35hugodantifuchs: you have a pointer to the change?
17:35symuynThanks a lot
17:35antifuchshugod: I think you participated in the discussion of that announcement
17:36antifuchsthat was when Helmut introduced binary prefixes
17:36hugodantifuchs: the last I heard Helmut decided not to go ahead with it
17:36antifuchsbut that seems to have changed to 6 hex digits counting chars
17:36technomancyi_s: that shouldn't matter for checkouts. do you have it in project.clj though?
17:36antifuchserm
17:36antifuchsI meant, 6 hex digits indicating number of bytes to read
17:37antifuchsand I believe it mandates utf-8 now
17:37antifuchswhich is just such a huge relief, I can't even tell you (:
17:37i_stechnomancy: i took it out of project.clj
17:37hugodI think utf-8 is the only change - it was always a six hex digit length encoding iirc
17:37technomancyi_s: why?
17:38antifuchshugod: anyway, that's what rpc.lisp does now, and also what rpc.clj does (:
17:38antifuchsit used to indicate number of chars though, and it's bytes now
17:38antifuchssubtle change, and imperceptible if you operate on ascii only
17:38i_stechnomancy: someone on the internet told me to. but I will see what happens if i include it.
17:38hugodah, gotcha
17:38technomancyi_s: go smack 'em for me =)
17:39i_shaha
17:39antifuchsbut it makes everything way easier to handle, I think
17:39technomancyfor some reason that's a widespread misconception
17:40antifuchsoh crap
17:40antifuchsI hadn't reloaded emacs, and it had broken state it seems.
17:41antifuchsjust restarted, and the REPL works now, connected to swank-clojure.
17:41antifuchs<3 <3 <3
17:41hugodyeah!
17:41antifuchsbacktraces in the debugger, check
17:41antifuchsah, restarts seem to not like getting invoked
17:42hugodis that using cdt?
17:42antifuchsnot sure! I think it might be
17:42antifuchswell, it's the emacs side beeping
17:42antifuchsmust be some argument list that changed
17:42hugodif it has frame locals, then it's cdt
17:44antifuchs[No Locals]
17:44antifuchsso, probably not cdt
17:45antifuchsinteresting! "java.lang.Integer cannot be cast to clojure.lang.IFn"
17:46scriptorwhat code are you running?
17:48antifuchs(nth (keys *sldb-restarts*) n) (with n being an integer, and *sldb-restarts* a map
17:49i_stechnomancy: just tried that, but now i get the old and busted version. running lein classpath also doesn't show the one that i'd expect from checkouts. any tips?
18:02antifuchsamazing, just passing back the Throwable as a string makes the abort restart work, too
18:02antifuchsso nice.
18:04michaelr525hello
18:04technomancyi_s: `lein classpath` should show both, with the src/ dir of the checkout version before the jar
18:11l1xis there a way to add the output of this (which is strings) to a hash? in ruby I would ().each {|a| target_hash <<a }
18:11l1x(doseq [s (jmx/mbean-names "hadoop:*")] (prn (. s getCanonicalName)))
18:14aperiodicl1x: check out 'with-out-str'
18:18l1xcool, i dont get it :)
18:19antifuchshugod: https://github.com/antifuchs/swank-clojure/tree/quicklisp-swank has my changes - it's not a ton of stuff that needed updating! (:
18:21emezeskel1x: What are they keys and what are the values in this hash?
18:21gtrakl1x: (into {} (for [[k] (jmx/mbean-names "hadoop:*")] [k (.getCanonicalName k)])) ?
18:22emezeskel1x: In Ruby it doesn't even seem like the << operator is defined for Hash
18:22l1xemezeske: rite i was thinking about an array :)
18:22l1xgtrak: thx!
18:23emezeskel1x: Oh, if you want an array, just do (for [s (jmx/mbean-names "hadoop:*")] (. s getCanonicalName))
18:23emezeskel1x: "for" returns a lazy seq of its the results, unlike doseq which returns nil
18:23gtrakor you can just use map at that point
18:23amalloy(map (memfn getCanonicalName) (whatever))?
18:24emezeskeamalloy: Wow, memfn sure beats #(. x y), I didn't know about that
18:24gtrakhuh
18:25l1xok, thanks guys i try to work out the details based on these ^^ ( #second_day_with_clojure )
18:25antifuchsoh my. sooo nice. <3
18:25gtrakl1x: have more days!
18:26l1x:))
18:26amalloyemezeske: well, memfn's actually kinda limited as it is
18:26amalloyeg, you can't typehint it
18:27amalloyhttp://dev.clojure.org/jira/browse/CLJ-910 would be nice
18:28emezeskeamalloy: Ah, it still looks handy for those quick use cases
18:28emezeskeSeems like a no-brainer change to add that!
18:29amalloynothing is ever a no-brainer on jira
18:29emezeskeThere is waay too much truth to that statement. :(
18:30technomancyI had to resist from chiming in on the "what about people who fix multiple bugs in a single issue" thread
18:30amalloyalthough the past week has been unusually productive in terms of accepting patches, so i should bridle my venom
18:30technomancyI really wanted to say "maybe if jira didn't suck so much, people wouldn't mind opening a separate issue for it"
18:30michaelr525why would (count (macro-with-binding (doall (lazy-seq-func)))) behave differently from (count (doall (macro-with-binding (lazy-seq-func))))?
18:31Raynestechnomancy: That's all a little ridiculous anyways.
18:31amalloytechnomancy: a couple days ago rich asked me to take my patch from may and split it up into about five different jira tickets
18:31RaynesIt isn't as black and white as they're making it out to be.
18:31RaynesI wouldn't have the patience to do that. I'd just give up and deal with it. :\
18:32amalloyRaynes: to do what?
18:32amalloy(or, deal with what?)
18:33RaynesSplit up a patch like that. I mean, if it was all completely unrelated than it shouldn't have been the same patch anyways, but if it was all related to one problem...
18:42michaelr525jkhdkjgdh
18:43jmlThe tutorial at <http://java.ociweb.com/mark/clojure/article.html&gt; says 'To create a new _application_ project, do "lein new app my-app"'. What's an application project and how is it different from a non-application project?
18:43technomancyjml: an application is just something that's not a library
18:44michaelr525jml: what is a non-application project? :)
18:44jmlmichaelr525: I don't know!
18:45jmltechnomancy: In which case, I don't get the significance of the two arguments to 'lein new'.
18:46technomancyjml: does `lein help new` make it clearer?
18:47jmltechnomancy: if I hadn't read that comment in the tutorial, it would seem very clear.
18:47hyPiRionUnread the comment.
18:48Raynestechnomancy: Told you that differentiating would be confusing and annoying.
18:48nDuffjml: Non-application projects are things like leiningen plugins
18:48RaynesNo.
18:48nDuffjml: ...ie. based on a different, special-purpose template
18:49nDuffNo?
18:49RaynesThere is a template for that too.
18:49technomancyif you have a :main, you're an application
18:49jmltechnomancy: if I read 'lein help new', I would interpret it as "make a project, but put it under a differently named directory to the default"
18:49technomancyif you push to clojars, you're a library
18:49RaynesThere are built in templates for 'apps', libraries, plugins, and templates.
18:50jmlbut to go from that to whether something is an application or not seems a stretch
18:51RaynesI have no idea what you just said.
18:51technomancypart of the problem is that we had to put the optional argument first for compatibility's sake
18:51jmlRaynes: sorry. I'm confused. That makes it harder to make sense.
18:52RaynesIt seems like you might be overthinking things.
18:52RaynesSlightly.
18:53Raynestechnomancy: We should really rewrite things so that a name argument isn't required and all args (save for :show, I guessed) are passed directly to templates.
18:54jmlOK. Seems most sensible to pretend that that particular instruction in the tutorial is wrong.
18:54RaynesAnd by we I mean me at some point.
19:00gtrakanyone have an IOFactory implementation for hadoop they'd like to share xD
19:00antifuchsheh, funny that I added a :main to swank-clojure then (:
19:00technomancyantifuchs: not at all; swank-clojure is end-user-facing
19:00antifuchscool cool (:
19:01antifuchstechnomancy: btw, set up a branch for latest quicklisp compat at https://github.com/antifuchs/swank-clojure/tree/quicklisp-swank
19:01technomancyantifuchs: are you planning on getting it into ritz?
19:01antifuchsmight be interesting soon, once I figure out instructions to install quicklisped slime
19:02antifuchsyes, definitely
19:02antifuchsthat's tomorrow's hack project
19:02technomancyok, I would rather point people there rather than to swank
19:02antifuchsunderstandable
19:03gtrakor rather I guess I need to add a URL-handler for the hdfs-prefix
19:08haspakerI have made two solutions for the 4clojure problem 106
19:08haspakerhttp://pastebin.com/eE9rHUgM
19:08haspakerOne in Python and one in Clojure, and both of them use the exact same method
19:08haspakerBut I like pastebin!
19:09nDuffhaspaker: it's full of ads and basically featureless compared to its competitors.
19:09haspakerAnyway, the Clojure version is extremely slow compared to the python one
19:09nDuffhaspaker: If you were using gist, for instance, you could have the two files as separate pastes, each syntax-highlighted accordingly, and we could check it out and run it using git if we wanted to.
19:09nDuff(separate pastes within the same gist, that is)
19:10nDuff...and we could fork the gist, and have revision-controlled history
19:10jmlfigured out the confusion
19:10jmllein 1.x vs lein 2
19:10haspakerHmm
19:10haspakerI'll look into it, nDuff
19:10l1xcould somebody have a look what I am doing wrong in this? (for [mbean (doseq [s (jmx/mbean-names "hadoop:*")] (. s getCanonicalName))] (jmx/mbean mbean))
19:10jmltime to go to bed. thanks for the help.
19:10l1xbasically i get the hadoop mbean names and i would like to iterate over it and get the actual attributes
19:11nDuffhaspaker: ...there are also "pastebin" services specific to Clojure that run pasted code inside a sandboxed VM, so we can see what it does straight off the web...
19:11nDuffhaspaker: ...whereas pastebin.com gives you no interesting features whatsoever, but lots and lots of ads.
19:13patchworkAnyone using swank-clojure ever get errors that never get displayed in slime, even though they are shown in the repl?
19:13patchworkis swank-clojure swallowing errors?
19:14patchworkThe simplest case I have for this is simply (+ nil nil)
19:14haspakernDuff: You made me see the error of my sinful ways, so at least it wasn't a worthless rant :>
19:14patchworkit shows the error in > lein repl
19:14haspakerhttps://gist.github.com/3374386
19:14patchworkbut in slime it just says "Evaluation aborted;"
19:14amalloypatchwork: it usually displays errors, but sometimes it doesn't and i don't know why
19:14amalloyeg, (+ nil nil) works fine for me (i get a trace)
19:14patchworkamalloy: sometimes if I do that twice, the second time it fails
19:15patchworkreally weird
19:15Bronsapatchwork: same here
19:15patchworkAny clues? It can be really annoying to have kick up the repl in terminal
19:16amalloypatchwork: are you closing the error buffer correctly?
19:16patchworkI just hit '0' in emacs
19:16patchworkis there a better way to close it?
19:16amalloy0 or q should both be fine. just don't like C-x 0 to hide the buffer
19:16patchworkI wonder if swank swallows jvm errors because it generates certain ones and wants to hide it
19:17xeqihaspaker: changing (flatten (map ...)) to (mapcat ...) causes a decrease from 850ms to 110ms on my box
19:17technomancypatchwork: there's a bug in clj-stacktrace where it can occasionally happen
19:17technomancycheck *e
19:17amalloyflatten is atrocious in so many ways
19:17xeqi(inc amalloy)
19:17lazybot⇒ 27
19:18amalloyoh man, i can get karma for complaining about flatten? i could do that all day
19:18patchworktechnomancy: So you think this is a clj-stacktrace problem, not a swank-clojure problem? Hmm...
19:18patchworkamalloy: what is wrong with flatten?
19:18xeqi~flatten
19:18clojurebotflatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with.
19:22michaelr525damn
19:23haspakerxeql: Your solution makes it about as fast as the python file for small numbers, but Clojure still has a memory problem for the larger calculations
19:23haspakerFor example, try (find-path 3 12912)
19:23haspakerPython spits out an answer in about 5 seconds
19:23haspakerClojure chews for two minutes until it throws an OutOfMemoryError
19:24haspakerIt seems like Clojure can't juggle with large lists the same way Python can
19:24emezeskehaspaker: It looks like your recursion is in the tail position
19:24emezeskehaspaker: Have you tried using recur?
19:25haspakerWait a sec
19:25emezeskehaspaker: I'm guessing that if you changed the Python version to use recursion that you'd have the same problem
19:26haspakerRecur seems to have the same problem
19:26haspakeremezeske: Yeah, but is it even possible to do it in Clojure without recursion?
19:27emezeskehaspaker: Of course it is. Anyway, if you use recur, it will basically be just looping anyway.
19:27amalloyof course. but too much recusion is never going to lead to an OOME
19:27emezeskeamalloy: It will always hit a stack overflow before oom?
19:27amalloyno
19:28amalloybut recursion will contribute to SOE, not to OOME. if you're hitting OOME, reducing recursion won't make a difference
19:28emezeskeHuh
19:28emezeskeI guess the stack space in the JVM is a separate thing from the heap space
19:29emezeske-Xss as opposed to -Xms or whatever
19:29amalloyyes
19:29michaelr525why would (count (macro-with-binding (doall (lazy-seq-func)))) behave differently from (count (doall (macro-with-binding (lazy-seq-func))))?
19:30amalloyhaspaker: fwiw, my solution to that problem solves (f 3 12912) in 5s
19:31haspakerCool. Could you upload it?
19:31michaelr525i don't get it gggg
19:31michaelr525it drives me crazy
19:31emezeskemichaelr525: What is macro-with-binding?
19:32amalloygod, 4clojure is so slow now. i thought i rolled back to a faster version
19:32amalloyhaspaker: https://gist.github.com/349eb71c83e9bd98d04c
19:32michaelr525it's a macro with just (binding [...] @body)
19:32emezeskemichaelr525: Could your problem have to do with the fact that bindings and lazy-seqs don't get along well?
19:33emezeskemichaelr525: In your second example, the binding would not affect the lazy-seq stuff when doall realized the lazy-seq, I think
19:34michaelr525emezeske: the funny thing is that the second example behaves in a way it
19:34michaelr525's supposed to
19:34emezeskemichaelr525: So does the first
19:34michaelr525while the first one returns strange results
19:34michaelr525i mean returns the expected results
19:34emezeskemichaelr525: In your first example, the binding is not in effect when the lazy-seq is realized
19:35michaelr525how so?
19:35emezeskemichaelr525: http://kotka.de/blog/2009/11/Taming_the_Bound_Seq.html
19:35emezeskemichaelr525: http://cemerick.com/2009/11/03/be-mindful-of-clojures-binding/
19:35emezeskemichaelr525: Maybe those will be helpful
19:36michaelr525maybe..
19:36michaelr525thanks
19:36michaelr525i'll read it
19:36michaelr525sometimes clojure just drives me nuts
19:37michaelr525is there reallly a good reason to write something in cps?
19:37michaelr525i'm talking about clj-http
19:46michaelr525emezeske: actually according to cemerick's article the first example should produce the correct result
19:46michaelr525emezeske: in the first example i realize the lazy sequence inside the binding
19:47emezeskemichaelr525: Oh, whichever way, I guess I had the order mixed up
19:47emezeskemichaelr525: I don't know what you mean by "correct result", though, they both work correctly
19:47emezeskemichaelr525: They just do different things
19:48haspakerI rewrote my Python code so that it relies purely on recursion
19:48haspakerIt still takes only 15 seconds to spit out the correct answer
19:49emezeskehaspaker: Did you see what amalloy said earlier? I was wrong about it being stack-space-related
19:53haspakeremezeske: Hmm. That only makes the error seem even more strange to me
19:53haspakerNow the Python code and the Clojure code performs almost exactly the same task
19:54haspakerBut Python seems to soldier on just fine while Clojure gives up and dies
19:55haspaker*give up and die, of course
19:57eggsbyhmm, why is the classic double tail recursive so slow in clojure (as compared to something like scala)
19:57eggsbylike fib, for example
19:57emezeskehaspaker: How big does the branches list get with the goal of 12912?
19:57eggsbyIs it just because it has to do the type checks?
19:57haspakerExtremely big
19:57emezeskehaspaker: Java has a fixed max heap size that you can set with command-line args
19:58emezeskehaspaker: If it's bigger than the default max heap size, you'll hit OOM
19:59emezeskehaspaker: You can set the Java max heap size with something like -Xmx500M or -Xmx2G
19:59haspakeremezeske: That could very well be the solution
19:59haspakerThe size of the final list lies somewhere between 2^12912 and 3^12912
19:59emezeskeHeh, that's a big number :)
20:05haspakeremezeske: I realized now that I lied
20:05haspakerI meant to say 2^17 and 3^17 :>
20:07emezeskehaspaker: Yeah, I was thinking about how ridiculously unimaginably big 2^12912 was just now :)
20:13haspakeremezeske: Yeah. 3^12912 is more than six thousand digits long
20:14emezeskehaspaker: You might have to buy an extra stick of RAM for that
20:24tomojdjanatyn: see also http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
20:25djanatynthanks
20:26tomojalso http://search.maven.org/#search%7Cga%7C1%7Cclojure.math.combinatorics
20:28tomoj(which won't find stuff on clojars, but the core clojure libs are in maven central not clojars)
20:52scizo_noob here trying to add something to the front of a vector and can't seem to find a function for it.
20:52scizo_maybe better said to the front of any collection?
20:54amalloyscizo_: not every collection is optimized for adding to any particular spot. if you don't mind turning it into a seq, you can just use cons
20:55scizo_amalloy: so with sequences cons and conj always add to the front?
20:55amalloyyes
20:56scizo_amalloy: alright, thanks.
21:22scizo_This might not be directly clojure related, maybe. I'm currently going through the clojure-koans and I am trying to write a recursive factorial function. I currently have this. https://gist.github.com/3375107
21:23scizo_This doesn't work because the recursion has to be at the tail, which I understand, but I am unable to come up with an alternative.
21:27casionscizo_: a clue would be that you would need more than 1 loop binding
21:28adamvhHello all.
21:28scizo_casion: Yeah, I just started playing around with that idea. I think I am almost there.
21:29scizo_casion: It worked. Thanks.
21:29casionsure, not often I know an answer to anything asked in here, haha
21:29adamvhDoes anyone know of good places to look for how to use core.logic with user-defined types?
21:29Scriptorthe good ole' iterative recursive factorial
21:31aperiodic~anyone
21:31clojurebotJust a heads up, you're more likely to get some help if you ask the question you really want the answer to, instead of "does anyone ..."
21:31adamvhWell, then.
21:32adamvhWhere is there documentation on using user-defined types with core.logic?
21:32adamvhWhat kinds of data can a logic engine work with?
21:34Scriptoraperiodic: not really relevant, he's looking for places to find documentation, not asking if anyone knows about a topic
21:34aperiodicScriptor: I thought he might have been running into a specific issue in trying to get that to work
21:35scizo_I updated my factorial function (https://gist.github.com/3375107) and it works with the exception of a base case of zero. I want to ask if I can do an early return before the loop, but that doesn't seem to feel like the clojure way of doing it.
21:35muhoofactorials are the "hello world" of lisp
21:36casionscizo_: you dont need to test for a case of 1
21:36Scriptorscizo_: if (fact 0) => 1
21:36Scriptorer, ignore the 'if' in that
21:37scizo_Scriptor casion: yes I see that now. Thanks. :)
21:40dnolenadamvh: you can extend unification to your own data types if that's what you mean.
21:40dnolenadamvh: the wiki has a Datomic example - you don't need to understand anything about Datomic to get it.
21:40adamvhdnolen: I'm sorry, I'm not entirely sure what unification means
21:40adamvhI'm rather new to logic programming in general
21:41dnolenadamvh: it means you can use your own data types.
21:44dnolenadamvh: unification is the process by which two pieces of data are attempted to be made equal.
21:46dnolenadamvh: out of the box, core.logic works the the standard Clojure data structures - I would stick with them until you feel a little more comfortable with how core.logic works.
21:52barryTheIdiotI'm having trouble evaluating a list with a parameter as a function. For example, (def example (list '+ 'x 1). then what I would love to do is (let [x 5] (eval example)), but running into scope issues i think
21:52barryTheIdiotwhat's the easiest way to do that kind of thing?
21:54brehautbarryTheIdiot: back up a bbit; what are you trying to achieve? eval is not common in real clojure code
21:54adamvhdnolen: The eventual goal is a program that will automatically validate army lists for a tabletop wargame
21:54brehautbarryTheIdiot: also, i think you idea of vars, symbols and scoping is wackadoodle
21:54barryTheIdiotprobably :(
21:54adamvhdnolen: the idea being that you chose a collection of units, some of which can only be present in certain quantities, some of which are allowed to be present only if others are
21:55barryTheIdiotI have a list, that is literally (+ x 5). how can I evaluate it?
21:55amalloyclojurebot: your idea of vars, symbols, and scoping is wackadoodle
21:55clojurebotOk.
21:55ScriptorbarryTheIdiot: why do you want to evaluate it as a list?
21:55Scriptoryou can simply do (+ x 5)
21:56brehaut,(let [x 1] (apply + x 5))
21:56clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long>
21:56brehautcrap
21:56brehaut,(let [x 1] (apply + x [5]))
21:56clojurebot6
21:56adamvhdnolen: is that a good problem domain for core.logic?
21:57brehautbarryTheIdiot: (im assuming you want to know how to apply a function to a list?)
21:57barryTheIdiotyes, but I have it as a literal list bound to variable. I don't know how to "treat" it as a function
21:57Scriptorso you have '(+ x 5)
21:57barryTheIdiotyes
21:57brehautbarryTheIdiot: why do you have that list then?
21:58adamvh,(eval '(+ x 5))
21:58clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
21:58brehaut,'x
21:58clojurebotx
21:58frioi think brehaut's initial question is the main thing here: what are you actually trying to achieve?
21:58brehaut,(read-string "x")
21:58clojurebotx
21:58brehauti have no idea what im doing
21:59barryTheIdiotI want to be able to temporarily bind x to a number, let's say 19, and then using the previously bound list '(+ x 5), to do the function
21:59barryTheIdiotsorry if I'm not making sense, not had much sleep lately.
21:59friono, i get that
21:59friobut why
22:00friowhat is the overall purpose of that design :)
22:00brehautbarryTheIdiot: i think you want partial application
22:00Scriptorthere might be a better way to do what you want
22:00barryTheIdiotit's for a program to find the next number in a sequence of numbers
22:00Scriptorah
22:00ScriptorbarryTheIdiot: do you know how to make a function?
22:00muhoo,(read-string "eval")
22:00clojureboteval
22:00brehaut(let [f (partial + 1) x 5] (f x))
22:00brehaut,(let [f (partial + 1) x 5] (f x))
22:00clojurebot6
22:01brehautbarryTheIdiot: capture the expression as a function, and apply that function later on, rahter than trying to capture it as a list and then inject values
22:01barryTheIdiotalright, thanks, i'll try that
22:02brehautbtw, that particular case is 'inc ;)
22:02adamvh,(let [f (partial + 1)] (take 5 (iterate f 5)))
22:02clojurebot(5 6 7 8 9)
22:02adamvhbarryTheIdiot: that's more or less what you want, right?
22:03brehautbarryTheIdiot: if the functions arguments arent in the order you want, then #(…) is idiomatic to capture that sort of out of order partial application
22:03ScriptorbarryTheIdiot: #(...) is shorthand for an anonymous function, which is like a regular clojure function but you don't supply it a name
22:04Scriptorsorry if I'm stating the obvious, just making sure we're covering the bases
22:04dnolenadamvh: static analysis of all kinds, scheduling, planning, in memory dbs, test generation, configuration - Prolog style programming is well suited to many problem domains.
22:05adamvhdnolen: Guess I'm just gonna have to put in some work to understand what it's all about :p
22:06dnolenadamvh: that you will - it's a big subject. I hardly know anything myself ...
22:19XRR_StanislavHmm, if you use (eval '(defn foo [] "I worship his shadow")) or something like that, does that alter the global scope?
22:22brehautim pretty sure it alters the namespace it is run in (globally)
22:37semperoscompiling a simple "hello world" for ClojureScript targeting Node.js; using lein-cljsbuild 0.2.5 which uses ClojureScript 0.0-1450
22:38semperosall goes well until I try to add a second ClojureScript file and namespace to my build, at which point I get the following error: https://gist.github.com/3375417
22:38semperosthe second namespace is just contains the ns form, nothing else
22:38semperoscompilation success, but running "node main.js" results in the error seen in that gist
22:38semperosanybody experience anything similar or have thoughts?
22:39amalloysemperos: ask Raynes and dnolen. known bug
22:40semperosamalloy: great, thanks
22:40semperosdid a quick google for keywords in the error but didn't see anything obvious surface
22:41muhoohas anyone got nrepl + piggieback + cljsbuild running with the browser (not rhino)?
22:43tomojsemperos: is the second namespace name single-segment and the same as a local somewhere else?
22:43tomojactually I guess it doesn't matter if it's single-segment, just if the first segment matches a local
22:44semperosa local where?
22:44tomojwell, since it's not in the second namespace, the other one, I guess
22:45semperostomoj: the two namespaces are platform.core and platform.util, the util being the second one that creates the error at runtime
22:45semperosplatform.core has only a `start` fn and the (set! *main-cli-fn* start) form
22:45Raynessemperos: Yeah, it's completely nuts.
22:45semperos:)
22:45semperosthat's ok, I just wanted to make sure I wasn't completely nuts
22:46tomojthat doesn't sound like the problem I was thinking of
22:46xeqimuhoo: I got them to where I could use the browser repl
22:46RaynesIt's baffling that the target was written, but apparently not tested at all.
22:46Raynes:p
22:49tomojthe node target?
22:53muhooxeqi: what did you supply as :eval argument to cemerick.piggieback/cljs-repl ?
22:53xeqimuhoo: https://www.refheap.com/paste/4239
22:55xeqithough doing that now it seems to be ignoring the first input I give it after starting the cljs-repl
22:56muhooxeqi: you are a god
22:56muhoothank you so much!
22:59xeqiits functional, but still in its infancy
22:59xeqican't wait for nrepl.el to work well with it
23:00muhooxeqi: that's what i'm using
23:08muhooand it works. amazing.
23:10xeqihmm, I didn't realize C-c C-k worked if I forced clojure-nrepl-mode for a cljs file
23:10xeqineat
23:11xeqithough losing M-. is annoying
23:16muhooi lost that years ago as my window manager binds it :-)
23:16muhooor do you mean dabbrev?
23:17xeqinrepl-jump
23:20muhoohmm, a bigger problem than that for me now is that if cljs gets hung up, any reconections to the process via nrepl.el or lein repl :connect lock up too
23:21xeqirefresh the browser ?
23:22muhootried. it's in the main jvm process itself, it seems to me. i get "user>", but anything after that hangs
23:23muhoowait, no, not hangs, throws an exception (in a terminal i didn't see)
23:25muhoohttps://www.refheap.com/paste/4438
23:26muhooanwyay, this is very cool stuff, but, sadly, i can't propose delivering a customer project with this stuff yet. so back to java hell i go for the next 3 months. *sigh*
23:38grettkeHi folks. What is the definitive source on what version of SLIME should be used for Clojure in Emacs?
23:40semperosgrettke: unless things have changed recently, the Emacs clojure-mode should handle pulling down what you need, including SLIME
23:42semperosit requires that you have lein-swank installed as well, but if you look through the clojure-mode and swank-clojure docs on their respective Github repo's, it says *not* to have other versions of SLIME loaded yourself
23:42grettkesemperos: Thanks. Who is the official maintainer of clojure-mode, I see more than a couple branches out there. Yea I noticed that it pukes on my existing SLIME... great lol.
23:43semperosgrettke: technomancy_ is the maintainer
23:43semperoshis Github user is the same, minus the final underscore
23:43semperosgrettke: I've ended up "delaying" my various Lisp configs in Emacs, so I can use different versions of everything as needed
23:43semperosincluding slime, etc.
23:44grettkesemperos: I see. Did you cut over to v24 yet? Do folks grab clojure-mode using ELPA these days?
23:44semperosI do use v24, have for a while, no issues
23:45semperosI personally pull in clojure-mode from its Github repo in my .emacs.d, but it gets updated via ELPA/Marmalade frequently enough
23:46xeqiI used it from elpa
23:47grettkeRight now I've got everything in my .emacs.d in vcs but wondering if that manual management can go away since ELPA is here?