#clojure logs

2013-03-19

00:00yogthos(pdf [{}
00:00yogthos [:table [[:cell {:align :right} "foo foo foo"]]]
00:00yogthos "bar"]
00:00yogthos "output.pdf")
00:00yogthosFrozenlock: so this should actually work
00:01yogthosFrozenlock: started digging and seems like I got it implemented already :)
00:02FrozenlockIt does!
00:02FrozenlockThank you very much indeed!
00:02yogthosFrozenlock: no prob, I'll update the docs :)
00:02yogthoskinda sad even I forgot it's there
00:08FrozenlockI wonder if dynamic variables could be useful in this case. (binding [*align* :right] ....)
00:20yogthosFrozenlock: you could yeah
00:20yogthosFrozenlock: another option is to use the templates
00:21yogthosFrozenlock: I could add a text-align to the table, so you don't have to do it per cell as well
00:25yogthosFrozenlock: you can do stuff like this as well
00:25yogthos(def items [{:item "foo"} {:item "bar"} {:item "baz"}])
00:25yogthos(pdf [{} [:table ((template [:cell {:align :right} $item]) items)]] "output.pdf")
01:01tieTYT2does clojure come with a library for using an http client to login to pages and browse pages, etc? or should I use java's http-client?
01:03HendekagontieTYT2 - check out Aleph
01:04tieTYT2cool thanks
01:04yogthostieTYT2: https://github.com/dakrone/clj-http
01:05yogthostieTYT2: this is an excellent resource site btw http://clojure-doc.org/
01:06yogthostieTYT2: for example they have a nice up to date common libraries list http://clojure-doc.org/articles/content.html#clojure_library_directory
01:06yogthoserr this link http://clojure-doc.org/articles/ecosystem/libraries_directory.html
01:07aibais it a bug in clojurescript that (= (hash [1 2 3]) (hash [1 2 [3]])) ?
01:07HendekagontieTYT2 - https://github.com/ztellman/aleph#http-client
01:07amalloyaiba: it is never a bug for two different objects to hash to the same thing
01:08amalloymight have a negative impact on performance, but will never break correctness
01:08aibaoh right, thanks, i was being stupid
01:08tieTYT2i'm looking for an example that submits forms
01:08tieTYT2it looks like clj-http has an example
01:08tieTYT2so i'll probably use that one
01:09tieTYT2yogthos: i'm reading stuff on that site right now :)
01:10tieTYT2that's a useful list of things
01:11mrowefwiw, I have found http.async.client much nicer to work with than clj-http
01:11tieTYT2this list is pretty impressive considering you can just fall back on the java ecosystem if you want
01:14yogthostieTYT2: yeah I find there's lots of nice libraries out there now
01:34tieTYT2yogthos|away: do you make light table?
01:54tomojhmm, maybe use @ in bindings to indicate that the value is expected to be lazy, and to set up a promise for recursive definitions?
01:55tomojwhile @ in the binding exprs indicates what you would normally expect, deref and the remaining bindings happen after deref
01:56tomoj(let [@s (cons x (lazy-seq s))] s)
01:58amalloytomoj: and what would that macroexpand to?
01:58tomojhttps://www.refheap.com/paste/c2cf06c771acb2f82077be63e
01:58tomojthat was my attempt, I dunno how it generalizes
02:04tomojhttps://www.refheap.com/paste/74e6c066da01f59bab09be05f
02:04tomoj:/
02:12tomojer, [:input {:type :text :value (switch "" input)}]
02:22eggheadhmm
02:23NeedMoreDesuIt seems nrepl.el blocks my attempts to use Thread$UncaughtExceptionHandler. Any suggestions about how can I make stacktraces on thread exception? (print-stacktrace thread) is fine too.
02:23eggheadplaying with pedestal, hello world app has 1.5mb deps?
02:30tieTYT2NeedMoreDesu: so weird, I just read an article about this today
02:30tieTYT2jayfields wrote it
02:31tieTYT2http://blog.jayfields.com/2011/01/clojure-using-java-inner-classes.html
02:31tieTYT2now I barely know clojure so I don't even know if this would help you
02:31tieTYT2keep that in mind, but I hope it helps
02:33NeedMoreDesutieTYT2: I've read those article. But http://www.everfall.com/paste/id.php?g8m0uog0kp1d works only in pure lein repl, dont works in nrepl.el session.
03:26NeedMoreDesuAhh, in the end i've just wrapped inner function in try-catch, as I was suggested in the very beginning.
04:06drorbemet
05:19tomojCPU% 2970; r/fold :D
05:19clgvtomoj: 32 cores?
05:20tomojyeah
05:22clgvtomoj: which problem domain? big data?
05:24tomojI'm just poking at google's ngrams
05:40ejacksontomoj: that's cool !
05:42talios'lo kittylyst
05:42taliosDidnt know you were a clojurian :)
05:43kittylystHi talios. Yes, when I get to do any coding these days. There are a couple of chapters on it in my book :)
05:43taliosNice
05:43taliosI think I saw a post from you the other day on the clojure list about it not working on JDK8?
05:47linqhello guys. I instal leiningen, sublime text2 with sublimeRepl. In sublimeRepl settings i edit "path to lein". So, repl works, but when i write "(use 'pl.danieljanus.tagsoup)", i had java.io.FileNotFoundException: Could not locate pl/danieljanus/tagsoup__init.class or pl/danieljanus/tagsoup.clj on classpath: (NO_SOURCE_FILE:0)
06:08noidilinq, and you've added tagsoup as a dependency in project.clj?
06:19florianoverwhats the most idiomatic way to get an entry from a collection of maps where a value of a key has a value of ["name1", "name2", "name3"] ?
06:20hyPiRionflorianover: Do you mean like ##(get-in {:name1 {:name2 {:name3 1034}}} [:name1 :name2 :name3]) ?
06:20lazybot⇒ 1034
06:21hyPiRionOh, where you have a value, and want a key.
06:21hyPiRionI need to learn how to read.
06:21florianoverno. you have the collection [{:name "Bla"}{:name "Foo"}{:name "boo"}]
06:22hyPiRionOkay, and you want ["Bla", "Foo", "boo"]?
06:22florianoverand you have a collection of names you are interested in ["Bar" "boo"]
06:22florianoverand i want the map where :name "boo"
06:23hyPiRion,(filter #(-> % :name #{"Bar" "boo"}) [{:name "Bla"}{:name "Foo"}{:name "boo"}]
06:23clojurebot#<RuntimeException java.lang.RuntimeException: EOF while reading>
06:23hyPiRion,(filter #(-> % :name #{"Bar" "boo"}) [{:name "Bla"}{:name "Foo"}{:name "boo"}])
06:23clojurebot({:name "boo"})
06:24florianoverwill try
06:24florianoverthanks
06:29drorbemet
06:38drorbemetHi, what is a better practice in Clojure? :
06:38drorbemet(def function-name (fn [arguments] (function body ...))) or
06:38drorbemet(defn function-name [arguments] (function body ...))
06:44hyPiRiondrorbemet: usually defn
06:46drorbemethyPiRion: so there arn't any complications down the road when a project gets bigger ... fine, thanks
06:55thm_proveris there anyway to get OpenGL to work with clojure on macosx 10.8, given that lwjgl requires jawt, which is not availble in java 7? (and apple only has java 7 for 10.8)
07:38NeedMoreDesuIs there something like (exception? arg) ?
07:39hyPiRionNeedMoreDesu: (instance? Exception arg)
07:40NeedMoreDesuhyPiRion: thanks.
07:41hyPiRion,(instance? Exception (RuntimeException.))
07:41clojurebottrue
08:14abpHi, any pointers on what's the best way to implement scheduled mailing in a Clojure web app?
08:22vagmiabp: You might want to look at http://clojurequartz.info/
08:31ejacksonabp: I manually schedule actions using cron calling the web service
08:31ejacksonits old skool, but solid.
08:46josteinkyou -really- appreciate "lein deps" after trying to port code from VS project based on "Nu get" to another
08:46josteinkjesus f christ
08:46josteinkinsane pos
08:51winkreally?
08:51winkI only heard about it once, and it was positive
08:52josteinkmadness
08:52josteinkproject 1 has lots of codes with lots of third party dependencies. all dependencies are in a file called packages.config
08:53josteinkin project 2, I want to copy that code and you'd think I'd just need to shove the packages.config, retrigger a fetch and be done
08:53josteinknoooo
08:53josteinkyou have to parse the packages.config XML into a powershell script which is run line by line, adding each dependency to the project, one by one
08:53josteinkand THEN you think you are done
08:54josteinkbut no, because the packages are just DLed in a repo outside the project, where you have to one and one go and add the f---ing DLLs to your new project
08:54josteinkit would be easier to never use the tool in the first place
08:54jstewAnyone who's gone to clojure from an object oriented language... How long did it take you to "get it"? I've been doing koans and problems on and off for a month or so, and I just feel like I can't grasp it. (IOW, clojure makes me feel dumb).
08:56ejacksonjstew: clojure makes everybody feel dumb at first. So its just like git, only with git it never stops. Keep cracking at it!
08:57john2xah shucks did I miss the discussion about pedestal?
08:58jstewHaha... Yes, git still surprises me from time to time.
08:59Pupnik-you never really know a language tillyou have a decent project (or several) under your belt
09:00jstewPupnik-: This is true. The basics of fp, to me, seem harder to grasp than learning an imperitive language like C
09:00Pupnik-maybe you dont remember how difficult it was to learn C to start with
09:00ejacksonjstew: the thing that helped me to understand is that in OOP when you call a method the object changes. In FP when you call a function you just get back another copy of the object with the change made.
09:01jstewI suppose I'll just keep at it and grind my way through the tough parts. And I agree, it was a long, long time ago I learned C, so my memory may be deleting a bunch.
09:06Pupnik-if you have been doing problems etc for a while
09:06Pupnik-do a small project
09:07Pupnik-maybe one that lends itself to functional style
09:26gmailerHi guys, i'm working on a compojure app, and i'm finding myself passing the req map around a lot, i've been looking into dynamic bindings, and how lib-noir does things...
09:26gmailerIs that sort of approach a good/bad idea? I'm unsure what the general approches are when it comes to information hiding vs code "verbosity"
09:34edwgmailer: Does your code keep and pass the request along only so that code several levels deeper may or may not use it? In that case—and this is a judgement call—I think using a binding probably makes sense. I would consider using the thread local value as an argument to a function and not in the function body itself, so you can still test it.
09:35edw"It" being the function the operates on the thread-local value, that is.
09:40gmaileri'm not quite sure i follow that last bit
09:42gmailerto borrow a lib-noir example: (set-cookie! :name "value") is roughly equivalent to (ring.util.response/set-cookie req :name "value")
10:12jcromartieseriously, XML namespaces...
10:15nDuffjcromartie: What about them?
10:18jcromartienDuff: can't live with them, can't live without them
10:18jcromartieespecially when dealing with outside XML
10:30nDuffjcromartie: I'm much more on the "can't live without them" side of the fence.
10:30jcromartieyes they're immensely useful
10:30jcromartiebut clojure.xml throws them out
10:30nDuffYes. That's my principal source of unhappiness with it, as it happens.
10:39jcromartiewow
10:39jcromartie(fn? a-multifn) ;;=> false
10:39jtoy_waht exactly does the with-precision argument do? I cant get this number to change: (with-precision 5 112312313123 ) (with-precision 555 112312313123 )
10:40jcromartieifn? is what I am looking for, then
10:41clgvjtoy_: afaik it was used for floating point numbers with arbitrary precision
10:41nDuff,(with-precision 5 (/ 112312313123M 1))
10:41clojurebot1.1231E+11M
10:42nDuffjtoy_: ^^
10:42nDuffjtoy_: Precision isn't involved when _reading_ BigDecimals, just calculating on them.
10:42clgvah it was the "M" suffix. I just searched for that example^^
10:43clgv,(/ 112312313123M 1)
10:43clojurebot112312313123M
10:43gmailerjcromartie: are there some good high-level alternatives to clojure.xml? I'm about to do some XML parsing and unsure if there's a generally accepted lib to use
10:45jtoy_so is there a way I can use with-precision to floor decimals to integers? this doesnt work: (with-precision 1 :rounding FLOOR (Math/sqrt 5) )
10:46hyPiRionMath/floor isn't sufficient?
10:47nDuffjtoy_: It's the wrong tool for the job, but if you _really_ wanted to...
10:47nDuff,(with-precision 1 :rounding FLOOR (/ (BigDecimal. (Math/sqrt 5)) 1))
10:47clojurebot2M
10:47jcromartiegmailer: I have not found one
10:47jcromartieI just wrote my own around the Java DOM API
10:48jcromartiewhich is fine
10:48jcromartieand namespace aware
10:48jtoy_nDuff: what is the appropriate tool? i saw contrib.math but that seesm to be gone
10:48nDuffjtoy_: Math/floor
10:48jcromartieit's kind of a crazy API with many classes and factory factories, etc.
10:48jtoy_ic
10:48jtoy_thx
10:48nDuffjtoy_: ...see http://docs.oracle.com/javase/6/docs/api/java/lang/Math.html
10:51nDuffjtoy_: By the way, I'd feel more strongly if this were something where I'd put in significant effort, but you might take the views in http://yaku.dk/s/irc/dont-use-thx-sry-plz.txt into consideration.
11:00gmailerjcromartie: makes sense, did you look at clj-xpath at all?
11:01gmailernDuff: as in, making them easier to type lessens the sentiment?
11:01jcromartiegmailer: yes, and it provided some helpful ideas, but I didn't like the design of it
11:02jcromartieI kind of took xml-> and the xpath stuff, and made xpath->
11:02gmailerany plans to spin your stuff off as a standalone lib? Something with a clojure-friendly interface would be nice
11:03nDuffgmailer: Not caring enough to even type the word in full indicates that there's very little sentiment behind it.
11:03gmailernDuff: that's very similar to drilling "please and thank you" into children, is it not?
11:03nDuff...and being that _transparently_ insincere strikes me as considerably more offensive than not providing any thanks at all.
11:03jcromartieand I also bundle up an xpath context when the document is parsed
11:05nDuffgmailer: I don't have a problem with drilling "please and thank you" into children, so long as it's taught with the effort of teaching them gratitude rather than platitudes (a distinction best made by example -- demonstrating by way of how one treats others).
11:06gmailerprobably, i'd liken "plz" to http://en.wikipedia.org/wiki/Assimilation_%28linguistics%29, making "speech" simpler but the "listener" can still understand - improving conversation flow
11:42yogthostieTYT: nope, that's Chris Granger's baby http://www.chris-granger.com/
11:48jcromartievery strange things happen when you forget the (cond …) part of a cond clause
11:49clgv,(cond)
11:49clojurebotnil
12:14TimMcnDuff: Alternative explanation: http://hyperboleandahalf.blogspot.com/2010/04/alot-is-better-than-you-at-everything.html
12:22drorbemet
12:27ciphergothAnyone know where I can find a good example of code that uses "ex-data"?
12:27technomancyciphergoth: syme uses it
12:27technomancyfor HTTP response codes
12:28ciphergothhmm so you just catch Exception e
12:29ciphergothIf I just want to catch the ex-info exception, that's ExceptionInfo right?
12:29technomancyor clojure.lang.ExceptionInfo if you want to be more picky
12:29technomancyyeah
12:30TimMcI think slingshot uses ExceptionInfo now.
12:30ciphergothright, I have to give the full name
12:30ciphergoththanks
12:30ciphergothSlingshot seems like overkill
12:32gmailerslignshot is basically just a wrapper around ex-info/ex-data
12:32technomancyit's pretty nice, but having ex-info alone is a huge improvement over Exception
12:32gmailerthere's no built-in way to catch based on ex-data
12:33technomancyyeah, if you want to dispatch based on more than just the class you need slingshot
12:34gmaileri forget the exact syntax, but for example clj-http lets you do (try+ (...) (catch [:status 403] (handle-it)))
12:34dakronegmailer: that's the right syntax
12:35gmailerhuzzah!
12:46Frozenlock(let [x [*dyn-var*]] (binding [*dyn-var* 12] x)) ---> x != 12 :(
12:46technomancyhow many folks use the clojuredocs client from lein repl
12:46technomancy?
12:46Frozenlocktechnomancy: Well I will now...
12:46TimMcFrozenlock: Makes sense to me.
12:47TimMcClojure automatically dereferences vars when retrieved by symbol.
12:47FrozenlockIf I understand correctly, it must be a function evaluated inside the binding to change the result?
12:48TimMc,(let [x #'*compile-path*] (binding [*compile-path* "foo"] @x))
12:48clojurebot"foo"
12:49TimMcFrozenlock: ^
12:50FrozenlockOh boy... I think I'll just deal with some additional arguments for now..
12:52TimMcFrozenlock: Yeah, your only choice is passing around the var itself.
12:52TimMc(or anything equivalent to that)
13:01augustlis it possible to at run-time create calls to java interop that are as efficient as the compile time generated interop?
13:01augustlor is run-time interop always reflection?
13:02TimMcaugustl: Reflection either happens at compile time or runtime, but it happens either way.
13:02TimMcI guess what you're asking for is reflect-once calls.
13:02augustlI want to get something like [:myCall 1 2 3] passed and have that end up as (MyJavaThing/myCall 1 2 3) in an as efficient way as possible
13:02augustlefficient is important since they're OpenGL commands :)
13:03augustlso I want to be able to take [:myCall 1 2 3] run-time
13:04augustlperhaps I should do my own JNI to OpenGL..
13:07augustlTimMc: what are reflect-once calls? :)
13:07TimMcA term I just made up.
13:07augustl:D
13:07TimMcAs in, the reflection is either done by the Clojure compiler, your own code (while building the fn), or in some memoized fashion.
13:09augustlhow do you actually call something without reflection?
13:09augustlor is reflection = getting a hold of something you can call?
13:10Chousukeaugustl: if you know the type of the thing you're calling it's possible to emit bytecode to do it directly.
13:10TimMcReflection *always* happens at some point. The compiler reflects in order to emit bytecode for a straight call, the usual runtime reflection gets ahold of a java.lang.reflect.Method object and calls that.
13:10Chousukebut in clojure's case the type often isn't known until runtime.
13:10clgvaugustl: well, with reflection you usually retrieve the class of a given object and search for a method with a given name and a given signature. then you have a method object you can invoke
13:11augustlclgv: I see
13:14gmaileraugustl: is there a reason you can't generate the whole interface pre-compile?
13:17augustlgmailer: hmm, I don't know enough about interop to understand that question I think :)
13:18gmailerpresumably you know all of the openGL commands which exist, or you have a way to get it?
13:18augustlessentially I have an API that allows specification of OpenGL commands to execute at run-time. Currently, to do that you need to require OpenGL stuff and pass a function that contains the commands. I'm playing with an API where you pass something like [[:aOpenGlCommand arg1 arg2] [:anotherCommand arg1]] etc
13:18gmailerif you have some way of enumerating the commands beforehand, you could generate the code to map/call them
13:19augustlit's OK to spend some time with the list of commands when I first get them
13:19augustlit's for calling them 120 times a second later on that needs to be optimized :)
13:20gmaileri mean generate a file containing clojure code, which then gets built into the jar
13:20augustlthe exact commands are based on user input etc
13:20gmailerah
13:20gmailerso there isn't a finite list of possible commands?
13:21augustlno, the actual functions are http://lwjgl.org/javadoc/org/lwjgl/opengl/GL11.html but the parameters may vary
13:22clgvTimMc: ping
13:23clgvTimMc: I use lein-otf 2.0.1 and have ":main ^:skip-aot my.main" in the project.clj but "my.main" gets compiled. what is wrong there?
13:25technomancyclgv: sad face
13:25technomancythat's my fault
13:25technomancyI removed support for implicit AOT of :main before the release of lein2
13:25technomancybut it got added back in without my knowledge
13:26clgvtechnomancy: oh right. just noticed. it fails for "lein install" but works for "lein uberjar"
13:26technomancyand the patch to add it back in didn't honor ^:skip-aot ಥ_ಥ
13:26technomancyclgv: 2.1.0 fixes that
13:26technomancywell, it fixes ^:skip-aot; it can't fix the fact that :main implies :aot unfortunately
13:27clgvtechnomancy: ah good to know. but there seems to be some asymmetrie whe "install" fails but "uberjar" works
13:28TimMcclgv: It's because lein-otf only hooks uberjar.
13:29clgvTimMc: ok. that explains it
13:38ieureWhy oh why doesn't macroexpand work in clojure tests?
13:39technomancyieure: you mean inside an clojure.test/is invocation specifically?
13:40ieuretechnomancy, Inside deftest, specifically.
13:41TimMc$karma TimMc
13:41lazybotTimMc has karma 34.
13:41TimMctechnomancy: All my karma is over here.
13:45technomancyconfirmed that deftest is weeeeird
13:45technomancyTimMc: aha; channel-local binding
13:45tyleris there any clojure syntax thats *not* edn syntax?
13:46gmaileris clojuredocs.org the "correct" place for public api docs?
13:46TimMctyler: #"foo"
13:46gmailerit seems to be missing 1.4 and 1.5
13:47joegallogmailer: http://clojure.github.com/clojure/
13:47technomancygmailer: the docstrings are the only canonical source
13:47TimMctyler: A whole bunch of reader sugar is probably not in EDN.
13:47joegalloi have that bookmarked as "Clojure API"
13:47technomancyI guess there are some special forms with missing docstrings that delegate to clojure.org reference =\
13:48gmailerclojure.org/cheatsheet links to clojuredocs.org >.<
13:48tylerTimMc: thnx
13:48joegallotechnomancy: right, so i have http://clojure.org/special_forms bookmarked as "Clojure Special Forms"
13:48joegallo'cause i'm wicked thorough
13:48technomancysucks if you're offline though
13:49joegalloi'm not a caveman
13:49technomancyhaha
13:49pjstadigwho is ever offline?
13:49technomancyexpensing wifi whenever you fly?
13:49joegallowifi?
13:49gmailertrains = big metal tubes = no signal
13:49joegalloon a plane?
13:49joegallowhat are you, some kind of terrorist? that rf recieving equipment will crash things!
13:50technomancyhttp://www.penny-arcade.com/comic/2006/10/30/
13:50pjstadighaha
13:50pjstadigoh man i was just gonna post an xkcd
13:51hyPiRionjoegallo: we have wifi on the planes over here
13:56TimMcjoegallo: I think active receivers can generate interference.
13:56TimMcsuch as GPS
14:00Pure-Loulouhello room :) when i recur in a function,does the garbige collector de-allocates the memory i consume? i think that when i use 1 function to allocate lots of memory,its better to break it into smaller functions.is this right?
14:01nDuffPure-Loulou: recur is equivalent to an iterative algorithm.
14:01clgvoh, what does that mean? java.lang.NoSuchMethodError: clojure.lang.RT.mapUniqueKeys
14:02nDuffPure-Loulou: ...in terms of when memory is freed, locals are cleared after the last point when they're used
14:02nDuffPure-Loulou: ...so locals can be (typically, are) freed before the function actually exist. Breaking things into small functions is good practice even if you don't need to do it for memory-efficiency reasons, though.
14:02nDuffs/exist/exit/
14:03hyPiRion,(let [recursive (fn rec [x] (if (= x 10000) :done (rec (inc x))))] (recursive 0))
14:03clojurebot#<StackOverflowError java.lang.StackOverflowError>
14:03Pure-LoulounDuff, you mean the locals are freed when i reach recur?or after the fuction call returns?
14:03nDuffhyPiRion: I gathered Pure-Loulou to mean using recur, as opposed to recursing directly
14:04hyPiRion,(let [iterative (fn [x] (loop [y x] (if (= y 10000) :done (recur (inc y))))] (iterative 0))
14:04clojurebot#<RuntimeException java.lang.RuntimeException: Unmatched delimiter: ]>
14:04nDuffPure-Loulou: Again -- if you use recur, you don't _really_ recurse
14:04hyPiRionfreash
14:04jtoy_can anyone tell me why I cant declare this function with defonce: https://www.refheap.com/paste/12720
14:04hyPiRion,(let [iterative (fn [x] (loop [y x] (if (= y 10000) :done (recur (inc y)))))] (iterative 0))
14:04clojurebot:done
14:04hyPiRionThere, that should explain it.
14:05nDuffPure-Loulou: and locals are freed as soon as they're no longer needed. If I do (let [a 12] (println a) (do-something-else)), then the a is nil before we reach do-something-else
14:05Pure-LoulounDuff, thanks,i know that recur its iteration,but when i use a function tha allocates match memory during recurs,i somethimes get out of memory...
14:06Pure-Loulouif i break the task into smaller functions its better for memory usage and i dont know the reason
14:06nDuffPure-Loulou: Can't help you without seeing a reproducer.
14:07jtoy_nm, i see
14:08clgvI get this exception when running my project. I just got that exception when switching to Clojure 1.5.1 -> java.lang.NoSuchMethodError: clojure.lang.RT.mapUniqueKeys([Ljava/lang/Object;)Lclojure/lang/IPersistentMap;
14:11TimMcclgv: Needs more context.
14:12clgvTimMc: I build a uberjar with :skip-aot on the main using lein-otf.
14:12callenbotQuora should make their site suck less.
14:12Pure-LoulounDuff, my example https://www.refheap.com/paste/12721 do youn know the reason for different memory usage and speed?
14:13clgvTimMc: that uberjar is run then. somehow it seems as if there might be two different clojure versions involved. one with and one without clojure.lang.RT.mapUniqueKeys
14:14TimMcclgv: Have you tried running lein clean? Sometimes classes stick around and cause trouble.
14:14hyPiRionand the classpath
14:14clgvTimMc: yes. I built with lein do clean, uberjar
14:14hyPiRion.lein-classpath or something
14:15nDuffPure-Loulou: The broken-down one doesn't loop back as far on the inner recurs.
14:15nDuffPure-Loulou: ...so they're not very equivalent logic.
14:16Pure-Loulouthe reason is the logic or the garbage collector?
14:16nDuffPure-Loulou: There are big enough obvious differences in the logic that I can't compare gc behavior.
14:16Pure-Loulouok nDuff thanx :)
14:16clgvTimMc: oh maybe I forgot to update one clojure dependency
14:17Pure-Louloumaybe its just the logic not the gc
14:22clgvTimMc: works now :)
14:31muhooslamhound is fantastic
14:41astevekeywords can point to functions?
14:42arrdem,(( :foo {:foo identity} ) 1)
14:42clojurebot1
14:42arrdemyes
14:43Pure-LoulounDuff, if you are here...,this is the question i have... https://www.refheap.com/paste/12724
14:44nDuffPure-Loulou: using recur will be much, much more efficient.
14:44Pure-Louloua ok:) thx
14:45Pure-Loulouand memory efficient?
14:47jtoy_what is the appropriate way to add lists together? not (+ '(1 2 3) '(4 5 6))
14:48asteveI've evaluating some code that has ((keyword variable_name) function_name); which is confusing to me
14:48asteve(:variable_name function-name) is how I'm reading it
14:49asteve:variable_name in this case could point to a function? so I'd be passing a function into the input of another function, no?
14:50jtoy_and its not conj
14:50amalloyjtoy_: what is the output you want?
14:50Ember-asteve: keywords are functions
14:50Pure-Louloujtoy_, (map + '(1 2 3) '(4 5 6))
14:50Pure-Loulouor (apply + (map + '(1 2 3) '(4 5 6)))
14:51amalloyit sounds like you probably want (concat '(1 2 3) '(4 5 6))
14:51Ember-so (:foo bar) retrives :foo from map bar
14:51asteveah!
14:51Ember-and the content of (:foo bar) can very well be a function
14:51jtoy_Pure-Loulou: sorry, i meant (1,2,3,4,5,6)
14:51asteveEmber-: that second piece is what I was hoping was happening but could not rationalize
14:51jtoy_conjoin them together
14:51nDuffjtoy_: then concat
14:51jtoy_thx
14:52asteveEmber-: thank you for the assistance
14:53Ember-asteve: np
15:02jtoy_is there a conj for adding to the end of a vector?
15:02jtoy_oh, conj does do that for a vector, but adds to the beginning for a list
15:05nDuffjtoy_: conj does the most efficient thing for each datastructure.
15:05nDuffjtoy_: if you're trying to frequently add to the end of the list or the beginning of a vector, you should probably be using a different datastructure.
15:09TimMcThe correct answer is always finger trees. :-P
15:11asteveI'd like to get a better understand of apply and when you'd use it; if I have a vector of input to a function and my function explicitly lists incoming args I'd use apply? for example, (defn foo [bar taco] (* bar taco)) and then (defn -main [vectoptions] (apply foo [vectoptions])?
15:11amalloyasteve: minus the []s, yes
15:12asteveamalloy: where do I not need the []s?
15:12amalloyin apply
15:12asteveare they not required?
15:13amalloy(apply f [x]) is identical to (f x), for any x
15:13asteveor are they logically incorrect
15:13amalloythey are incorrect
15:13amalloyyour example would evaluate like (foo [bar taco]), whereas you want (foo bar taco)
15:14asteveis there a case for wanting (foo [bar taco])?
15:14gf3That's up to you
15:15astevewhat would foo look like to want [bar taco] as an input?
15:16gf3asteve: Your initial code
15:17TimMcI think that's a misleading statement.
15:17TimMc[bar taco] as the list of args, yes -- not the single argument [bar taco], a vector of two items.
15:18TimMcasteve: Take a look at +.
15:18TimMc&(apply + [1 2 3])
15:18lazybot⇒ 6
15:18TimMc&(+ 1 2 3)
15:18lazybot⇒ 6
15:19asteve&(+ [1 2 3])
15:19lazybotjava.lang.ClassCastException: Cannot cast clojure.lang.PersistentVector to java.lang.Number
15:19astevegot it
15:19TimMcAnd you can specify some initial args before the final one that is unwrapped.
15:19TimMc&(apply + 1 2 3 [4 5 6])
15:19lazybot⇒ 21
15:19TimMc&(+ 1 2 3 4 5 6)
15:19lazybot⇒ 21
15:28abpDigging into pedestal is hard, but totally worth the effort I think.
15:29callenbotabp: braver man than I
15:29callenbotfunny that we ditched Noir for being too overwrought, yet Pedestal is okay.
15:29technomancyit's not a framework, honest!
15:29abpcallenbot: this ^
15:29callenbotdo people actually believe that?
15:30abpWell, parts of it, especially the rendering stuff needs a bridge for other libs.
15:30abpBut very much of this is only to reduce web apps into a functional pipeline via queues.
15:31callenbotabp: put down the flavor-aid.
15:31abpThey nailed it, there are probably some things that could be eased out without sacrificing simplicity but the stuff is seriously spot on.
15:31abpIt's just observations.
15:31callenbotabp: spot on? Tell that to the frontender that has to learn clojurescript just to touch up some stuff.
15:32technomancyyeah, I'm mildly interested in interceptors, but I don't want to pull in a bunch of client-side transformation stuff just to use a more flexible request/response model.
15:32abpcallenbot: It's based on enlive html-templates.
15:32tieTYTyogthos: did you build lighttable
15:32callenbotabp: I am well known for hating enlive too.
15:32tieTYT?
15:33callenbottieTYT: LightTable is Chris Granger aka ibdknox
15:33tieTYTah
15:33abpcallenbot: Then use clabango.. I just wanted to say there are html-templates your designer can shape.
15:33tieTYTwhat is it written in?
15:33callenbotabp: I'm not talking only about the HTML
15:34callenbotabp: I was talking about ClojureScript, in the place of JavaScript.
15:34abpcallenbot: You can write javascript when you want to. It's just an option to write serious clientside code.
15:35abpcallenbot: There's even a multimethod based asset pipeline for compass etc built-in.
15:35technomancyo_O
15:35abpreverse routing an terse route definition. I don't know, I think it rocks.
15:36callenbotcompojure wasn't terse?
15:36xeqiabp: is that a positive or a negative?
15:36xeqithe asset pipeline builtin
15:36technomancyit actually kinda reminds me of pinot
15:37abpcallenbot: Nope, not compared to that straight to the point definition. I was working on similiar things. The ones I've shown you quite a while back.
15:37technomancy"here's a bunch of unrelated pieces of functionality that I happen to use together which I will split apart into five different libraries six months down the road"
15:37abpxeqi: Extendable through multimethods, so rather positive.
15:38callenbotabp: but seriously, less kool-aid.
15:38abpYeah, they could tear quite some things and bridges apart. But hey, it's alpha and kicks ass.
15:38abpcallenbot: Heh, more respect for the really hard work done by those folks.
15:39callenbotwe just got done reversing this kind of thing in multiple places
15:39abpcallenbot: ffs, it's just libs.
15:39abp:P
15:47thm_proverI have ":jvm-opts [ ... "-XstartOnMainThread" ]" ...
15:47jcromartieso I think I came up with pretty much the best Xpath interface ever
15:47thm_provernow, does Lein run on mainthread, or does my clojure code run in main thread?
15:47thm_proverI want my clojure code to run on main thread in order that I can use swt
15:47thm_proverhowever, it appears that Lein is taking main thread
15:53jcromartie(-> (doc "//atom:entry[1]/atom:link[@rel='alternate']") first attrs :href)
15:54jcromartie(let [entry (first (*d "//atom:entry"))] (-> (entry "atom:title") text))
15:54jcromartieI don't think this is abuse of IFn
15:55jcromartiebasically I parse an XML doc into a QueryNode record which is a (Java) DOM node and an XPath context (with namespace mappings)
15:55jcromartiethen the QueryNode implements IFn to do XPath queries
15:55jcromartieonly for node sequences right now, but possibly for other types later
15:55arrdemis there a better way to run code in another namespace than (`(do (in-ns 'other) ~@sexprs)) ?
15:56jcromartieand each item in the returned node seqs is a QueryNode too
15:57Glenjaminshould clojure be throwing a warning if i def something that matches a special form?
15:57Glenjamini did (defn set! …) and it took me a while to realise why it didn't work
15:57Glenjamin(when called, not when defined)
16:00tomojGlenjamin: no
16:01Glenjaminis that because it's available fully namespaced?
16:01tomojthat's why I want clojure not to throw an error there
16:01tomoj:)
16:02Glenjaminit warns when i define something thats also available in clojure.core
16:02Glenjamin(def get) ; => warning (def set!) ; => nothing
16:02tomojso (foo/if x y z) works
16:03tomojyeah.. just how special forms are
16:03tomoj&set!
16:03lazybotjava.lang.SecurityException: You tripped the alarm! set! is bad!
16:03Glenjaminhrm, can i make the current namespace available under a short name?
16:03SegFaultAXGlenjamin: Add a refer-clojure exclude in your namespace decl so it's obvious you're shadowing that var.
16:03tomojwell, lazybot is stupid, there is no set!
16:03TimMc,set!
16:03clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: set! in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:04tomoj(alias 'f 'foo)
16:04Glenjaminbasically i've got an app.config namespace, with a (get) and a (set!)
16:04SegFaultAXGlenjamin: Then explicitly exclude get from your namespace.
16:06tomojyou can do (alias 'c 'app.config) under (ns app.config ...) and then (c/set! ...) will work later in app.config. maybe just rename it though? :)
16:07jcromartiecan I use varargs when implementing protocols?
16:07jcromartielike, inside a defrecord spec
16:10amalloyno
16:10jcromartieamalloy: thanks :)
16:14jcromartieI appreciate that I can combine :as and :refer in the same :require
16:14jcromartie(:require foo.bar.bat :as bat :refer (zort troz))
16:22arrdemcan I force macros to resolve symbols using ns-specific qualified names rather than absolute names?
16:23arrdemeg. (require ['clojure.pprint :as pp]), `(pp/pprint foo) -> (pp/pprint foo) not (clojure.pprint/pprint foo)
16:27Raynesarrdem: When you require something :as anything, the fully qualified names are still available.
16:28Raynesarrdem: So if you do that require, you can still refer to pprint as clojure.pprint/pprint and it'll work fine.
16:28arrdemRaynes: ofc. I'm just looking for a way to use the abbreviated name in macroexpansions short of ~' ing all my symbols
16:28arrdems/use/get out/
16:28RaynesWhy do you want to do that though?
16:29arrdemI'm working on a toolkit that generates potentially huge ammounts of code which is intended for long-term storage not emmidiate evaling
16:30arrdemthe project is http://github.com/arrdem/sad
16:30arrdemthe idea is that rather than implement an entire grammar by hand in fnparse you just feed it in and sad spits out the equivalent fnparse code.
16:31arrdemso I would like the generated code to be readable (using abbreviated names) not obfuscated by fully qualified ones.
16:32drorbemetWhich is the fast way to check if a clojure.set contains an element? Do I have to put the element in a set first and apply subset? ?
16:33arrdem,(contains #{3} 3)
16:33clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: contains in this context, compiling:(NO_SOURCE_PATH:0:0)>
16:33arrdem,(clojure.set/contains #{3} 3)
16:33clojurebot#<ClassNotFoundException java.lang.ClassNotFoundException: clojure.set>
16:33arrdemgoddamnit bot
16:33drorbemetAh ok thanks
16:33arrdemdrorbemet: fair warning I may have the literal and the collection backwards...
16:34arrdemah it's contains?
16:34arrdem,(contains? #{3} 3)
16:34clojurebottrue
16:34arrdemHAH
16:34arrdemdrorbemet: ^^
16:34nDuff,(#{3} 3)
16:34clojurebot3
16:34nDuff,(#{3} 2)
16:34clojurebotnil
16:34arrdemor that.
16:34nDuffdrorbemet: ^^
16:36drorbemetnDuff: I have some problems at the moment, I come back with a better prepared question
16:37Glenjaminis there a shorthand to add more than one boolean metadata flag?
16:38drorbemetnDuff: Thanks, I figured it out
16:38jjidolike a set?
16:38Glenjaminsomething like ^[:dynamic :private]
16:38arrdemGlenjamin: (def ^{:dynamic true :private true} foo 3) ?
16:39Glenjaminyeah, was hoping for something to drop the trues, but not exactly important
16:40arrdemGlenjamin: the semantics of Clojure maps demand that you have <key, val> pairs inline, unless you wanted to implement some funky macro there's no way around that.
16:40mthvedtGlenjamin:
16:40mthvedtuser=> (def ^:dynamic ^:private abc 1)
16:40mthvedt#user/abc
16:40mthvedtuser => (meta #'abc)
16:40mthvedt{:ns #<Namespace s3sync.core>, :name abc, :dynamic true, :column 1, :private true, :line 1, :file "NO_SOURCE_PATH"}
16:40Glenjaminheh
16:40arrdem(inc mthvedt)
16:40lazybot⇒ 1
16:40Glenjaminwhy didn't i try that >.<
16:41mthvedtwoo
16:41mthvedtno longer a 0
16:41arrdemTIL XP and that's worth karma
16:41arrdem$karma arrdem
16:41lazybotarrdem has karma 1.
16:49jcromartieXPath is a nice dynamic language that gets rather constrained by Java
16:49yediwhat's all this stuff about pedestal's interceptor model about
16:50yedianyone have a link or something?
16:51abpyedi: http://pedestal.io/documentation/service-interceptors/
16:51abpyedi: Probably want to read overview first.
16:55nDuff...but then, one can actually do real work in XQuery (database lookups, HTTP requests, etc etc) as opposed to being _strictly_ a query language.
16:58jtoy_how would you recommend I get a vector back that has the last element removed?
16:58arrdemjtoy_: ,(doc butlast)
16:58arrdem,(butlast [1 2 3 4])
16:58clojurebot(1 2 3)
16:58S11001001no
16:58jtoy_sweet
16:58arrdemS11001001: ??
16:58lazybotarrdem: Definitely not.
16:59arrdemlazybot: gtfo
16:59S11001001arrdem: sorry, lazybot agrees with me
16:59S11001001,(doc pop)
16:59clojurebot"([coll]); For a list or queue, returns a new list/queue without the first item, for a vector, returns a new vector without the last item. If the collection is empty, throws an exception. Note - not the same as next/butlast."
16:59FrozenlockThis is confusing...
16:59S11001001jtoy_, arrdem: butlast not only doesn't return a vec, as you see, it's also O(n). pop has neither limitation
17:00arrdemah.
17:00S11001001,(doc butlast)
17:00clojurebot"([coll]); Return a seq of all but the last item in coll, in linear time"
17:00jtoy_ah, yes
17:01S11001001additionally, iteratively calling butlast has the same stack problems as iteratively `concat'ing to the end of a seq
17:01FrozenlockIsn't there a function that automatically choose when to use butlast/pop?
17:01S11001001doubt it
17:01S11001001it has been observed by others that using cons and pop for stack management is faster than using vec as a stack
17:01S11001001worth considering
17:02FrozenlockWould (defn butlast* [coll] (if (vector? coll) (pop coll) (butlast coll))) be efficient?
17:03S11001001albeit pretty much useless
17:05FrozenlockHow so? Isn't the need to remember to use `pop' instead of `butlast' an unnecessary step?
17:05S11001001It's a statement of truth about the code it appears in.
17:06S11001001butlast and pop are considered to cover the universe of common ideas you would express in code. The ability to deal with arbitrary seqs is at odds with making assumptions about what operations are safe or efficient on a particular domain of seqs
17:06S11001001IOW, if you are writing code that iteratively pops, you should just say pop
17:06S11001001note that "conj" has exactly the same front-or-back behavior
17:07FrozenlockWhich is another thing that I find confusing. -_-
17:07FrozenlockI'm not as smart as you guys.
17:07clojurebotexcusez-moi
17:08amalloyS11001001: butlast is definitely a bad solution, but calling it O(n) is a bit misleading
17:09amalloyit's a lazy operation, and returns items when it can
17:09nDuffFrozenlock: ...the thing to remember is that you can trust functions to do only what they promise to do. conj doesn't promise anything about _where_ things go, so it does whatever's convenient.
17:10nDuffFrozenlock: ...that way you can pick the function that has only the constraints that you need, so the implementation can be fast/cheap if it can optimize things away by not delivering on promises you don't need.
17:11Frozenlock,(doc conj)
17:11clojurebot"([coll x] [coll x & xs]); conj[oin]. Returns a new collection with the xs 'added'. (conj nil item) returns (item). The 'addition' may happen at different 'places' depending on the concrete type."
17:11FrozenlockSo if I use conj and pop, everything will 'work' as expected. It's if I try to build on orders than things get more complicated?
17:13Frozenlock,(pop (conj '(1 2 3) 4))
17:13clojurebot(1 2 3)
17:13Frozenlock,(pop (conj [1 2 3] 4))
17:13clojurebot[1 2 3]
17:13Glenjaminis there a built-in function to do (merge m (f m)) ?
17:14technomancyjuxt!
17:14technomancy(not really)
17:15Frozenlockmerge-with?
17:15brehaut(comp (partial apply merge) (juxt identity f))
17:16technomancybrehaut: so much more abstract amirite
17:16Glenjaminheh, i've found myself doing it a lot with ring maps
17:16brehauttechnomancy: you can take my points, but you will never take my freedom
17:16FrozenlockBurn the land and boil the sea...
17:17Glenjaminbrehaut: can you generalise to [m & fns] ?
17:17technomancy=D
17:17pjstadignot exactly a built in function
17:18brehautGlenjamin: not without wasting too much of my life
17:18Glenjaminheh :)
17:18Glenjamingetting into haskell territory
17:24brehautarrdem: oh?
17:24arrdembrehaut: fnp/effects doesn't seem to be behaving the way I expect.
17:26brehautarrdem: hmm. i dont know if i ever used that form
17:28brehautarrdem: it looks like (effects …stuff…) wraps up side effects that can consume input and then returns the state to what it was prior to the effects being called?
17:29arrdembrehaut: where are you reading that? Choi's wiki says its (effects rule fn) calls fn for side-effects then rule.
17:29abphttps://github.com/pedestal/pedestal/blob/master/app/src/io/pedestal/app/query.clj there we go. :)
17:29brehautarrdem: i went and looked at the code (in the factual fork). i could be well wrong though
17:30arrdembrehaut: okay that makes more sense actually. thanks.
17:30brehautarrdem: https://github.com/Factual/fnparse/blob/master/src/name/choi/joshua/fnparse.clj#L381-L386
17:31brehautarrdem: at this point i also dont trust the original repo or related content to be remotely up todate or relevant
17:31arrdembrehaut: agreed...
17:31brehautarrdem: that also goes for my blog posts if you happen to stumble on them
17:31arrdemjust the first thing Chrome pops up when I enter C-l fnparse XP
17:32arrdembrehaut: noted thanks
17:32brehaut(i think the gist of them is still sound, but the specifics may be off)
17:35arrdemsorta like clojuredocs.org!
17:38brehautwait, which one is that
17:38brehautthe old one?
17:38arrdemyeah.
17:39arrdemwhich one is the new one?
17:39brehautclojure-doc.org
17:39brehautnot confusing at all ;)
17:40amalloyi'll register do-clojure.net
17:40arrdemah I was under the impression that it was clojure-docs.org which doesn't exist
17:40amalloythat should clear things up
17:40arrdem-________-
17:40Raynesamalloy: I think you mean doc-clojure.net
17:40amalloythere's already a C there, mate
17:40RaynesGet off my internet.
17:40cap10morganis it possible to tell leiningen to use a local copy of a library instead of the one it downloaded? (i.e. a git clone I modified and want to test)
17:41arrdemcap10morgan: as of Lein 2.0 you have to actually build the library and install it with Maven before Lein will touch it.
17:41blrmarrdem: I've made that mistake enough to consider just buying the domain and redirecting :)
17:42cap10morganarrdem: ok, bummer
17:42brehautarrdem, cap10morgan really? lein install works fine for me without any fancy setup
17:42tieTYT {:pre [(not-nil? d) (not-nil? precision)]}
17:42tieTYTis not-nil? assumed to be a predicate?
17:43tieTYTor does it throw an error if something is null?
17:43antares__arrdem: not at all, just use Leiningen checkouts
17:44arrdembrehaut: oh yeah that'd do it.
17:44arrdemcap10morgan: if you can build from source, the lein install thang that brehaut mentioned 'll do for ya
17:44brehautphew. i was really worried i had been developing code under some deep hallucination
17:44antares__cap10morgan: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies
17:44arrdemif jar then the maven stuff applies.
17:45antares__arrdem: there is no need to build Leiningen-managed projects from source to install locally, just use checkouts: https://github.com/technomancy/leiningen/blob/master/doc/TUTORIAL.md#checkout-dependencies
17:47cap10morganah, yep, lein install worked. thanks brehaut, arrdem
17:47arrdemcap10morgan: np, happy lisping!
17:51TimMc< brehaut> technomancy: you can take my pants, but you will never take my freedom
17:51TimMcI think I may have misread that.
17:52brehautTimMc: i have a hellboy comic for you
17:52tomojsweet, taking 5e5 samples per second from a multinomial with 10e6 outcomes https://www.refheap.com/paste/2f6b52745b5b1ab11cb04a214
17:53Glenjaminhere we go, apply functions to map and merge recursively
17:53Glenjaminhttps://gist.github.com/glenjamin/5200480
17:54Glenjamincan't decide if its worth using though :s
17:56brehautTimMc: http://media.brehaut.net/files/tmp/pants.jpeg
18:07tomojapparently 1 out of 5e6 words is "foo"
18:08tomoj4e6
18:09tylerwhats the diff between ^:foo and #^:foo ?
18:09tomoj#^ is archaic
18:10tylerah, saw it in a slide
18:10tyleri was like dafuq?!
18:11TimMcFrozenlock: o/
18:11Frozenlock\o
18:12FrozenlockI'm still convinced that I can be funny. One day I'll succeed.
18:12brehauttyler: side effecting predicates are a code smell
18:12TimMcI got the reference, but I'm just a minor fan.
18:12arrdemwhat
18:12FrozenlockYou can't be just a minor fan :P
18:12tieTYTnamed parameters seem a little weird. You don't wrap the input in a {}?
18:12arrdem,(:foo)
18:12clojurebot#<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args passed to keyword: :foo>
18:13Frozenlockarrdem: a keyword is a function (for a map)
18:13TimMcbrehaut: (defn side-effecting? [f] (System/exit 5) false)
18:14TimMc(nothing is side-effecting once the JVM is shut down)
18:14brehautTimMc: that should be 'side-effecting?!
18:14TimMcOh, point.
18:14brehautwhich it turns out was extremely difficult for me to type with my interrobang substitution
18:15S11001001brehaut: nah, not unless it fails when called in a transaction
18:16TimMcS11001001: But it does!
18:16brehautS11001001: way to spoil a good joke with specifics :P
18:16TimMcI'm not sure what (System/exit 5) is *besides* failing.
18:16brehautTimMc: i think he's complaining about my nomenclature about ! functions
18:16S11001001TimMc: I'd call that a successful commit
18:17TimMcHow so?
18:17TimMc"It is not the case that there is a transaction that will retry"?
18:17S11001001causes all active transactions to succeed immediately before exiting
18:17jtoy_can i use leinengein to use code that is on github? a fork of a project that is on clojar ?
18:17S11001001including the currently active one, if such a one exists
18:17S11001001(in this thread)
18:18TimMcS11001001: In that case, side-effecting?¡
18:19TimMcsince it causes transactions to succeed
18:20S11001001cool
19:42jtoy_with with-open how could I skip the first line
19:42jtoy_for example with a csv file i want to skip the header
19:44ed_gjtoy: I would use the data.csv parser and then just use (rest csv-output)
20:08jimkcarcan someone tell me if this is an ok thing to do? or is there something better to do? https://www.refheap.com/paste/12734
20:09ed_g#( ) form will expect an argument. I'd use (fn [] (println "you did command X") instead
20:10jimkcarok. In the real code, I'm just putting the name of various defn declarations in there.
20:11ed_goops #( ) is OK never mind.
20:11ed_gjimkcar: are you asking in terms of using untrusted input?
20:12jimkcared_g: no, its for a repl/shell app. If what they type isn't in the cmd-map, it just tries to eval it as if they were at the repl
20:13jimkcarjust trying to emulate another set of shell commands without making users type (cmd) all the time
20:17ed_gif they type a command thats not in your map, looks like clojure will try to run (nil) and throw an exception. maybe (when (contains? (keyword cmd) cmd-map) ((get cmd-map (keyword cmd))))
20:18tylercan clojure apps access namespaces in cljs files?
20:21jimkcared_g: that's a good idea. I was going to (try ... (catch ...)) it, but I always hate catching errors as flow control
20:26arrdemthoughts on potemkin?
20:38callenbotdanlarkin: what would it take to get proper escaped-by-default behavior in Clabango?
20:38callenbotI'm looking at the ast/token/realize stuff right now, trying to figure out where a good place for this live would be.
20:38jonasacwhat is the idiomatic way to spin up async threads that are supposed to run eternal read loops, i need access to the output ?
20:39callenbotjonasac: eternal?
20:39callenbotjonasac: like an async server?
20:39callenbotjonasac: you could use a buffer that could be drained off. There's more serious servery stuff in Lamina.
20:41jonasaccallenbot: lamina looks cool
20:41callenbotjonasac: ztellman does good work, but you didn't explain enough of what you want for me to get any more detailed.
20:41tomojis a PersistentVector with 64 elements always a tree with two full leaves?
20:44jonasaccallenbot: im not really sure either, looking around for inspiration
20:45callenbotjonasac: if you don't know what you want, you ain't gonna need it.
20:48devnleveling up on pedestal and enjoying it thoroughly
20:49devn</status>
20:49callenbotdevn: liking it eh? anything to report?
20:49callenbotdevn: gimme data!
20:51devncallenbot: nothing you probably don't know, just rewriting some backend services using it
20:52devnspecifically liking the whole route generation setup
20:52squidzIve been programming a little bit in clojure, and have had the feeling that I am getting used to it, but today I came across a problem that just didnt seem to click with clojure. Basically I have to test some rules for Sudoku. Those being, every row/column must contain numbers 1-9, and that each 3x3 subsection must contain the numbers 1-9. I split up the problem by smaller steps, and one of those steps is what is confusing me. I am trying to extract all 3x3 s
20:53squidzthe board is 9x9 btw. meaning that there are 9 sub-blocks
20:53devnsquidz: maybe some use of partition is what you're looking for?
20:54devn,(partition 3 1 (range 25))
20:54clojurebot((0 1 2) (1 2 3) (2 3 4) (3 4 5) (4 5 6) ...)
20:54squidzdevn: that definitely seems to be in the right direction
20:55devn,(zipmap (partition 3 1 (range 100)) (partition 3 1 (range -99 1)))
20:55clojurebot{(0 1 2) (-99 -98 -97), (32 33 34) (-67 -66 -65), (64 65 66) (-35 -34 -33), (96 97 98) (-3 -2 -1), (1 2 3) (-98 -97 -96), ...}
20:55callenbotdevn: I'm considering building my next (mostly simple static content) project in it.
20:55devnsquidz: also look into zippers in clojure
20:55squidzI am using a 2D vector for the representation of my sudoku board. I thougt about partition, even though I forgot that clojure had the function already, but I still am not sure what would be the best way to retain that informaiton while moving through each 'row'.
20:56devnreduce, reductions?
20:56devn,(reductions conj [] [1 2 3])
20:56clojurebot([] [1] [1 2] [1 2 3])
20:57squidzdevn: ah the zipmap looks good. I also thought about reductions, but havent considered it much further than just consideration
20:57devnsquidz: *nod* -- there are a lot of ways to do it, just making some naive suggestions
20:58devnsquidz: you could peek around here a bit (still very much unfinished, but if you're looking to browse some examples of transformations to get ideas) http://getclojure.org/
20:58squidzyeah that's what I was hoping for. Just vague ideas on how I could do it. Ill do the work to get it going. Just wanting to get better grips on the 'clojure' way of doing things
21:00SgeoHey, is ClojureWest going on now?
21:00devnsquidz: Sgeo yeah
21:00SgeoI'm curious as to the Racket presentation that will occur
21:00devnerr Sgeo: yeah
21:04amalloysquidz: https://www.refheap.com/paste/8cecd2392c04c4cd9d7690ab9 ?
21:05amalloythrow in some (vec) calls there if for some reason you need the subgrids to be vectors
21:06amalloyi have trouble seeing how to use reduce, reductions, or partition here
21:07squidzamalloy: It seems like your solution might work. I will have to try it out.
21:12squidzamalloy: hm I just realized that I wanted the partitions to be kind of mini-versions of the whole sudoku board. That is, with nested vectors like so [[1 2 3] [4 5 6] [7 8 9]]
21:12amalloyin that case, read the messages i already sent about that
21:12squidzah okay i see what you meant now
21:44ToxicFrogDesign question.
21:45ToxicFrogI have here (in effect) a list of '(regex function) pairs. When a line of text is read, the function corresponding to the first matching regex is called.
21:45ToxicFrogHowever, this process is slightly stateful. In particular, the dispatch of some lines depends on tokens read from earlier lines.
21:46ToxicFrogThis is all happening in the same thread.
21:46ToxicFrogIn Lua, I'd just slap a file-local variable at the top and close all of the functions over it, mutating it as needed.
21:47ToxicFrogI'm not sure what the closest equivalent is in Clojure (def at the top of the file, def again to mutate?) or even if that's the correct approach (I could, for example, instead have each function return a state-value which is preserved by the caller and passed to the next function)
21:47ToxicFrogAdvice?
21:47clojurebotlive every week, like it is shark week!
21:47ToxicFrog...thank you for that, clojurebot.
21:49brehautToxicFrog: you have a few options. most obvious is state-m, but thats potentially heavy handed. you could keep some addional state in an atom also closed over, or you could implement it as a state machine, where each function in the list returns a value and the next state
21:49brehautToxicFrog: deffing for mutation is verboten. redef is only for dev time
21:50brehautToxicFrog: you can trivially close over a local in just the same way using let (or a function parameter)
21:51kwertiiYou could make a recursive function that passes an accumulator with the state (a map or whatever else is convenient) to itself, along with the next line
21:54brehautkwertii: it doesnt even need to be explicitly recursive. reduce over a seq of lines would be sufficient
21:56kwertiibrehaut: true. I like that solution.
21:59ToxicFrogOk, additional context - most of the line processing is stateless, and I'm using saturnine for this, so the existing flow is basically "line arrives, handler gets called, handler scans regex list to find the real handler function, calls that"
22:00ToxicFrogThis also means I have existing support for "each function returns the next state".
22:01brehautit sounds like its not really a question then eh. just do that
22:01pochoI just included the clj-kdtree into my project.clj and now my compiler can't find mapv. What gives?
22:02ToxicFrogYeah, I was just second-guessing myself because I'm coming from a language where "close everything over a mutable local and then mutate the shit out of it" is the natural approach.
22:02brehautpocho: likely somehting has version clamped you to an old version of clojure
22:03brehautpocho: *clojure-version* from your repl will tell you the version in use, and lein deps :tree from the command line will list the dependancies so you can be sure which version is pulling what in
22:03brehautpocho: also, from memory the lein plugin lein-pedantic will warn you about about some classhing version problems
22:08amalloyToxicFrog: most instances of "iteratively mutate a global" can be transformed pretty mechanically into "reduce over a state local"
22:09brehautpocho: looking at https://clojars.org/clj-kdtree its definately the cause; its clamped to a version range (see also http://nelsonmorris.net/2012/07/31/do-not-use-version-ranges-in-project-clj.html)
22:09brehautpocho: you can try using an exclusion to fix it
22:10tomojhmm
22:10tomojfor a while every time I evaluated 0 in the repl, I saw ~5MB increase in memory usage by my process
22:11brehautO_o
22:11tomojafter allocating a bunch of direct byte buffers with their only remaining references *1 etc
22:12brehautpocho: https://github.com/technomancy/leiningen/blob/stable/sample.project.clj#L38 for an example of a lein exclusion
22:12tomojI can't reproduce now..
22:12arrdemwhy does github not automagically make the doc wiki a submodule /doc ?
22:12tylerohpauleez: if i want to make remote calls via XHR is shoreleave the best way to do it?
22:13ohpauleezare you making them to your server?
22:13ohpauleezor CORS
22:14technomancyarrdem: because submodules can't point to references, only specific revisions
22:14ohpauleeztyler: The best way for interacting with your server is remotes. Specifically, use the macro. If you're calling an external server that you own (like Solr), use JSONP to avoid the CORS headache.
22:14arrdemtechnomancy: TIL thanks
22:14ohpauleezif your server is in a different language (not Clojure), you can use the base xhr remote calls
22:14pochobrehaut: The project.clj on github says it's 1.4.0 compatible. https://github.com/abscondment/clj-kdtree/blob/master/project.clj
22:14brehautpocho: did you download from github or clojars?
22:15tylerohpauleez: thnx
22:15pochobrehaut: clojar. Would it be less painful to get the version from github or use :exclude?
22:15nonubywhat are the alternatives to (take 10 (interleave (iterate inc 0) (iterate dec -1))) - just wondering as it took me a while to figure this implementation out expected is a lazy seq that goes 0 -1 1 -2 2 -3 3 and so fotth
22:15tylerohpauleez: im experimenting using a full clojure stack sending edn as data format, im a clojurescript noob heh
22:16ohpauleeztyler: Awesome! In that case you'll definitely want to use the remotes
22:16technomancypocho: best to do :exclude
22:16technomancymaybe file a bug report if the project isn't abandoned
22:16tyleri usually proxy remote services
22:16brehaut~version ranges
22:17clojurebotversion ranges are nothing but trouble: http://nelsonmorris.net/2012/07/31/do-not-use-version-ranges-in-project-clj.html
22:17ohpauleeztyler: Also have a look at pedestal: http://pedestal.io/
22:17amalloy&(take 10 (rest (mapcat (juxt - +) (range))))
22:17lazybot⇒ (0 -1 1 -2 2 -3 3 -4 4 -5)
22:17tylerohpauleez: i saw it with everyone else ;) it looks cool. i have the firsst mailing list post, which was an actual bug :)))
22:17brehautamalloy: nice :)
22:17nonubyamalloy, interesting!
22:18technomancyyou sly dog
22:21tylermapcat wins the award for cutest function name
22:21nonubyany others? side effect: discovered juxt :)
22:22ToxicFroglazy-cat?
22:22muhoocors?
22:23ToxicFrogWe need a lazymapcat, or possibly an excuse to use "kitten" in a function name.
22:26trptcolindoes anyone else try and use `man` as an alias for `doc` in the REPL?
22:26brehauttrptcolin: nope. i get tripped up and try help occasionally (curse you, python)
22:27brehautToxicFrog: (def lazymapcat mapcat) ; job done
22:28technomancyobligatory http://spl.smugmug.com/Humor/Lambdacats/13227630_j2MHcg#!i=1503651799&amp;k=dVj9xxz
22:28trptcolinbrehaut: nice, yeah, that should work. maybe i'll alias it in reply. not before it gets more modular/configurable though
22:28kwertiiI remember thinking sometime in the late 80s that all computer systems which accept any kind of text input from a human ought to at least respond to the string "help" intelligently
22:28technomancyleiningen does better; it responds to halp as well
22:28kwertiinice
22:29trptcolinlol, i was just thinking i'd include that as an alias
22:29brehautwhile you are there, you could alias wat to (pst)
22:30trptcolinhehe
22:30technomancyi-dont-even
22:30brehautdont forget O_o
22:31trptcolinah crap, gotta normalize that one, i use o_O
22:31brehauthaha
22:31technomancythey're matching delimiters obvs
22:31brehauthaha
22:32brehauttechnomancy: i want to know what kind of data structure (╯°□°)╯︵ ┻━┻ and ┻━┻ ︵ ╰(°□° ╰) bound
22:32Apage43tables of some sort
22:33TimMc*Inverted* tables of some sort
22:35tylerohpauleez: im stuck on how to define the function on the serverside to call with rpc
22:36Apage43clojure.set/map-invert
22:36ohpauleeztyler: You can either use (defremote …) for one off endpoints, or expose an entire server-side ns as an API endpoint
22:36ohpauleezI typically do that latter
22:36ohpauleezsee shoreleave-baseline 's kitchen-sink branch
22:36nonubygive a list '( { :dt #} { :dt #} {:dt # } .. ~x100) how can I take X from the list from the point where item matches predicates
22:37ohpauleezhttps://github.com/shoreleave/shoreleave-baseline/tree/kitchen-sink
22:37tylerohpauleez: in the readme you require "noir.shoreleave.rpc".... that is confusing is the readme out of date or am i missing something?
22:37tylerohpauleez: thnx
22:37ohpauleezIn what readme?
22:38ohpauleezall of the readme docs probably need to be scrubbed. The source of truth are the marg docs and baseline
22:39ohpauleezhttps://github.com/ohpauleez/shoreleave#wheres-the-code
22:39tylerhttps://github.com/shoreleave/shoreleave-remote/blob/master/README.mkd
22:39ohpauleezyeah, I just spotted that as well
22:39ohpauleezI need to get to all of the READMEs
22:41tyleri don't see defremote anywhere on http://shoreleave.github.com/shoreleave-remote/
22:41tyleris it in a different repo?
22:42ohpauleezyes, it's in the ring piece
22:42nonubyis the defn [] an implicit recur point of do i need to add loop?
22:42ohpauleezI'll nab it for you
22:42tylerah
22:42tylerohpauleez: thnx
22:43ohpauleezhttp://shoreleave.github.com/shoreleave-remote-ring/#shoreleave.middleware.rpc
22:43ohpauleeztyler: ^
22:43tylerdanke
22:43ohpauleez(defremote remote-fn [arg1 arg2 ...] ...)
22:43ohpauleezthis README is also outdated, but it'll give you the right idea: https://github.com/shoreleave/shoreleave-remote-ring
22:46ohpauleeztyler: I apologize for the broken docs. I've been busy with: http://ndensity.com/
22:47tylerohpauleez: nice
22:52tylerso is the reason people are into FRP is because it allows you to do async javascript without having to do callbacks?
22:52tyleror am i way off base
22:52ohpauleezpeople are into it for a variety of reasons, and it is very much dependent on the type of client-side work you are doing
22:53ohpauleezdeclaratively constructing your application in terms of actions/functions and the composition therein is one of the more compelling ones
22:54ohpauleezI'm of the opinion that at the core of these FRP systems, is the notion of a raw c2-event system - a pub/sub with many publishers and many subscribers (more or less)
22:55ohpauleezand that the raw pub/sub abstraction should be exposed and provided for constructing dataflows with pure functions
22:56ohpauleezthis is the general approach promoted in Shoreleave. It's certainly the approach you find in pedestal. In an abstracted way, it's also the approach of Javelin
22:56ohpauleezdespite all having different engines powering the general mechanism
22:57ohpauleezShoreleave is the only one built against a protocol, allowing you to swap it out for whatever suits you app the best. The others force the constraint on you, because it's tightly integrated to other pieces of their toolchain
22:57ohpauleeztightly coupled*
22:57brehautohpauleez: i saw you mention core.specs on twitter; is that the project you were talking about with types, contracts and generative tests?
22:59ohpauleezyeah, technically the project is called "Sterling" but a component is called core.specs
23:00kwertiiI was kind of surprised that nobody mentioned MQ in any of the various streaming event-based stuff presentations
23:00brehautoh right
23:00ohpauleezthe name is only because it re-writes a few contrib libs. And contrib libs can only depend on other contrib libs
23:00brehautah interesting
23:01ohpauleezkwertii: I would say most people in this community deploy service-oriented solutions built around MQs
23:01kwertiiohpauleez: oh. great :)
23:01ohpauleezand potentially do some sort of event sourcing // CEP
23:01kwertiibut.. like the last clj/w presentation today about gathering profiling data via lamina streams.. apparently uses a custom UDP based protocol.
23:02ohpauleezbrehaut: Yeah, the demo was a little weak but essentially - the keywords (:constraints :typed) at the end of the spec are arbitrary. They can be whatever you want them to be, and you register handlers for them
23:02ohpauleezby default, :constraints gets consumed by test,generative and you can also use it to generate a version of your function/record that's constrained by contracts/conditions
23:02brehautohpauleez: interesting. i'll have to look at it in more depth when work isnt super busty
23:03brehautbusy
23:03ohpauleezhaha, I mean… work being busty isn't so bad
23:04ohpauleezthe real power is being Alloy into Clojure - allowing you to run verification on your general *ideas* about the system, in the repl, and have results/feedback in milliseconds
23:04ohpauleeztest.generative for your requirements, within milliseconds
23:16tylerohpauleez: getting ReferenceError: shoreleave is not defined when running rpc function, any ideas?
23:17pochois using nested atoms a terrible idea?
23:19kwertiipocho: I think so, though I have met an otherwise sane programmer who swears it's a great idea.
23:19brehauthttp://c2.com/cgi/wiki?ThreeStarProgrammer
23:20brehautTwo Cabbage Programmer isnt quite as snappy
23:21tylerheh
23:23tylerah
23:23tylerwrong jar
23:23tylerthanks https://github.com/shoreleave/shoreleave-remote-ring/issues/5
23:26amalloybrehaut: cabbage? i haven't been following the conversation, but i *have* to hear what that's about
23:26brehautamalloy: one name for '@' is cabbage
23:27amalloyah
23:29tyler2par is my new rap name
23:29tyler((
23:36tylerbloody hell
23:37tylerupdated jar and still is wonky
23:37tyleroh well
23:39tyleraaaaaaaah
23:40amalloybrehaut: i actually have some two-cabbage code
23:40tylerohpauleez: derp you need to require [shoreleave.remotes.http-rpc :as rpc] even if you're only using macros
23:40tyleri think thats a clojurescript thing require to get access to namespace
23:40brehautamalloy: what about three?
23:40tyleror is that a clojure thing
23:40amalloyunclear
23:40amalloyi have one place where i store (atom {:key (delay (future ...))})
23:41brehauthah
23:41brehauti think thats at most 2 cabbage
23:44ohpauleeztyler: Yeah, that's a cljs thing
23:44ToxicFrogNow I'm having an issue where, after editing some files, "lein repl", "lein run", and "lein compile" all say "all namespaces already :aot compiled" and my changes don't get picked up until I touch src/*
23:49tylerdoes pedestal use frp? i couldn't tell when i looked at source
23:53Apage43pretty sure it's devoid of fiber reinforced plastics
23:53amalloyToxicFrog: avoid AOT like the plague unless you absolutely must have it
23:53amalloy(and that's quite rare)
23:58JeanPierreamalloy_, I worship his Shadow