#clojure logs

2012-10-11

00:05AtKaaZ##((juxt name symbol) 'a)
00:05lazybot⇒ ["a" a]
00:07ivan&(apply str (repeat 10 "\uFFFF"))
00:07lazybot⇒ "￿￿￿￿￿￿￿￿￿￿"
00:08AtKaaZ,(.length (str (macroexpand '((juxt namespace symbol) `'`'`'`a))))
00:08clojurebot333
00:09AtKaaZ,(* 2 (.length (str (flatten (macroexpand '((juxt namespace symbol) `'`'`'`a))))))
00:09clojurebot58
00:10AtKaaZ,(* 2 (.length (str (macroexpand '((juxt namespace symbol) `'`'`'`a)))))
00:10clojurebot666
00:14wingyim reading about interactive development using nrepl
00:14wingy"Immutant provides two methods for connecting to an application's runtime with a REPL: Swank (for emacs & possibly vim if you are feeling adventurous) and nREPL (for any nREPL client)."
00:14wingywhat does Immutant means?
00:17muhooit's a project
00:18muhoo,google immutant
00:18clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: google in this context, compiling:(NO_SOURCE_PATH:0)>
00:18AtKaaZ$google immutant
00:18lazybot[Immutant | Home] http://immutant.org/
00:18muhooclojurebot: google immutant
00:18clojurebotFirst, out of 1760 results is:
00:18clojurebotImmutant | Home
00:18clojurebothttp://immutant.org/
00:29wingyafter reading this https://github.com/clojure/tools.nrepl i still dont get how to connect to a remote nrepl instance
00:32AtKaaZwingy, like: lein repl :connect nrepl://localhost:50821
00:32AtKaaZin my case that's the url for the ccw/eclipse started one
00:33SgeoCan nREPL servers be password protected?
00:33wingyAtKaaZ: cool it worked
00:33wingywhere did you get that info?
00:34AtKaaZwingy, I remembered it from a video, not sure but maybe it was chas emerick
00:34AtKaaZin this vid: https://www.youtube.com/watch?v=VVd4ow-ZcX0
00:35wingyAtKaaZ: lein help repl
00:35wingyill watch it now :)
00:35wingyi love your video recommendations
00:35wingywow 1.30 h :)
00:36AtKaaZikr, I'm only at 28min :)
00:36wingywe should watch a video together some time
00:36wingyso we can live discuss :)
00:36wingyi watched movies with my pal like that many times :)
00:37AtKaaZI usually have a few open and paused , do other stuff and randomly continue
00:37wingyyeah
00:37AtKaaZwingy, it talks about your :join false which I saw earlier recommended for you, at about minute 28 in the video
00:38wingycool
01:46uvtc,(str/replace "score is 22" #"(\d+)" #(str "1" %1))
01:46clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: str, compiling:(NO_SOURCE_PATH:0)>
01:46uvtc,(clojure.string/replace "score is 22" #"(\d+)" #(str "1" %1))
01:46clojurebot"score is 1[\"22\" \"22\"]"
01:46uvtcHow can I get "score is 122"? ^^
01:47uvtcI want to take the whole thing that matched the regex, then (str "1" whole-thing).
01:51ivan,(clojure.string/replace "score is 22" #"(\d+)" "1$1")
01:51clojurebot"score is 122"
01:52ivan,(clojure.string/replace "score is 22" #"(\d+)" #(str "1" (first %1)))
01:52clojurebot"score is 122"
01:53uvtcThanks, ivan. But why is that `first` call required there?
01:53ivan,(clojure.string/replace "score is 22" #"\d+" #(str "1" %1))
01:53clojurebot"score is 122"
01:53AtKaaZ,(clojure.string/replace "score is 22" #"(\d+)" #(when-let [[x] %] (str "1" x) ))
01:53clojurebot"score is 122"
01:53ivansomething to do with matching groups giving you a vector
01:54ivanyou have a matching group, and a "whole match" (in my vague non-understanding)
01:54uvtcAh, didn't see that if you left out parens, the whole match is $1
01:54uvtcThanks, ivan!
01:55uvtcOh wait I'm wrong there.
01:55uvtc,(str/replace "score is 22" #"\d+" "1$1")
01:55clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: str, compiling:(NO_SOURCE_PATH:0)>
01:55wei_how do you traverse a list with an atom that represents the current item? for example, I'm displaying one image in a list of images, and i want to be able to get the next or previous image.
01:55AtKaaZ ,(clojure.string/replace "score is 22" #"(\d+)" #(println %&))
01:55clojurebot([22 22])
01:55clojurebot#<NullPointerException java.lang.NullPointerException>
01:56uvtcAtKaaZ: Wait ... $% vs. %& ...
01:57AtKaaZuvtc, I was only showing what the param(s) are to that function it's that [22 22] vector
01:57AtKaaZaka 1 param
01:57AtKaaZbut it is due to the grouping parens near the (\d+) right?
01:57uvtcAtKaaZ: Oh, right. Forgot about %& in literal function syntax.
01:59uvtcSeems like it would be handy if "$&" meant "the whole match"...
02:00amalloyuvtc: $0, i think
02:00AtKaaZ,(clojure.string/replace "score is 22 33" #"(\d+)" "1$0")
02:00clojurebot"score is 122 133"
02:00uvtcHoly malloy! Avast!
02:00uvtcThanks, amalloy, that's it. :)
02:00amalloyit would be pretty silly for clojure's & notation to sneak into java's regex replacer :P
02:01AtKaaZ,(clojure.string/replace "score is 22 33" #"(\d+)" "1$1")
02:01clojurebot"score is 122 133"
02:02AtKaaZwish I knew the answer to wei_ 's question
02:02wei_thanks AtKaaz
02:02wei_I was beginning to wonder whether it was too newb a question
02:03Sgeowei_, maybe two lists, with the head of one of them representing the current item?
02:03wei_so i can pop to find the next one. but how to get prev?
02:04Sgeo['(3 2 1) '(4 5 6)] could be, for example, the list 1 2 3 4 5 6 with the current position being on 4
02:04AtKaaZwei_, was the atom the index to an immutable "list" ?
02:04SgeoThe previous would be the head of the left list, current is the head of the right list
02:06wei_works for me. thanks Sgeo!
02:06SgeoYou're welcome
02:06SgeoNote that I don't know if that's idiomatic Clojure style, but it avoids the need for mutability
02:06wei_the atom can be that whole structure, i guess
02:07SgeoNote that this concept is, I think, what clojure.zip is about
02:07AtKaaZSgeo, so when you go to the next, you'd get new lists like ['(4 3 2 1) '(5 6)] ?
02:07SgeoAtKaaZ, yes
02:08Sgeo,(-> '(1 2 3 4 5 6) clojure.zip/seq-zip)
02:08clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.zip>
02:09Sgeo,(require 'clojure.zip :as 'zip)
02:09clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.Symbol>
02:09Sgeo,(require '[clojure.zip :as zip])
02:09clojurebotnil
02:09Sgeo,(-> '(1 2 3 4 5 6) zip/seq-zip)
02:09clojurebot[(1 2 3 4 5 ...) nil]
02:09Sgeo,(-> '(1 2 3 4 5 6) zip/seq-zip zip/down zip/next zip/next zip/next)
02:09clojurebot[4 {:l [1 2 3], :pnodes [(1 2 3 4 5 ...)], :ppath nil, :r (5 6)}]
02:10Sgeo,(-> '(1 2 3 4 5 6) zip/seq-zip zip/down zip/next zip/next zip/next zip/prev)
02:10clojurebot[3 {:l [1 2], :pnodes [(1 2 3 4 5 ...)], :ppath nil, :r (4 5 6)}]
02:10wei_what's with the zip/down?
02:10AtKaaZyep I'm totally lost :)
02:10Sgeo,(-> '(1 2 3 4 5 6) zip/seq-zip zip/down zip/next zip/next zip/next zip/prev zip/node)
02:10clojurebot3
02:11Sgeowei_, in clojure.zip, when you make a zipper out of something, your "location" starts out as the entire structure itself
02:11Sgeo,(-> '(1 2 3 4 5 6) zip/seq-zip zip/node)
02:11clojurebot#<CompilerException java.lang.RuntimeException: No such namespace: zip, compiling:(NO_SOURCE_PATH:0)>
02:11Sgeo,(require '[clojure.zip :as zip])
02:11clojurebotnil
02:11Sgeo,(-> '(1 2 3 4 5 6) zip/seq-zip zip/node)
02:11clojurebot(1 2 3 4 5 ...)
02:11Sgeo,(-> '(1 2 3 4 5 6) zip/seq-zip zip/down zip/node)
02:11clojurebot1
02:12wei_so in this case the list itself is the parent node for the items
02:13Sgeo,(-> '(1 2 3) zip/seq-zip zip/down zip/right (zip/replace 10) zip/root zip/node)
02:13clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn>
02:14Sgeo..?
02:15SgeoAt any rate, the two list structure I showed you is, to the best of my understanding, a form of zipper, even if it doesn't support descending and isn't clojure.zip compatible
02:15wei_,(-> '(1 2 3) zip/seq-zip zip/down zip/right (zip/replace 10) zip/up zip/node)
02:15clojurebot(1 10 3)
02:16ori-lwei_: konami code?
02:16wei_right, your implementation does resemble a zipper
02:17wei_ori-l haha, i think you need a tree for that
02:17Sgeo,(-> '(1 2 3) zip/seq-zip zip/down zip/right (zip/replace 10) zip/root)
02:17clojurebot(1 10 3)
02:19SgeoI should really sleep now, I have class in less than 6 hours
02:20AtKaaZ,(-> '(1 2 3) zip/seq-zip zip/down zip/right zip/right (zip/replace 4) zip/up)
02:20clojurebot[(1 2 4) nil]
02:21AtKaaZoh right, forgot root
02:29AtKaaZ,(quote a b c)
02:29clojurebota
02:32AtKaaZhow would you replace the numbers with d a b c here: ##(-> 4 (list 1 2 3))
02:32lazybot⇒ (4 1 2 3)
02:32AtKaaZother than this ##(-> 'd (list 'a 'b 'c))
02:32lazybot⇒ (d a b c)
02:34AtKaaZ,(-> 'd (list (map symbol '(a b c))))
02:34clojurebot(d (a b c))
02:43AtKaaZhow do you make a list of params become non-list, in non-macros
02:43AtKaaZ,(#(do (-> (last %&) (list (reverse (pop (reverse %&)))) ) ) 1 2 3)
02:43clojurebot(3 (1 2))
02:46tomojhuh?
02:46AtKaaZ:) I want to pass 2 param but they are in a list
02:46AtKaaZthere was a simple way but I'm missing it now
02:47AtKaaZrigth apply?
02:47tomojsay what you want like (= (__ + '(1 2)) 3)
02:47tomojwhere __ is the blank you want to fill in
02:48AtKaaZit's "apply" what I was looking for
02:48AtKaaZ,(apply list '(1 2 3))
02:48clojurebot(1 2 3)
02:50AtKaaZok appply would've worked but not in my example: (#(do (-> (last %&) (list (___ (reverse (rest (reverse %&)))) ) ) ) 1 2 3)
02:53AtKaaZbasically I want to do this: (list 1 (2 3)) without flatten and return (1 2 3)
02:53AtKaaZ,(flatten (list 1 '(2 3)))
02:53clojurebot(1 2 3)
02:54AtKaaZthat, but without flatten :)
02:55AtKaaZtomoj, ,(list 1 (____ '(2 3)))
02:57AtKaaZin other words, is it possible to return a non-collection list of things heh
02:58AtKaaZI guess macros then
03:11wingyclj is such a good repl lang
03:11AtKaaZok i give up, i wanted a generic way to see the difference between -> and ->> by being able to pass any number and type of params to be added to a list by ie. (funxion-any -> a b 2 ) or (funxion01 a b 2) which would return (2 a b) or (a b 2) if ->>
03:11AtKaaZ,(#(do (flatten (-> (last %&) (list (reverse (rest (reverse %&))) ) ))) 'a 'b 'c)
03:12clojurebot(c a b)
03:13AtKaaZ,(defmacro x [& coll#] `(-> (last '~coll#) (list ~@coll#))) (x 1 2 3)
03:13clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
03:14tomojAtKaaZ: what do you want (list 1 (____ '(2 3))) to be?
03:14AtKaaZ(1 2 3)
03:15tomojthat's not possible
03:15tomoj##(apply list 1 '(2 3)) is possible
03:15AtKaaZi was afraid of that
03:15lazybot⇒ (1 2 3)
03:15tomoj-> and ->> aren't functions
03:15AtKaaZif I do apply like that, then I can't use it with -> and ->>
03:15tomoj,(clojure.walk/macroexpand-all '(-> a b 2))
03:15clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.walk>
03:16AtKaaZyeah I know it's a macro
03:16tomoj,(clojure.walk/macroexpand-all '(-> a b 2))
03:16clojurebot(2 (b a))
03:19AtKaaZok I guess this is the best I can do ##(#(do (flatten (-> (last %) (list (reverse (rest (reverse %))) ) ))) '(a b c 2))
03:19lazybot⇒ (2 a b c)
03:19AtKaaZ,(#(do (flatten (->> (last %) (list (reverse (rest (reverse %))) ) ))) '(a b c 2))
03:19clojurebot(a b c 2)
03:20tomojI guess I still don't understand what you're trying to do
03:21AtKaaZexperimenting, but well I wanted to make a generic way of this structure (-> 1 (list 2 3)) where -> 1 2 and 3 etc. would be changable
03:22AtKaaZso in my example above, I can change/add anything in the (a b c 2) part and the ->>
03:22AtKaaZthe ->> can be one of -> or ->> :) just to see the result
03:28AtKaaZok considering the latest revisions: (defmacro x [f# coll#] `(flatten (~f# (last ~coll#) (list (reverse (rest (reverse ~coll#)))) ))) (x ->> '(a b c d))
03:31AtKaaZor this one might be better: (defmacro x [f# & coll#] `(flatten (~f# (last '~coll#) (list (reverse (rest (reverse '~coll#)))) ))) (x -> a b c d)
03:32AtKaaZI just wish I could get ~@coll# without the last param
03:32tomoj~@(butlast coll#)?
03:32clojurebotCool story bro.
03:33tomojnote you don't need to # the x params
03:33tomojalso ##(#(cons (last %) (butlast %)) '(a b c d))
03:33lazybot⇒ (d a b c)
03:37AtKaaZlol @clojurebot , but how come that works hmm, i tested it that's pretty awesome
03:37AtKaaZwhy don't I need to # the params?
03:38tomojyou only need gensyms in the code your macro returns
03:39tomojthose params are in the macro code, not its result
03:39tomoj'x#
03:39tomoj&'x#
03:39lazybot⇒ x#
03:39tomoj&`(let [x# 3] x#)
03:39lazybot⇒ (clojure.core/let [x__11709__auto__ 3] x__11709__auto__)
03:40tomojwhy not just macroexpand to see the difference between -> and ->>?
03:43AtKaaZI was already aware of that, so kinda trying experimenting other ways; started from (-> 1 (list 2 3)) and then what if I wanted to allow a b c, then what if I didn't want to manually quote them like (-> 'a (list 'b 'c)) then what if I wanted to pass only the relevant inputs -> a b c to a function
03:44AtKaaZso far you taught me this important thing: ~@(butlast coll#) and I'm still not yet to the part with x#
03:45AtKaaZoh right x# I got the part with gensyms not being needed
03:51AtKaaZ,(apply quote '(a b c))
03:51clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: quote in this context, compiling:(NO_SOURCE_PATH:0)>
03:52AtKaaZ,(map symbol '(a b c))
03:52clojurebot(a b c)
03:52AtKaaZ,(map symbol '(a b c 1))
03:52clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String>
03:53AtKaaZactually I want this: (map quote '(a b c))
03:54wingyAtKaaZ: you never sleep
03:54AtKaaZmaybe in here: (defmacro y [& c] `(list ~@(map quote c))) (y 1 2 3 4 d e)
03:54AtKaaZwingy, I sleep when I am offline
03:55wingyme 2
03:55wingysleep code sleep code
03:55AtKaaZI don't code, yet, I'm nowhere near there:)
03:56wingylearn code learn code
03:57AtKaaZ,(list (symbol 'quote) 'a)
03:57clojurebot(quote a)
03:57wingythe best way to learn something is to code something though
03:57wingycode an app you wanna launch for real
03:58AtKaaZ,(println (symbol "'a"))
03:58clojurebot'a
03:59AtKaaZ,(println 'a)
03:59clojurebota
03:59AtKaaZwingy, yeah but I need to learn some more, experiment randomly
03:59wingyuse Light Table for that
03:59wingyits the best learning env
04:00wingyhttp://www.chris-granger.com/2012/08/17/light-table-reaches-010/
04:00AtKaaZthanks, I think I've seen it before, but not lately
04:01wingyit will make learning clj 1000 times more fun
04:06AtKaaZ18mb launcher wonder why it needs to connect to the internet, not allowing =)
04:07wingyfor stats
04:07wingyyou got firewall?
04:07AtKaaZyep, I it won't start without internet, oh well
04:07wingyheh .. its probably nothing harmful
04:08wingytrust me .. its worth it
04:08AtKaaZI'll just fake a local server for it lol
04:08wingyits like lein .. doing some checks and installing things
04:08AtKaaZin lein we trust :))
04:08wingytrust ibdknox
04:08wingyhe is harmless
04:09wingyit will save you 1000 hours
04:09wingywhen final is here im sure i will ignore "lein repl" :)
04:12tomojdatomic should have a pricing plan where you give rich equity for a temporary license
04:13wingythey should have a cloud alternative
04:13wingyproviding it as a heroku addon with full managed scalability
04:13wingyme hate sysadmin works
04:15tomojyeah heroku addon would be cool
04:15wingyhttps://groups.google.com/forum/?fromgroups=#!topic/datomic/6uh2edM-i1g
04:15wingyno answer though
04:15tomojthe peer limit seems weird
04:20tomojwell
04:21tomojyou could pretty easily do in-memory datomic on heroku I think
04:22tomojthough you don't have a lot of ram so..
04:25wingyin memory is only for development though
04:25clojurebotIk begrijp
04:26tomojyeah
04:30wingyif i make a transaction with datomic: @(d/transact conn [{:db/id #db/id[:db.part/user -1000001] :name "foo"}])
04:30wingyhow do i get back the entity (id) immediately?
04:54michaelr525is there anything like that function in core? http://clojuredocs.org/clojure_contrib/clojure.contrib.map-utils/deep-merge-with
04:55michaelr525merges a map recursively
04:56michaelr525hmm
04:57michaelr525i'll just copy that function over to my code :)
05:31edlichSorry first time here. Looking if something happens...
05:59KototamaI don't understand people complaining about the Lisp syntax, it's so much better than JavaScript. After writing a few macro here is what I get http://paste2.org/p/2322970
06:02tomojcool
06:02tomojwe can do better than backbone, though :)
06:03Kototamaprobably :-)
06:04wingyhow do i require the test files in repl?
06:05wingyit usually is looking for namespaces in the src/ dir
06:05wingynot the test/ >
06:05wingy?
06:08tomojmaybe lein with-profiles test repl ?
06:08tomojjust a guess
06:09tomojer
06:09edlichand lein test in another shell is not possible?
06:10tomojwith-profile
06:10edlichOr possible lein repl and then require the test file (but I didn't test if this works)
06:10wingyi just required the namespace that was defined
06:11wingyit worked since test/ must be in the class path
06:11edlichSo problem solved?!
06:12wingyyeah
06:12wingyjust trying to find a good testing workflow now
06:13wingyi run it atm with (run-tests 'testing-ns)
06:13edlichBy the way is someone working with travis-ci.org ?
06:14edlichThe clojure part needs more documentation as: what could be written in the script part etc.
06:15edlichThis might be how you wingy should test ;-)
06:15wingyedlich: have not used travis yet
06:16wingyi'll get there :)
06:16edlichit's cool
06:16edlichbut beta.
06:16wingywhats the benefits?
06:16edlichYou can set a github hook.
06:16edlichSo every commit gets an automatic build. Have a look:
06:16wingycool
06:17edlichhttps://travis-ci.org/#!/edlich/rasbojnik
06:17edlich(but my project is also just starting... (not much code in there...)
06:22edlichWhat would be really great would be a clojure coach. There should be a platform to hire one.
06:22wingywould be so much better if the failures in clojure.test gave some different colors
06:23wingythere is a lot of info about clj already
06:23wingyconsult http://thinkrelevance.com/
06:24edlichI have ALL books and I am studying them.
06:24edlichI am thinking more of something as a neat help like small feedback 50 cents, middle Feedback = 2$ big Feedback 5$
06:25edlichI think I ask Stu when meeting him at the next conference. Good hint. Thanks.
06:25wingyyeah he should know
06:27edlichBy the way do you know a forum to ask technical questions beside the toplevel Google Group #!forum/clojure ?
06:28wingystackoverflow :)
06:29edlichOK have to build up a credibility there ;-)
06:33wingyis using (with-test) preferable since your tests are coupled with your code
06:33wingycould it yield better TDD behavior?
06:33wingyor should we decopule them with (deftest) instead in different files
06:37edlich(someone else should jump in here. Not yet a Clojure testing Guru).
06:38clgvwingy: separating tests from code is done in a lot of clojure projects.
06:39wingyclgv: i've noticed .. but what i like with looking at clj code is that i can read the doc and meta data for the fns as well
06:39wingythey are all in one place
06:39wingyperhaps the testing would make it easier to understand how to use the code?
06:40wingysince if they are in different files i would probably never look at them
06:40wingytoo much work when browsing in github
06:40wingy:)
06:40wingybut it seems that no one likes this
06:41clgvoh, if I want to see typically use cases and there are tests, I often read them to get an impression
06:41clgvwingy: it would be nice though, to have some connection between tests and code. maybe via metadata or something
06:42wingywhat are the bad things with having them in one place
06:42wingybloat?
06:42clgvdepending on the size of your namespaces it could get very crowded
06:42wingyyeah .. but that would force everyone to write/read tests :)
06:42wingyfirst class citizens
06:43wingylike doc!
06:43clgvI cant follow that conclusion
06:43wingyi prefer to read the doc in source code rather than from external places since its all there
06:43wingyyeah .. just preferences
06:43wingyill try both out and see how it works out
06:49wingyhow do i mock http requets?
06:49clgvmorning laurent ;)
06:50noidiwingy, if you're using Ring or something based on it, the requests are just Clojure maps. there's nothing to mock.
06:51wingynoidi: im using clj-http to make requests in some fns
06:51wingynoidi: but ill test the route handlers as well later , thx for the tip
06:51clgvwingy: mock the clj-http functions you are using ^^
06:51hyPiRionHumm, defrecords doesn't support destructuring for record elements. In hindsight, that may be a good thing.
06:51wingyclgv: with dynamic binding?
06:52clgvwingy: if you use midje, you can just use its related features...
06:52wingyim using clojure.test
06:53wingydynamic binding should do mocking pretty easy
06:53clgvhyPiRion: huh? defrecord has a 100% map implementation. or what exactly do you mean?
06:53wingyif there isnt another mocking way
06:53wingyno mocking libs in clj?
06:53clgvwingy: there are some macros like with-redefs ...
06:54noidiwingy, in midje you can do (fact ... (provided (some-fn arg1 arg2) => return-value))
06:54clgvnoidi: thats one of the features I chose midje for ^^
06:55wingynoidi: is there a way to programmatically run midje from repl?
06:55noidiwingy, e.g. (provided (client/get "http://www.google.com&quot;) => {:fake "response"}))
06:55hyPiRionclgv: (defrecord Foo [[bar] baz] ...) isn't legal.
06:56noidiwingy, the facts are run upon evaluation. just re-evaluate the fact, and you'll get error printouts in the repl if the tests fail.
06:56clgvhyPiRion: ah, you want to define a structuring in the definition. right, that's not going to work
06:56wingynoidi: how do you run the tests?
06:57clgvwingy: lein test or evaluating the namespace should work
06:57hyPiRionOh, while I remember: Is there any way of making a clojure-set/map/vector/list/seq which contain itself?
06:59hyPiRionX = #{X} seems to be impossible, which picked my curiosity
06:59noidiwingy, there's also the midje plugin for leiningen
06:59clgvhyPiRion: yeah cycle references are not possible with immutable datastructures- you'll need some indirection. but you can manage it with transient
07:00hyPiRionclgv: not possible with immutable datastructures in Clojure*
07:00hyPiRion;)
07:00clgvhyPiRion: I think that is general
07:01noidihyPiRion, you can add in laziness with (delay)
07:01clgvok. lazy sequences can have cycles ^^
07:01hyPiRionclgv: If you have unbound variables, then it's doable.
07:01noidioops, I mean promise
07:02clgvhyPiRion: right. but the variable is then not immutable and thats the trick
07:02noidi(let [a (promise), b (promise)] (deliver a {:b b}) (deliver b {:a a}))
07:02hyPiRionclgv: I suppose that's depending on the definition of immutable.
07:02noidior something like that >(
07:02noidi:)
07:03noidithen you can do (:a @(:b @(:a @(:b a))))
07:03clgvhyPiRion: well take maps and vectors. you definitly can't do it with them.
07:04hyPiRionclgv: Again, not in Clojure. Say X = {:foo Y}, and Y is unbound. You can then assign Y = X.
07:05hyPiRion/s/assign/unify/
07:05clgvhyPiRion: well if immutable means that the data structure rflects changes by returning a modified version of itself, than you can't do it in general
07:05hyPiRionnoidi: I know of that one. The sad part is that you have to dereference the items :(
07:06clgvhyPiRion: try to build a graph representation with deftype/defrecord (without transients) as edges and nodes where the edges contain both nodes and each node contains its edges
07:07clgvand :volatile-mutabile and :unsynchronized-mutable are not allowed
07:07hyPiRionclgv: yeah, I know. It's not possible in Clojure.
07:08tomojI started implementing inductive graphs
07:08clgvhyPiRion: no, with the above definition of immutable it is not possible in general for those immutable data structures
07:08clgvyour unbound variable is a mutable thing which is the trick
07:09tomojis a promise mutable?
07:09hyPiRiontomoj: Depends on who you ask :p Clojurians say no, CTMCP says yes
07:09clgvtomoj: no but its assignment is defereed
07:09hyPiRion* I mean reverse
07:09clgvtomoj: you can't change it once it was delivered.
07:09tomojclgv: that seems like a good description of the unbound variable case too
07:10tomojI think IPending makes clojure's promise's mutable in one sense
07:11hyPiRionYeah, clojure's promise is mutable. If you e.g. do (let [a (promise)] (run-thread (deliver a 10)) (run-thread (deliver a 20))), then a could be either 10 or 20
07:11clgvhmm promise is not a value though - it's something you can deref to get a value^^
07:11hyPiRionWell, that's my thought.
07:11clgvhence the mutable/immutable attributes are not really fitting
07:12tomojmy promises can't be delivered that way
07:12hyPiRionIt's an iffy subject. If I defer the computation of a value, is it immutable or mutable?
07:12clgvtomoj: yeah the second deliver will loose and throw an exception
07:12hyPiRion,(let [a (promise)] (deliver a 10) (deliver a 20))
07:12clojurebotnil
07:13hyPiRion,(let [a (promise)] (deliver a 10) (deliver a 20) @a)
07:13clojurebot10
07:13hyPiRion,(let [a (promise)] (deliver a 20) (deliver a 10) @a)
07:13clojurebot20
07:13clgvhuh, was that old 1.2.1 which did throw an exception?
07:13hyPiRionclgv: Well, I was actually kind of hoping an exception would be thrown now.
07:13hyPiRion:(
07:14clgvthat got changed in 1.3 it seems
07:14clgvmaybe it's useful in some case to have the first deliver win silently
07:15tomojthe problem is to let functional clojure code easily get determinism
07:15hyPiRionclgv: It's okay if the values you deliver are the same, but well.. it's not deterministic now, is it?
07:15tomojso that you never deliver different values, except when you don't care (IO? random numbers?)
07:16clgvhyPiRion: hm yes, it's in your duty to guarantee the determinism
07:24hyPiRion&'foo
07:24lazybot⇒ foo
07:30clgv&(#(% %) #(% %))
07:30lazybotjava.lang.StackOverflowError
07:30CheironHi, would you please help me with this? http://pastie.org/5034598
07:46noidiCheiron, check out group-by http://clojuredocs.org/clojure_core/clojure.core/group-by
07:46noidi(group-by :a records-2) will give you a map from the :a value to the record
07:48CheironI need to match by values . for example (Record-1 :a "1") , i need to match the record in records-2 where its :as also equals to "1" . not sure how group-by will help
07:49noidi(for [r1 records-1, :let [r2 (first ((group-by :a records-2) (:a r1)))]] (update-in r1 [:vals] concat (:vals r2)))
07:49noidisomething like that
07:50noidinote that that's untested semi-pseudocode :)
07:50Cheironnoidi: yes thanks :)
07:52noidijust look up each (:a r1) in the map produced by group-by and you'll get all r2s with the same :a
07:52michaelr525maybe (index) and (join) from clojure.set is worth checking
07:53michaelr525inspired by jay fields` post
07:54Cheironnoidi: group-by ins't going to work for me
07:54Cheironi don't know, it is hairy ....
07:57michaelr525hairy?!
07:57michaelr525wtf
07:57michaelr525what's hairy about group by?
08:02Cheironnot group-by . my data . :a values in records-1 aren't repeated . same true for :a values in records-2
08:03Cheiron:a values are unique within the vector but there is a match value in the other vector
08:06Cheironso the question, is how to find by value, not by key
08:07clgvCheiron: the just use something like (for [x r1, y r2 :when (= (:a x) (:a y))] ...build-combined-data...)
08:07clgvthat has quadratic complexity though, in case that matters.
08:07Cheironwhat the Big(O) of that line?
08:08CheironBig (N * N) ?
08:08clgvO(N²) yes
08:08Cheironany ideas for more efficient code?
08:08clgvyou will need to sort both collections to get N*log(N)
08:09clgvyou can sort both and then do a recursion over both collections
08:11Cheironwhat about something like select-value ? http://blog.jayfields.com/2011/01/clojure-select-keys-select-values-and.html
08:14clgvCheiron: you can have O(1) access and a total of O(N) if you build maps of them before. but thats some how cheating since the constants will differ. when sorting you only need comparisons. using a map you need to evaluate a hash function
08:14clgvbut you can try both and see what fits best for your data
08:20clgv*"constant factors" I meant ^^
08:25Cheironi see
08:44CubicHi
08:44CubicI have a bit of a problem with java overloaded methods and reflection
08:45CubicI'm trying to write a function that calls a static method that has an overload for CharSequence and ByteBuffer
08:46CubicI want to avoid reflection, and I suppose I can do this somehow, but putting type hints before the argument or the call hasn't really helped
08:48CubicBasically I have this: (defn glBindAttribLocation [program index name] (GL20/glBindAttribLocation program index ^java.lang.CharSequence name))
08:49Cubicand this: (defn glBindAttribLocationbb [program index name] (GL20/glBindAttribLocation program index ^java.nio.ByteBuffer name))
08:49clgvCubic: you need a typehint for "program" as well
08:50clgvCubic: usually you need the first type hint for the first argument if it can not be inferred.
08:50CubicIt's int in both cases though, the overloads only differ in the last argument
08:53clgvah ok. then wrap it like (int program)
08:55CubicHuh? Attaching typehints to all args actually fixed it. I don't really understand why, but thanks anyway.
08:57jweissdoes anyone write tests in the namespace as code, surrounded by a macro that runs tests at compile time unless a "development" flag is not on, in which case the macro just emits nothing? if not, what's the drawback vs separate tests?
08:57jweisss/namespace/same namespace/
09:03cbergI'm feeling stupid today: Running lein repl in a project base dir, I can't access the project namespaces from the repl. What could I be doing wrong?
09:05edlichPaste your equivalent as (require 'my-stuff.core)
09:06edlichthen we can see...
09:07clgvI'd start with an actual error message ;)
09:07clgvif you have none, what exactly did you do and what did not happen as expected
09:08edlichso you do not even get the REPL prompt?!
09:08cbergOk, so the require worked...
09:09edlichwhat was the mistake?
09:09cbergI may be completely wrong but I thought I used to be able to just jump to a namespace with in-ns and work with the symbols there without requiring?
09:12clgvcberg: yes, that is completely wrong. in-ns just switches the namespace asnd creates it if it does not exist already. hence you end up in an "empty" namespace if you did not load it's implementation previously via use/require
09:14cbergYeah, sorry. I couldn't use Clojure for a few months and apparently my brain leaked. Never mind.
09:15clgvthat error seems pretty common. I wonder where `in-ns` is introduced without explaining it properly
09:25pyrhhoMy project depends on two other packages, which each depends on a different version of the org.codehaus.jackson library (which conflict). I'm new to java (and clojure) how should I fix this??
09:25lazybotpyrhho: What are you, crazy? Of course not!
09:25TimMc$mail antares_ seqs-and-colls is now under dual-license for inclusion into clojure-doc, if desired.
09:25lazybotMessage saved.
09:26TimMcpyrhho: I believe you can put a "hard version" of jackson into your dependency list.
09:26pyrhhoah. so if I have a version specified in my project.clj it will override those project's dependencies?
09:26TimMcpyrhho: This is really a Maven issue, and for reference these are called conflicting transitive dependencies.
09:27pyrhhoTimMc: ok. thanks. that is helpful to goodle
09:27pyrhho*google
09:28TimMcI *think* if you say "[1.2]" (instead of "1.2") in your dependency list it will fix it, but best to look around.
09:28TimMcDo the two Jackson versions have the same major version?
09:29TimMcYou might even be able to use a soft version ("1.2").
09:29pyrhhoTimMc: ah, actually it looks like just setting the version in my project.clj has worked
09:29duck1123pyrhho: You might want to check out lein pedantic. It'll identify all the conflicts and help you choose the right versions
09:29pyrhhoTimMc: erm. maybe
09:30pyrhhoTimMc: Yeah soft version has worked. thanks
09:30pyrhhoduck1123: ok will check that out. thanks
09:30TimMcWhat version of lein are you on? 1.x or 2.x (master)?
09:31pyrhhoTimMc: Leiningen 2.0.0-preview10 on Java 1.6.0_32 Java HotSpot(TM) 64-Bit Server VM
09:36quadrocubeHey, anyone out there?) Can smone help me with this stuff: why is these piece of code throw the clojure.lang.ArityException: Wrong number of args (2) passed to: PersistentVector ? Trying to find it out for a couple of hours now..
09:36quadrocube((fn flat[x] ( if (coll? x) (reduce [] #(concat % (flat %2)) x) [x])) '(1))
09:36quadrocubejust simple flatten
09:37TimMcpyrhho: lein classpath is ugly, but it will tell you exactly what's being included.
09:38pyrhhoTimMc: oh cool.. didn't realise 'lein classpath' existed. thanks
09:46clgvquadrocube: because you have the wrong parameter order for reduce ##(doc reduce)
09:46lazybot⇒ "([f coll] [f val coll]); f should be a function of 2 arguments. If val is not supplied, returns the result of applying f to the first 2 items in coll, then applying f to that result and the 3rd item, etc. If coll contains no items, f must accept no arguments as... https://www.refheap.com/paste/5716
09:46dark_elementI am trying to build a project with this as dependency https://github.com/samaaron/serial-port
09:46clgvreordering your example: (reduce #(concat % (flat %2)) [] x)
09:48quadrocubearrrgh, thx so much, lazybot, dark_element and clgv! Can't forgive myself's stupiditness.. Thx again)
09:48dark_elementgetting this error "java.lang.UnsatisfiedLinkError: no rxtxSerial in java.library.path" when running the uberjar created from leiningen
09:49clgvquadrocube: try to build your code incrementally to avoid such mistakes
09:50dark_elementI think this project https://github.com/samaaron/serial-port should be used with cake but its discontinued
09:53dark_elementany help would be appreciated
09:55jsabeaudrydark_element, What are your needs in terms of serial comm?
09:55clgvdark_element: I think there was a difference how cake and leiningen packed native dependencies. so you might just need to change the jar layout of the RxTx lib
09:56dark_elementjsabeaudry just playing around with it reading some string from serial port
09:56jsabeaudrydark_element, Then I'd say just read/write to the device using a file stream
09:58dark_elementclgv will try that out
09:59dark_elementjsabeaudry will most probably have to run the jar on windows
10:00dark_elementjsabeaudry i am helping somebody to plot volatge ratings from a device in graph, maybe even show it in browser.
10:06AWizzArdWhen I can type „javac” in the shell and get a reply, how can I then find out at what path Leiningen tries to find my javac? Cause Leiningen doesn’t find it…
10:11bhenrycan i queue up futures to limit how many will run simultaneously?
10:11nDuffAWizzArd: My impression was that leiningen used tools.jar directly, rather than invoking javac.
10:14clgvbhenry: not until 1.5 I guess. in 1.5 you may change the executor it seems
10:14clgvbhenry: but you can just use a self configured ThreadPoolExecutor for parallel execution
10:19bhenryin update-message here: https://gist.github.com/06cdd93dadcbe68c2378 can i just call each move-data block in a future, then deref the futures so that it will do those three in parallel but not move on to the next three until they finish?
10:19clgvno
10:20clgvbhenry: you can use pmap to have bounded parallel execution - but you can't set the bound yourself with it
10:20bhenryhm
10:21clgvbhenry: the easiest way to set how many parallel computations are done, is to create a ThreadPoolExecutor yourself
10:23AWizzArdnDuff: do you have an idea how I can let Leiningen know where my jdk is installed? JAVA_HOME seems to get ignored.
10:23mpenetbhenry: you can also use pallet-thread, a thin wrapper around java executors, if you really dont want to touch java interop
10:24bhenryi'll check it out thanks
10:30lpetitclgv: hello
10:30clgvlpetit: hi
10:31lpetitclgv: will start looking at your pull request
10:31clgvlpetit: =)
10:32lpetitclgv: when you think you're ok with a code in a branch, you should change the corresponding issue' status to Fixed:to-be-integrated
10:33clgvlpetit: ah ok. I thought I wait for feedback first. good to know
10:33lpetitSince it's ready to be integrated into main, but not done yet (and I'll either change it to Fixed:to-be-delivered, either to Accepted or New if the code needs rework)
10:34lpetitAlso, a mention (link) to the github pull request or commit to integrate in the issue comments, so that e.g. Chas or Christophe can take a look at it in a click ;)
10:35lpetitclgv: so, before I dig into the code and into the actual behavior, would you please tell me what it's supposed to do ? ;)
10:36clgvlpetit: ok. noted for next time.
10:36lpetitok
10:36lpetitthx
10:38clgvlpetit: the patch enables to search the history for entries starting with the text in front of the cursor. the patch unifies the implementation with already existing stepping through history
10:41lpetitclgv; ok
10:42lpetitclgv: so we should change the default keyboard bindings … but to what ?
10:42clgvlpetit: good question. I thought it good to have them "near to" the history stepping
10:43lpetitsomething like ctrl+alt+up , ctrl+alt+down ?
10:43clgvlpetit: we could use "page up/down"
10:44lpetitI don't know where "page up/page down" buttons are on my Mac keyboard :)
10:44AdmiralBumbleBeefn-up and fn-down probabply
10:44clgvlpetit: would be the same as on lein repl with reply
10:45lpetitclgv: oh really?
10:45clgvlpetit: yeah. it has search there as well
10:46lpetitand what about just having search enabled by default? :p
10:46TimMcI love it when people thank the bots.
10:46clgvhumm I'd like to have both available. since sometimes you know I definitely want one of the last three commands
10:47lpetitclgv: then you just trigger the history with an empty content in the log area?
10:47lpetitor with the cursor at the beginning of the log area's content ?
10:48clgvI think it does not do that yet
10:48lpetitclgv: should it do that, what would you think about the suggestion?
10:49clgvlpetit: I would have to try if it makes sense. currently it jumps to the end of the line so that you can easily evaluate the entry with trailing enter
10:50clgvlpetit: if you have both, you can search for something and still go one step back or forth with the other key bindings
10:51clgvlpetit: I dont know if I or others do or will do that often. I would need to check my behavior on that
10:51lpetitclgv: you mean, via the search going to a certain point in history, and then from this point, start browsing the history without the filter to refine the search?
10:53clgvlpetit: yeah somethimes you have very similar entries since you only used different parameters. I would suggest to keep both history modes and maybe ask the users if they really need both after a while
10:54lpetitclgv: which raises my question again: maybe we could make the new behavior with the search the default, and have new key bindings for the old behavior ?
10:54clgvlpetit: ah you meant it like that.
10:54lpetitjust an idea
10:55clgvthat could work. and maybe adding only one modification key for the old behavior?
10:56lpetitI haven't tested the code yet, but also, out of my mind: it should be possible to come back to what was typed, with the cursor at the same place, if finally the search does nothing. Is this already how it works?
10:56lpetitclgv: yes, the old behavior could be triggered by adding ALT => Ctrl+Alt+Up, Ctrl+Alt+Down
10:56clgvlpetit: if you do not change the cursor position you will come back to the initial statement
10:57lpetitclgv: and if you change the cursor position?
10:57clgvlpetit: if you change the cursor position you changed the query and you wont. hmm that could be added.
10:58clgvlpetit: currently, it would only go back to retained-input
10:58lpetitclgv: needs some real life testing.
10:58clgvyeah. fire it up and try ;)
10:59lpetitclgv: another idea: have considered doing a less restrictive search? Like you just type "foobar" and every history entry containing "foobar" will be filtered?
10:59clgvlpetit: I saw you changed nrepl dep again before my commit. can't the currently used nrepl lib be added to the repository in a third-party directory?
11:00lpetitclgv: I understand what you're saying, and your pain. I'm reluctant (currently) to not play by OSGi rules when possible.
11:02clgvlpetit: no, I did not consider that kind of search. that would be like in the code completion, I guess. I am only used to the prefix search due to repl-y and rlwrap. but maybe it would be worth it
11:03lpetitclgv: would depend whether the ineluctable increasing "noise" introduced would make it doable or not. Of course, this should then go hand by hand with a way to "highlight" the matching portion (but that could be saved for another day)
11:03clgvin leiningen I often do something like "(u" -> complete -> "(use '...)" or "(def s" -> complete -> "(def server (create ..."
11:04clgvI do that a lot if I have a certain debug/test scenario that I recently used
11:04lpetitwhere you could write "serve" -> history -> "def serer (create ...)"
11:06lpetitSometimes, also, the most "unique" part of the history entry you can think of is not at the start of the line. Think about unique local names, etc. ?
11:06lpetitclgv: maybe the "search" function could be specified as a preference :)
11:06lpetits/search/filter/
11:12clgvlpetit: that's an option
11:13clgvI justed wanted to name my frequent use case on the repl ;
11:17lpetitque
11:17lpetitsure
11:19clgvlpetit: well, it's implemented with exchangeable filter anyway ;)
11:19lpetitclgv: :)
11:19lpetitclgv: I've got some urgent emails to answer to, bbl
11:20clgvlpetit: np
11:47holohi
11:48jsabeaudryhelo
11:48holoanyone here is being able to use heroku commands with default app in a directory with multiple apps?
12:00CubicIs anyone here that uses emacs with clojure-mode?
12:01Frozenlo`Sure
12:02CubicI've been trying to find a cheat sheet (or something the like) for it for a while now
12:02AdmiralBumbleBeeCubic: lots of people do
12:02Cubicbasically just a list with the things it actually does
12:02CubicRight now I'm quite desperately trying to comment out a section of my code and it won't let me
12:03AdmiralBumbleBeeCubic: c-h b?
12:03FrozenlockYou mean ';' won't comment the line?
12:03AdmiralBumbleBeeCubic: are you using any other modes?
12:03FrozenlockM-x comment-region is really useful too.
12:03uvtcCubic: M-;
12:04CubicI'm using paredit with clojure-mode. And ; always starts a new line
12:04AdmiralBumbleBeeyou could also mark a region, c-x r t, and ;;
12:04AdmiralBumbleBeeM-; is preferred though
12:04uvtcOh, paredit.
12:05CubicOh great what now? Is that bad? Everyone and their dog told me paredit was the best thing since the invention of chocolate
12:05TimMcIt is!
12:05FrozenlockIt is, but I don't like it :p
12:06AdmiralBumbleBeeCubic: it's fine, you have to mark and use M-; or use rectangle commands or c-q ;;
12:06uvtcCubic: my understanding is that paredit is wonderful, and most folks here recommend it unconditionally, but you've got to dive in head-first and power through the initial learning curve. I haven't yet done so myself.
12:07TimMcCubic: You can also use #_ if you're commenting out syntactically valid code.
12:07TimMc,[1 2 3 #_ 4 5 6]
12:07AdmiralBumbleBeeCubic: in general, if you find something like that again, you can just use c-q to avoid triggering any mode-related bindings
12:07TimMcclojurebot: hello?
12:07AdmiralBumbleBeethen find the 'real' solution later
12:07Bronsawoah, what happened to clojurebot
12:08TimMc&[1 2 3 #_ 4 5 6]
12:08lazybot⇒ [1 2 3 5 6]
12:08uvtcCubic: I wrote up a little Emacs+Clojure tut, if you're interested: http://www.unexpected-vortices.com/clojure/10-minute-emacs-for-clojure.html
12:08Frozenlockuvtc: 10 minutes emacs tutorial is quite misleading I would say :P
12:08CubicEh thanks everyone. I'm pretty much new to emacs (I used it barely enough to be able to open and edit files without accidentally installing DOS in the process)
12:09uvtcThough, I really need to look into how to find out when there's an Ubuntu Emacs 24 so I don't have to add the cassou ppa...
12:09uvtcFrozenlock: I don't think so. It takes a while to internalize the key-combos, but I'd say 10 minutes is somewhere in the right ballpark for just getting your bearings straight. :)
12:10AdmiralBumbleBeein my experience, learning emacs is more about learning how to find help, not so much memorizing combos and chords
12:11Frozenlockuvtc: Must have took me around 2 hours the first time... buffers? Windows? Frame? Wtf am I doing AHHHHHHHH
12:11ziltiFrozenlock: lol
12:11CubicI got that down, but I still accidentally close windows and kill buffers I shouldn't all the time
12:11FrozenlockComing from windows, I was utterly lost.
12:12uvtcFrozenlock: I may need to add those terms to my little tut. Thanks.
12:12AdmiralBumbleBeehow would you accidentally kill a buffer you don't want to1?
12:12CubicYou'd be surprised
12:13AdmiralBumbleBeeI already am
12:13FrozenlockAdmiralBumbleBee: If it hasn't changed since last save it will not ask you "are you really sure"
12:14CubicWell, I definitely managed to kill my REPL at least once when I tried to close an error window
12:14AdmiralBumbleBeeFrozenlock: I'm unsure of how you'd kill the wrong buffer, it's pretty obvious where you are (at least I think it is)
12:14AdmiralBumbleBeemaybe you guys are just using a crappy theme :)
12:15FrozenlockYes, but if you misclick you could click the little "x" thingy and close emacs :P
12:15uvtcCubic: might be better to just start off for now with Emacs+clojure-mode, and then interact with Clojure in a repl in a separate terminal.
12:15FrozenlockThat's before you learn the way and remove the menu bar of course :)
12:16AdmiralBumbleBeeFrozenlock: if you're using the mouse when you're in emacs, I think that's probably a big problem :)
12:16uvtcCubic: then, once you're comfortable with that, add in paredit. And then later nrepl.el.
12:16FrozenlockAmen to that.
12:17Cubicuvtc: I usually just throw in everything at once and then just try until I get some kind of flow. Worked with Vim anyways
12:17clgvIs clojure.core/require threadsafe when multiple threads try to require the same namespace dynamically?
12:17FrozenlockCubic: Then lean elisp and make your own modes :)
12:17technomancyclgv: no =(
12:17technomancyno transactional loading
12:17Cubicclgv: is there actually a good reason to want to do that?
12:18clgvtechnomancy: ok that explains an observation of mine. so I have to wrap it in some coordination on my application level
12:19clgvCubic: yes. remote code execution. all the code base is on the remote classpath and only function symbols are send to the remote side along with parameters
12:22clgvtechnomancy: is something like this in work?
12:22clgvtechnomancy: transactional loading, I mean
12:22technomancyclgv: I don't think so
12:23clgvtechnomancy: humm it shouldnt be hard to do or do I miss a major problem?
12:23technomancyclgv: ever try to contribute to clojure?
12:23clgvtechnomancy: ok, apart from that ;)
12:24lpetitclgv: I have tried the feature. It's easier to remember the keyword by still having the up/down arrows do their job, and just with an additional modifier (alt works for me on Mac keyboard, so ctrl+alt+UP / ctrl+alt+DOWN to be precise)
12:24lpetitclgv: but when I started moving in the history, even if I don't move the cursor, I lose what was currently typed
12:25clgvlpetit: it should work like stepping through history which can come back to what was typed.
12:25lpetitclgv: I'm wrong. It's if I move the cursor. But see? Moving the cursor is easy, so I'd prefer not lose what was type should I go back to it
12:25clgvleptit: I tried that one out before commiting ;)
12:26CubicIs there something like Vim C-v i b in Emacs?
12:27jsabeaudryWhat does that do?
12:27clgvlpetit: ok I guess that could be fixed.
12:27lpetitclgv: I mean, I think this should get special treatment and be retained whatever the filter function at the end of the history list (really, it is not part of the history list yet, just appended to it during the search, I guess)
12:27AdmiralBumbleBeeCubic: what is that?
12:27CubicSelects the inner parts of the current block (S-expression in Lisps) and if that already is selected, goes to the next outer scope
12:28clgvlpetit: yes. it could be removed from the forward search and put in an `or` form with the result of the forward search, or similar
12:28CubicWell the C-v part is just for entering visual mode
12:29wingyis there a way to remove all removed vars when i use (require ns :reload-all) in the repl
12:30lpetitclgv: cool
12:31intranationCubic: try expand-region: https://github.com/magnars/expand-region.el
12:31clgvlpetit: will you change that yourself or shall I fix that next time?
12:32lpetitI'd prefer if you fix that and submit a new pull request
12:32AdmiralBumbleBeeCubic: why are you trying to do that?
12:34CubicFor commenting out (or removing comments) in front a function definition (or similar) also, I want to select (and copy) the contents of a vector all the time cause I'm writing some OpenGL glue code at the moment
12:34Cubicwhere I'm just writing (defn glSomething [args] (GLSomeVer/glSomething args))
12:34AdmiralBumbleBeeCubic: you want to prepend a selection of lines with text?
12:35AdmiralBumbleBeeor remove text?
12:35CubicI want to select the lines in the first place
12:35lpetitclgv: I found a bug
12:35AdmiralBumbleBeeCubic: ideally you'd use C-M-f and C-M-b to navigate and set mark
12:35lpetitclgv: say the history is "1 :a", "2 :b", "3 :c", "4 :d".
12:36lpetitclgv: say I start searching for "b" => I jump to "2 :b". Now I start editing. And I change my mind, erase the content, and start searching for "c" => I don't find it, because it starts searching from "2 :b" in the history
12:37AdmiralBumbleBeeCubic: there's also C-M-h
12:37CubicAdmiralBumbleBee: I don't really know what that does. At least I see no difference to M-f and M-b
12:37clgvlpetit: hmm ok. so we need some kind of reset when editing
12:37lpetitdo you want me to add comments on the ticket for all this ?
12:38clgvlpetit: yes, please
12:39lpetitok
12:39AdmiralBumbleBeeCubic: M-f is forward word, C-M-f is forward-sexp
12:41CubicAdmiralBumbleBee: Ah I see. That's still rather unwieldy though ;)
12:42lpetitclgv: ok, issue updated. We're on the right track !
12:42lpetit:-D
12:42AdmiralBumbleBeeCubic: you could always make a macro real quick
12:43clgvlpetit: is the pull request closed? or should it be updated somehow when the corrections are done?
12:43lpetitclgv: I don't no much about pull requests. I don't know if it can be updated, or should be discarded.
12:44clgvlpetit: ah ok. I thought you might have a default workflow there. so I'll just figure that out, when I commited again
12:44lpetitclgv: while we're at it: would be great if that could be done in a branch reflecting the issue name. I'm used to this with cemerick, works great because I won't accidentally pull more than expected
12:45clgvlpetit: ok
12:45lpetitthose "lightweight" branches work then like easier to manage patch files :)
12:46lpetitclgv: one last word please - consider rebasing your branch on the last master before issuing the new pull request
12:47clgvlpetit: yes. I did that with last too ;)
12:47lpetit:)
12:50lpetitclgv: I'm glad you started working on this
12:54clgvlpetit: it was bugging me for a while. there are also two additional REPLView things I want to fix
12:54hyPiRion,(clojure.pprint/cl-format true "~9f~%" 3.045236495677389)
12:54clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.pprint>
12:54hyPiRion(require '[clojure.pprint])
12:54hyPiRion,(require '[clojure.pprint])
12:54clojurebotnil
12:54hyPiRion,(clojure.pprint/cl-format true "~9f~%" 3.045236495677389)
12:54clojurebot3.0452365
12:54wingywhat are the diffs between with-redefs and with-redefs-fn
12:55hyPiRion,(clojure.pprint/cl-format true "~,9f~%" 3.045236495677389)
12:55clojurebot#<NumberFormatException java.lang.NumberFormatException: For input string: "3045236495">
12:55lpetitclgv: spoilers please :)
12:55wingyim doing mocking for tests but dont know why i would wanna use the latter .. the former works great already for fns
12:55clgvlpetit: they are not as big as search: repl history size as option and removing "noise" from history
12:55hyPiRionOkay, why is not "~,9f" working properly here? Is this a bug in cl-format?
12:56lpetitclgv: tell me more about "removing noise" from history, please
12:57clgvlpetit: there are clojure comments in the history as well as (in-ns ' ...) statements that came from CCW and not from the user
12:57Cubic,(clojure.pprint/cl-format true "~{~a ~}" [1 2 3 4])
12:57clojurebot1 2 3 4
12:57CubicOhh I didn't know that
12:57lpetitclgv: ok, you should probably talk to cemerick about this one
12:58clgvlpetit: ok. I'll ask him before I start anything
13:13clgvlpetit: finishing time for today. good evening.
13:20Sgeo*sigh*
13:21SgeoIn Incanter, I saw some code that modifys refs... several refs, but each modified ref is modified in a separate dosync
13:21SgeoDoesn't that kind of eliminate the point of STM in the first place?
13:21SgeoAdmittedly, since it's occuring in a macro, it's not likely to be a big deal in actual usage, but still...
13:22duck11231does each change need to pass or fail together?
13:23SgeoHmm, not entirely sure. It doesn't make conceptual sense for one to pass and another to fail, but I think if other changes occur mixed in with those it's not a big deal?
13:25Sgeohttps://github.com/liebke/incanter/blob/077cde547363afe675fd8400de11dda0a4b47952/modules/incanter-core/src/incanter/infix.clj#L42
13:26SgeoAlso, ref-set where alter would be more stylistically appropriate, but since it's a ref in a transaction rather than an atom, it shouldn't make a semantic difference the way it would with an atom and reset! vs swap!
13:28SgeoOh hey, there actually is a significant problem with that code due to the split of dosyncs
13:29Sgeo+highest-precedence+ could receive a lower highest-precedence in a race condition
13:30SgeoAlthough... does macro code ever get run in different threads?
13:30SgeoOr is the compiler/macroevaluator/whatever single threaded?
13:34SgeoOh wait defop is a function not a macro
13:34SgeoSo yeah, that doesn't matter
13:34SgeoIt should be fixed. I will fix it when I have time.
14:16FrozenlockWeird... In noir I have a page showing me "{:status 302, :headers {"Location" "/subscribe"}, :body ""}" Instead of redirecting. Any idea what might be happening?
14:17FrozenlockCould the special form 'do' be messing things up here?
14:31amalloyyou're rendering a map with hiccup as the response body, instead of making it the whole ring response
14:36FrozenlockSo it seems. I've found the function causing this, but I don't know why.. https://www.refheap.com/paste/5728
14:36FrozenlockOh wait it might be because 'body' is returned inside a list.
14:46jcromartieNoir: because sessions are magic
14:47cemerickjcromartie: snarky, much? ;-)
14:47jcromartievery much
14:47cemerickSessions are sorta magic everywhere, really.
14:47FrozenlockWhat's not to like?
14:47cemerick!, !, !, generally
14:48cemerickmeanwhile, native ring sessions are simple, but hard
14:48FrozenlockBy ! you mean mutations?
14:48cemerickyah
14:48jcromartiemutating thread-local bindings
14:50FrozenlockAny simple example of ring sessions?
14:50jcromartiecemerick: what's so hard about Ring sessions?
14:50xeqiheh, there are some fun rules about updating them
14:51cemerickjcromartie: if you're passing around full response maps, you need to be very careful about consistently applying downstream changes/additions to the existing state from the request
14:51cemerickI ran aground on that myself last week with Friend.
14:51jcromartiehmm
14:52jcromartieI actually don't really have a problem with stateful sessions as middleware
14:52cemerickwell, maybe you've been doing it right this whole time :-)
14:52l1x, (/ (System/currentTimeMillis) 1000)
14:52jcromartieI also think the word "actually" is actually useless in most cases
14:52clojurebot269996228887/200
14:53cemerickit *works*, it's just easy to forget the rules.
14:53l1xhmm, how can i get back long rounded after the division?
14:53jcromartiewhat are the rules?
14:53jcromartieI always use merge/update-in/etc. when dealing with response maps
14:53duck11231,(long (/ (System/currentTimeMillis) 1000))
14:54clojurebot1349981214
14:54cemerickjcromartie: weavejester can probably state them more succinctly, but basically: you need to consistently propagate any :session provided by a downstream handler
14:55jcromartieand by "downstream" you mean like, an "inner" handler
14:55jcromartieI always get a little mixed up with middleware terminology
14:55weavejesterRight, the base session middleware is very simple - you can only read the session or replace the session.
14:55cemerickyes, or any other function that returns a response map you're going to pass along
14:55duck11231it's hard to know which way is up
14:56l1xduck11231: thanks
14:56jcromartiemy middleware basically follows the pattern: (if-let [resp (handler req)] (-> resp …))
14:56jcromartieor rather when-let
14:56l1xi guess this variable is always 64 bit on every platform
14:58tmciverweavejester: I'm having trouble getting compojure.route/files to serve static files when I run my compojure app using 'lein run'. I see that 'public' is the default root directory. Does that mean files will be served from <project-dir>/public? It doesn't seem to work for me.
14:58jcromartiebut aren't sessions just a convention and not any sort of standard?
14:58jcromartieyou could really do whatever you want
15:00weavejestertmciver: That's correct. What does your route look like?
15:00weavejestertmciver: (route/files "/") ?
15:00tmciverweavejester: yes. let me do a quick sanity check.
15:00weavejestertmciver: Incidentally, route/resources is usually preferred over route/files.
15:02tmciverweavejester: I have test.js in <project_dir>/public. If I go to localhost/test.js, I get the 'not-found' route.
15:03weavejestertmciver: Could you show me what your routes look like?
15:08tmciverweavejester: https://www.refheap.com/paste/5729
15:09cemerickjcromartie: Sure, but it all ends up needing to boil down to a token/cookie that will round-trip on the next request, etc.
15:09jcromartieyes
15:12tmciverweavejester: I also noticed that the 'file-path' local in the files function is 'test' when I try to get my test.js file.
15:15weavejestertmciver: Hm… let me look into this
15:15weavejestertmciver: Out of interest, is there any reason you're using files instead of resources?
15:17tmciverweavejester: none at all. But I just tried to use resources with the same result.
15:18tmciverweavejester: am I correct to assume that the dir that 'public' is supposed to in is the project dir?
15:18amalloyweavejester: fwiw i use files instead of resources because there's better support for things like Last-Modified, MIME types and so forth
15:19weavejestertmciver: Yes, and I can't reproduce your problem… How are you accessing your routes? By running the adapter and accessing them through a browser or HTTP client?
15:19duck11231hmmm... for some reason, it looks like I'm using wrap-files and wrap-file-info
15:19weavejesteramalloy: Ring 1.2 should have better support for last-modified on non-file resources
15:21tmciverweavejester: yes, I'm running the Jetty adapter through 'lein run' and using a browser. The other routes work fine with that setup.
15:21tmciverweavejester: I've no doubt I'm doing something silly, I just don't know what.
15:22weavejestertmciver: What happens if you run the following code in a REPL:
15:22weavejester((route/files "/") {:uri "/test.js", :scheme :http, :request-method :get, :headers {"host" "localhost"}})
15:24tmciverweavejester: that seems to work correctly . . . hmm
15:25weavejestertmciver: Okay, next try passing the same request map to your routes
15:25weavejestere.g.
15:25weavejester(routes {:uri "/test.js", :scheme :http, :request-method :get, :headers {"host" "localhost"}})
15:25tmciverweavejester: 404
15:26TimMcantares_: ping
15:26antares_TimMc: pong
15:26TimMcMail for you!
15:26weavejestertmciver: Innnnnteresting…
15:26TimMclazymail
15:26weavejestertmciver: Try cutting out all the routes except for the files route and the not-found route?
15:26tmciverweavejester: I'd love to tell you that I'm doing something strange, but I don't think so.
15:27weavejestertmciver: Then if that works, add the other routes back in until the 404 appears
15:27antares_TimMc: I see no new emails. Or is it this IRC/lazybot mail thing? I don't know how to use it :)
15:27antares_lazybot: lazymail
15:28antares_clojurebot: lazymail
15:28clojurebotNo entiendo
15:28TimMcYeah, I don't know how to use it either. :-P
15:28antares_clojurebot: mail
15:28clojurebotif you can access the email account that is signed up then you winn
15:28TimMcAnyway, the seqs-and-colls repo is dual-licensed compatibly with clojure-doc now.
15:28antares_TimMc: ah, nice
15:28tmciverweavejester: 404 still. :(
15:29TimMc$mail TimMc test
15:29lazybotMessage saved.
15:29antares_I am finishing dinner and going to work on namespaces and collections/sequences guides
15:29antares_TimMc: thank you
15:29TimMclazybot: Mail for me?
15:29weavejestertmciver: Hm...
15:29tmciverweavejester: I've got (route/resources "/") for the static files route.
15:29weavejestertmciver: Oh! You switched?
15:29TimMcantares_: "/msg lazybot mail" seems to be the thing
15:30weavejestertmciver: If you're going with resources, the directory changes to "resources/public"
15:30antares_does lazybot use /dev/null for mail? :)
15:30antares_ah, cool
15:30antares_thanks TimMc
15:30tmciverweavejester: so my test.js file should be in 'resources/public'?
15:31weavejestertmciver: If you're using resources. If you're using files, it can be in 'public'
15:31tmciverweavejester: OK, went back to files and it seems to work with the other routes commented out.
15:31tmciverfrom the repl
15:32weavejestertmciver: Okay, try adding all the other routes back and trying it from the REPL again
15:32HodappI read "REPL again" as "Republican". I eagerly await election season in the US being over.
15:33TimMcI, too, need new glasses.
15:33TimMcI read "electron season".
15:34weavejesterHodapp: Now I need to resist jokes about functions that return different results for the same arguments...
15:34tmciverweavejester: yeah, seems to work from the repl now with all the routes, but not from a browser. I'm baffled.
15:34ToBeReplacedi'm getting confused with the information out there regarding SLIME/swank-clojure/nREPL >> i can't figure out what the intended use is now that swank-clojure is deprecated >> am i supposed to "lein repl" then "M-x nrepl" to it from emacs?
15:35weavejestertmciver: Well, we can peek at the request map being passed in with some middleware
15:35weavejestertmciver: (defn wrap-prn [h] (fn [r] (prn r) (h r)))
15:36tmciverweavejester: OK, I'll try that. Let me get back to you with the result; got to go do my 'real' work :(
15:38Somelauwjcromartie: Aren't all irc clients textual?
16:09TimMc,alive?
16:09clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: alive? in this context, compiling:(NO_SOURCE_PATH:0)>
16:10ddeaguiar,(doc alive?)
16:10clojurebotGabh mo leithscéal?
16:10ddeaguiarhm
16:10fractaloopWTF?
16:11ddeaguiarwhat was that..
16:11Somelauw,dead?
16:11clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: dead? in this context, compiling:(NO_SOURCE_PATH:0)>
16:11TimMcI was just checking if clojurebot was back.
16:11ddeaguiaro
16:14jcromartiewas clojurebot speaking Gaelic?
16:15scriptormost clojure devs speak Irish, didn't you know?
16:15fractaloop....
16:16devthanyone know an up-to-date reference on clojure.data.zip.xml? most results are for old contrib and don't work anymore.
16:24Somelauwcan all languages be implemented as a macro in clojure?
16:24Somelauwis there prolog?
16:25emezeskeSomelauw: You might be interested in core.logic
16:26Somelauwit's even in the core
16:29technomancyToBeReplaced: M-x nrepl-jack-in is the way to go. if you have slime set up and working you can keep using it though; it's not going away
16:30ToBeReplacedtechnomancy: thanks >> i was missing the prefix argument to make it more awesome
16:33ToBeReplacedtechnomancy: this page needs editing to match the current state of the world if you're feeling generous; i'm not signed up yet >> http://dev.clojure.org/display/doc/Getting+Started+with+Emacs
16:36AtKaaZhow can I see all fields/methods of a class? which is like of this type: clojure.core$future_call$reify__3499
16:37AtKaaZin an attempt to get the difference between java's Future, clojure's future and @future
16:38antares_AtKaaZ: do you need to use it from Java? Why would you need to instapect methods on a future implementation?
16:38AtKaaZ,(def f (future (Thread/sleep 1000) nil )) (cancel-future f) f
16:38antares_@future is the same as (deref future), which basically calls #deref on it
16:38clojurebot#<Exception java.lang.Exception: SANBOX DENIED>
16:38AtKaaZok but what is the underef-ed future supposed to be?
16:38antares_you can treat Clojure futures as Java futures if you need to.
16:39AtKaaZtrue I tested that a bit
16:39antares_just like j.u.c. future, it is a reference to a value that may or may not be available
16:39antares_if you call #get on it, it will block the current thread until it is available
16:40AtKaaZok, in other words it also knows if it's pending, completed or cancelled?
16:40AtKaaZif it were cancelled what would f and @f look like?
16:40AtKaaZit seems to me that @f should throw, but maybe f shouldn't?
16:41antares_AtKaaZ: and what should it do then?
16:41AtKaaZbut since f also shows the @f then it should throw also , I don't know:)
16:41antares_if it is cancelled, you never will get the value it is supposed to reference
16:41AtKaaZyes I agree
16:42AtKaaZso when you try showing f, you also invoke @f if the future is done ?
16:42AtKaaZor even if it's cancelled? in an attempt to show all
16:43AtKaaZif the future is pending, showing f shows #<core$future_call$reify__3499@7c9391d9: :pending>
16:43AtKaaZbut if it's cancelled shouldn't it show cancelled?
16:43AtKaaZyet it thows instead
16:43AtKaaZbut @f should definitely throw in this case
16:43reactormonkI have a bit of an idea of lisp, what do I start with for closure?
16:43hiredmanwell, getting the name right helps with googling
16:44brehautAtKaaZ: have you done a (source future-call) ?
16:44TimMcreactormonk: Are you asking how to get started developing in Clojure?
16:44reactormonkTimMc, exactly
16:44reactormonkexcept I might call it coding
16:44TimMcSure.
16:45TimMcGrab Leiningen and you can get a REPL that way (and set up projects, etc.)
16:45reactormonkI'd like to use emacs
16:45pandeirois using aget to retrieve dynamically resolved javascript object property names a bad approach?
16:46reactormonkTimMc, oh, nice
16:46TimMcreactormonk: I generally write in Emacs (with clojure-mode and paredit) and use lein for the REPL, so I'm the wrong person to ask. :-)
16:46AtKaaZbrehaut: I have now but can't pretend to understand :) btw, I only asked because someone reported it on clojure ML
16:46_ulisesreactormonk: you can use nrepl for that
16:47reactormonkTimMc, sounds like the way I'd do it
16:48AtKaaZbrehaut, but thanks that is actually what I wanted to know, methods/fields
16:48jweissi have an apparently large datastructure in memory (not so large that i'm almost out of heap space - set to 1G and taking up 500mb). but i can't figure out how to dump this to disk without going OOM. spit won't do it. nor will any prn/print variant. any suggestions?
16:48patchworkIs there any way to tell lein to start up without checking the net for deps?
16:49patchworktrying to use lein sometimes when I don't have a connection
16:49patchworkand it just hangs
16:49technomancypatchwork: sure; `lein -o whatever`
16:49ChongLiI'm having a weird issue with nrepl
16:49ChongLiit's adding a bunch of newlines whenever I press enter at the repl
16:50reactormonkTimMc, I ♥ paredit. I even edit syntax trees for linguistics with it :-)
16:50patchworktechnomancy: Thanks!
16:50ChongLicausing my history entries to be full of newlines that I have to delete in order to read the entries
16:50ChongLidoes this happen to anyone else?
16:50technomancypatchwork: that will remove other profiles, so if you want dev/user etc you may be better off with `lein with-profile offline,user,dev,default repl`
16:54aperiodicjweiss: maybe try a doseq? won't be a printable form unless you do some work, but seems worth a shot
16:54aperiodics/printable/readable
16:55jweissaperiodic: interesting, might work. i just don't get why the various print functions gobble up so much memory
16:56jweissway more than the original data takes up in heap space.
16:56aperiodicjweiss: they probably build up the entire string for the datastructure before dumping it to disk
16:59aperiodichmm, reading in the result might cause problems too, if your plan is to gobble the whole thing up and call read-string
17:00jweissaperiodic: i don't need to read it back. problem is probably some loop out of control adding too much data, i should be able to tell if i can just look at it.
17:03jweissah appears to be a function that produces infinite seq that i accidentally traced. woops.
17:09tickinghmm I was wondering what is the best way to check if a potentially infinite list has still 2 elements?
17:10ticking(if-let [sec (second myseq)] foo) seems flawed because of data transparency considering nil
17:11technomancyticking: (get (into [] (take 2 my-vec)) 2 :not-found) I guess?
17:11technomancyrather: (count (take 2 my-seq))
17:11amalloy(nnext my-seq)
17:12amalloyor just next, i guess, since you only want to check for two. that checks for three
17:12tickingright
17:12amalloy&(map next [[] [1] [1 2] [1 2 3]])
17:12lazybot⇒ (nil nil (2) (2 3))
17:12tickingyeah makes sense thanks ^^
17:13AtKaaZ,(nnext (range))
17:13clojurebot(2 3 4 5 6 ...)
17:13ticking'(empty (next [1]))
17:13ticking,(empty (next [1]))
17:13clojurebotnil
17:14tickingright yeah thanks ^^
17:15amalloyticking: don't call (empty) on the result. that's a disaster
17:15tickingah right because it already returns nil if it is empty
17:16tickingamalloy, also I meant empty? ^^
17:16amalloyticking: but don't use empty? either, because there's no reason
17:16tickingright
17:17AtKaaZ,(next [1])
17:17clojurebotnil
17:17AtKaaZ,(next [1 2])
17:17clojurebot(2)
17:17AtKaaZ,(next [1 2 3])
17:17clojurebot(2 3)
17:17AtKaaZ,(next [])
17:17clojurebotnil
17:17AtKaaZnice
17:18AtKaaZ,(empty? nil)
17:18clojurebottrue
17:18AtKaaZamalloy, why not?
17:19amalloydid you read the part where i said why not?
17:19AtKaaZbecause there is no reason?
17:19tickingAtKaaZ, if and most if like constructs test for nil non nil as well as true false
17:19amalloyyes
17:19tickingnil is falsy and non nil is thuthy
17:19AtKaaZoh right, thank you for that
17:21callenamalloy: how long did it take you to solve all those 4clojure problems?
17:22amalloy*shrug*
17:22callenamalloy: don't want to sound smug, or don't want to recollect all that time you'd spent?
17:24mattmossWhat's wrong with empty?
17:24brehaut~empty?
17:24clojurebotempty is amalloy: therfor I return [previous] if rest
17:27AtKaaZmattmoss, well I was trying to use empty? to map nil to false and non-empty to true, but if-like constructs already do this mapping (so to speak)
17:27mattmossoh, I thought amalloy (or whoever it was) was saying something like "never use empty?"
17:28mattmossbut right, no need for empty in that situation
17:28duck1123don't use empty?. reverse the clauses and use seq
17:28technomancyugh no
17:28technomancyempty? is an actual english word
17:28mattmossduck1123: empty? already uses seq. And I prefer positive checks where possible.
17:28technomancyso much more readable
17:28tmciverweavejester: from earlier: here's the request map when I try to get a js file through the browser: https://www.refheap.com/paste/5732
17:29mattmossAnd what technomancy said.
17:30weavejestertmciver: You could try passing that map (minus the body inputstream) to your routes to see what happens
17:30AtKaaZactually I correct myself, when I said non-empty I meant non-nil :)
17:31duck1123my point was, I'd rather see (if (seq x) :foo :bar) than (if (empty? x) :bar :foo) but that's mostly because I tend to find the non-empty case to be more interesting
17:32tickingduck1123, I'd argue to use it so that it complements documentation, if the empty case is the one you want to emphasize use that otherwise don't
17:32AtKaaZyeah that would make it more readable for newbz like I
17:36tmciverweavejester: Ugh, I got it working. It seems to be a problem with a middleware I tried wrote that alters the 'accept' header depending on the extension of the resource in the URL. Doh!
17:37tmciverweavejester: thanks for bearing with me.
17:54weavejestertmciver: No problem - glad you got it sorted out.
18:30devthsuggestions on how to turn [{:g 1, :v "foo"} {:v "bar"} {:v "qux"} {:g 2, :v "baz"} {:v "quux"}] into {:1 ["bar" "qux"], :2 ["quux"]} ?
18:30devthsorry, wrong structure, let me try that again
18:30devth[{:g 1} {:v "bar"} {:v "qux"} {:g 2} {:v "quux"}] to {:1 ["bar" "qux"], :2 ["quux"]}
18:33arrdem,(doc zipmap)
18:33clojurebot"([keys vals]); Returns a map with the keys mapped to the corresponding vals."
18:33arrdemso (zipmap (map :g datastructures) (map vals datastructures))
18:35devththanks, trying that.
18:36jamiiNow with real documentation - https://github.com/jamii/strucjure#examples
18:37devtharrdem: that's close but there are a different number of keys and values, so i get nil keys. i'll keep playing w/ it tho. thanks.
18:39devthreduce might actually be what i need.
19:30wingythis test is passing since i mock the http/post with with-redefs https://gist.github.com/3876287
19:30wingyi wonder how/why to use with-redefs-fn .. there is no example in the doc for it
19:31wingywhat is the difference
19:34amalloydevth: https://gist.github.com/0864360312f804c37cd9
19:35devthamalloy: wow, nice. thanks, i was still messing around with a really nasty reduce / update-in mess
19:35emezeskewingy: with-redefs-fn is a function instead of a macro, so it might be useful for things like e.g. generating test input data on the fly
19:36emezeskewingy: That is, it might be useful when you don't know what the bindings will be at compile-time
19:36arrdemherm... anyone know how to access the com.mongodb.ObjectId constructor in Congomongo?
19:36amalloyinto/for solves an awful lot of problems that would otherwise require a hairy reduce
19:36wingyemezeske: i c
19:36wingyso if i know i might as well use with-redefs?
19:37emezeskewingy: with-redefs is probably more convenient most of the time
19:37emezeskewingy: Since you can just pass an arbitrary body to it, instead of a function to run
19:37wingyemezeske: i c
19:38wingyyeah since its a fn i have to wrap the expression inside a callback
19:38wingyalso i cant use bindings in a fn right?
19:38wingyso i have to provide a map
19:40wingyemezeske: https://gist.github.com/3876287
19:41wingypretty straightforward
19:41wingyi should probably add the example with with-redefs-fn to do?
19:41wingydoc
19:42emezeskeI thought the docs for with-redefs-fn were pretty explanatory, but I guess an example never hurt anyone
19:43wingyno examples
19:45wingyhttp://clojuredocs.org/clojure_core/clojure.core/with-redefs-fn
19:45wingysince the doc says its used for mocking during testing i added a test oriented example
19:45emezeskeSeems reasonable.
20:01gertis there a recommended way to run tests on clojurescript code?
20:01dnolengert: not really.
20:03emezeskegert: Webapp?
20:04gertemezeske: I'm writing ring-like chaining on the client side and would like to write tests for my code
20:05emezeskegert: So, yes?
20:05gertI suppose so yes :)
20:05emezeskegert: :P
20:05gertI'm looking at Clojurescript One's one.test atm
20:05emezeskegert: For that, I write a bunch of cljs functions that just use assert, and run the tests in PhantomJS
20:06gertthat's a good idea - and possibly more lightweight than one.test
20:06emezeskeI've been meaning to look at this too: https://github.com/kumarshantanu/clip-test
20:07emezeskeSeems very promising.
20:07gertit does!
20:07gertI'm going to check that out. cheers!
20:13wingyhow do i check if an id exists in datomic
20:13wingy(q '[:find ?id :in $ ?id :where [?id _ _]] (db conn) id)
20:15wingydidn't work and threw no error
20:15AtKaaZshould've worked
20:15AtKaaZbut you also don't have to specify the _ _
20:15wingyperhaps ?id cannot be the same as the ?id passed in
20:16AtKaaZthis might be relevant: https://groups.google.com/forum/?fromgroups=#!topic/datomic/rJxgqnI4hz0
20:19wingyit worked now
20:19wingyi passed a string as an id :[
20:19AtKaaZoh
20:19wingyshould be converted to a long
20:19AtKaaZyep, reminds me of yesterday:)
20:19wingyyeah
20:20wingycant clojure implement static typing!
20:20wingysaves so much manual checking
20:20AtKaaZit's curious however that the entity id exists even without any attributes... I've yet to test that out
20:21AtKaaZ"stated another way, having no attributes is as nonexistent as an entity can be." -Stu
20:21wingyi think the attrs exists
20:21wingybut you arent quering them
20:21wingy[?id]
20:21wingythe same as [?id _ _]
20:22AtKaaZhow can I delete erm retract an entity with a specific id?
20:23AtKaaZok I guess like so: @(d/transact conn [[:db.fn/retractEntity easton-id]])
20:24AtKaaZyep the two are the same: [?id] or [?id _ _] same result
20:35tomojshould java.util.Set etc be added to pprint's dispatch?
20:36tomoj..bit bothersome that the HashSets datomic returns don't pprint. of course (comp pprint set) works
20:43AtKaaZdoesn't seem to work ?
20:44AtKaaZworks, my set was just empty
20:50emezesketomoj: Could you maybe define a pprint multimethod for datomic sets?
20:50tomojwell they're just HashSets
20:51tomojbut yeah
20:51tomojwondering why pprint shouldn't do that
20:56ChongLihmmm
20:57ChongLithis new version of ac-nrepl or nrepl is adding a lot of latency to my keystrokes
20:57ChongLiI have no idea how to figure diagnose this
21:11Sgeo,(-> 10 [1 2 3])
21:11clojurebot#<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException>
21:11SgeoWell, that's an interesting way to fail
21:13TimMc&(macroexpand-1 '(-> 10 [1 2 3]))
21:13lazybot⇒ ([1 2 3] 10)
21:13AtKaaZwhat was it supposed to do?
21:13emezeskeSgeo: Interesting? Isn't that what you'd expect?
21:13Sgeoemezeske, I expected some kind of error
21:13SgeoBut wasn't sure what kind
21:14emezeskeIndexOutOfBounds seems pretty reasonable and uninteresting to me :)
21:14TimMc,(-> 1 [:a :b :c])
21:14clojurebot:b
21:14AtKaaZhow would you add that 10 to that vector, using the same construct
21:15TimMcYou wouldn't.
21:15AtKaaZ,(-> 10 (cons [1 2 3]))
21:15Sgeoemezeske, I was wondering if it would try to insert into the vector or something
21:15clojurebot(10 1 2 3)
21:15Sgeo,(macroexpand-1 '(-> 10 (1 2 3)))
21:15clojurebot(1 10 2 3)
21:15Iceland_jackevil..
21:15AtKaaZlol
21:15TimMc,(macroexpand-1 '(-> 10 '(1 2 3)))
21:15clojurebot(quote 10 (1 2 3))
21:16AtKaaZthat was pretty epic with macroexpand
21:17amalloy&(-> 10 (1 2 3) quote)
21:17TimMc,(-> 10 '(don't mind me))
21:17clojurebot10
21:17lazybot⇒ (1 10 2 3)
21:17TimMc((juxt inc dec) amalloy)
21:17amalloyhah
21:18AtKaaZlol
21:18TimMcI can't believe mine worked.
21:18AtKaaZwhy not?
21:18TimMc,(quote 1 2 3 4)
21:18clojurebot1
21:18amalloyTimMc: you've made the comment macro obsolete
21:18TimMc:-D
21:19amalloywell, i guess not. since it quotes
21:19AtKaaZ,(->> 10 '(don't mind me))
21:19clojurebot(don't mind me)
21:19amalloy&(-> (+ 1 2) '(comment whatever))
21:19lazybot⇒ (+ 1 2)
21:20TimMcGood for obfuscated code.
21:20AtKaaZ,(macroexpand '(-> (+ 1 2) '(comment whatever)))
21:20clojurebot(quote (+ 1 2) (comment whatever))
21:20AtKaaZmakes sense ##('(1 2) 3)
21:20lazybotjava.lang.ClassCastException: clojure.lang.PersistentList cannot be cast to clojure.lang.IFn
21:20AtKaaZto not believe :)
21:21AtKaaZ,(macroexpand '('(1 2) 3))
21:21clojurebot((quote (1 2)) 3)
21:50SgeoHow long do the Incanter unit tests usually take?
21:50SgeoI'm planning on making a minor change to Incanter
21:50SgeoNot one that should be API visible though
21:52SgeoI still don't like the thought of making a new project each time I want to use some library from the REPl
21:52SgeoREPL
21:52tomojyou could add pomegranate to your user profile
21:53SgeoHmm
21:53tomojthe example in the readme is actually incanter..
21:53jcromartiewhat about an option for lein repl?
21:54tomojI've thought it'd be nice to have repl-in
21:54tomoj`lein repl-in incanter` ?
21:55SgeoHaving to merge with clojars seems annoying
21:55SgeoErm, manually specifying the repositories like that
21:55tomojso write a helper
22:00ohpauleez$(doc find-fn)
22:00ohpauleez,(doc find-fn)
22:00clojurebotI don't understand.
22:01ohpauleez$find-fn
22:03TimMc$findfn 2 3 5
22:03lazybot[clojure.core/+ clojure.core/unchecked-add clojure.core/+' clojure.core/unchecked-add-int]
22:03TimMcslobot
22:03ohpauleezthank you TimMc
22:04ohpauleez$findfn [1 2 3 4] ((1 2)(3 4))
22:04lazybotjava.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn
22:04ohpauleez$findfn [1 2 3 4] '((1 2)(3 4))
22:04lazybot[]
22:05TimMcpartition 2?
22:05ohpauleezTHANK YOU!
22:05TimMchaha, np
22:05ohpauleezI was drawing a blank, "step, group, grab"
22:05ohpauleezit was killing me
22:12AtKaaZ$findfn {:a 1} {:a 2} {:a 3}
22:12lazybot[]
22:18TimMctechnomancy: I think I'm getting pretty close to having a working lein2 version of lein-otf -- the trouble now is to get lein-otf into the dependencies list of the target project!
22:18TimMc"Who am I" is always a hard thing to solve.
22:20TimMcIs there some way I can ask what version of a dependency is in use?
22:21Sgeo$findfn {:a 1} [:a]
22:22lazybot[clojure.core/keys]
22:22SgeoCool
22:22AtKaaZ $findfn {:a 1} [1]
22:23AtKaaZthat space:)
22:24AtKaaZTimMc, from inside a lein plugin?
22:24TimMcYep.
22:25TimMcAtKaaZ: This plugin needs to add itself to the :dependencies listing of the project it is run in.
22:25AtKaaZso this is not needed? Specify the plugin as a development dependency: :dev-dependencies [[org.timmc/lein-otf "1.1.0"]]
22:26AtKaaZoh wait, I assumed it's already added in profiles.clj
22:26AtKaaZactually, I don't know what I'm talking about lol
22:29SgeoWhat's a higher priority, fixing a theoretical but unlikely race condition in Incanter, or doing something cool
22:29AtKaaZthe latter, but not in my view:)
22:30amalloyTimMc: i don't think so, aside from looking through the project.clj to find yourself in the plugins list. but i'm definitely not a lein dev, so take that with a grain of salt
22:33AtKaaZTimMc, I failed to follow the Usage, getting: uberjar-otf is not a task. Use "lein help" to list all tasks.
22:34AtKaaZor maybe the part with "Get the plugin" is implied?
22:37wingyhey
22:37wingywhat is the best way to handle something unexpected in clj
22:38wingyi did (throw (Exception.)) but my compojure server is still running and nothing was logged in console
22:39SgeoWhat's the difference between (ensure someref) and (deref someref) in a transaction?
22:39amalloySgeo: very subtle, whatever it is
22:40TimMcLooking through :plugins *works*, although I'm not sure that will always work.
22:40AtKaaZ,(throw (Exception. "boo"))
22:40clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.Exception: boo>
22:40AtKaaZ,(pst)
22:40clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable>
22:40AtKaaZ,(pst)
22:40clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable>
22:40TimMcSgeo: The question is really: What's the difference between (ensure foo) and (ref-set foo @foo)?
22:41SgeoTimMc, what's the difference between (ref-set foo @foo) and @foo
22:41TimMcAtKaaZ: "Specify the plugin as a development dependency: ..."
22:41AtKaaZTimMc, I definitely did that
22:42AtKaaZin project.clj
22:42TimMcAre you using lein1 or lein2?
22:42AtKaaZ2
22:42TimMcThere's your problem.
22:42AtKaaZah, sorry, I kinda just realized
22:42TimMclein-otf isn't ready for lein 2.x yet.
22:43TimMcso the usage instructions haven't been updated for that.
22:43AtKaaZcan say it's for lein1 maybe
22:45TimMcOh! I thought I did. Let me fix that...
22:48TimMcBad connection, I'll do it tomorrow. Go'night.
22:48SgeoUm.
22:48SgeoDoes ensure just change the timing of things, or does it actually have a semantic effect on correctness?
22:49amalloySgeo: my understanding is that it affects correctness in certain unusual algorithms
22:49amalloybut tbh i've never gotten a grasp on ensure
22:49TimMcwrite-skew
22:49AtKaaZTimMc, bad RAM too "Go'night." :))
22:50AtKaaZ,(doc ensure)
22:50clojurebot"([ref]); Must be called in a transaction. Protects the ref from modification by other transactions. Returns the in-transaction-value of ref. Allows for more concurrency than (ref-set ref @ref)"
22:50AtKaaZ,(doc ref-set)
22:50clojurebot"([ref val]); Must be called in a transaction. Sets the value of ref. Returns val."
22:50TimMcAtKaaZ: too much lag for backspace to be useful
22:50SgeoBut my understanding is that with deref in a transaction, the transaction should not see an outside transaction change the ref
22:51TimMcensure is only intended to be used when you are reading the ref somewhere else in teh xaction.
22:53SgeoTimMc, but shouldn't reading the ref itself ensure that the transaction will restart if anything else tries to write it?
23:00jcromartiewhen I use a certain fn to paint a JPanel, I see output from prn, etc., but I don't see exception messages
23:00jcromartiein the SLIME REPL
23:00jcromartiehow can I see those?
23:00AtKaaZmaybe (pst) ?
23:05jcromartieno, (pst) doesn't see the exception from the AWT thread
23:05Sgeo,(doc pst)
23:05clojurebot"([] [e-or-depth] [e depth]); Prints a stack trace of the exception, to the depth requested. If none supplied, uses the root cause of the most recent repl exception (*e), and a depth of 12."
23:05AtKaaZmaybe you can call it on AWT?
23:05SgeoAre those any more understandable than Java stack traces?
23:05AtKaaZthread
23:08jcromartietrying from lein repl instead of SLIME
23:09AtKaaZsomething with javax.swing.SwingUtilities/invokeLater but I don't know how to exactly pass that Runnable
23:10jcromartieyeah, in the plain lein repl it shows up
23:10jcromartiebut not in SLIME
23:10jcromartieseems like a swank bug?
23:10jcromartieI've seen this in other things too
23:10jcromartielike running a ring jetty server
23:12AtKaaZhow did you call it? I'm failing :) ##(javax.swing.SwingUtilities/invokeLater ^Runnable ((pst)) )
23:12lazybotjava.lang.RuntimeException: Unable to resolve symbol: pst in this context
23:12AtKaaZ,(javax.swing.SwingUtilities/invokeLater ^Runnable ((pst)) )
23:12clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.Var$Unbound cannot be cast to java.lang.Throwable>
23:13jcromartiehm
23:14AtKaaZjcromartie, I mean, how did you call (pst) on AWT thread?
23:14jcromartieI didn't
23:14AtKaaZfrom repl?
23:14jcromartieI'm saying that I just see exception stack traces
23:14jcromartiefrom the repl
23:14jcromartiebut not the SLIME repl
23:14AtKaaZoh
23:14jcromartiejust when I run it with "lein repl"
23:16AtKaaZ,(javax.swing.SwingUtilities/invokeLater #(pst))
23:16clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.ExceptionInInitializerError>
23:17jcromartiedoesn't seem to work, AtKaaZ
23:17jcromartiejust tried it
23:17AtKaaZnot even sure I'm doing it right though
23:17jcromartie(defmacro g-do [& forms] `(SwingUtilities/invokeLater #(do ~@forms)))
23:17jcromartieseems to work except for printing exceptions
23:18AtKaaZ,(javax.swing.SwingUtilities/invokeLater (fn [] (println *ns*)))
23:18clojurebot#<RuntimeException java.lang.RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit>
23:18jcromartieyeah don't count on clojurebot doing Swing
23:18AtKaaZlol
23:18jcromartieclojurebot doesn't Swing that way ;)
23:18AtKaaZmaybe can use binding to reditect stderr?
23:20AtKaaZI'm curious how you'd do that, my noobish tried isn't doing anything: (g-do (binding [*err* *out*] (pst)) )
23:21jcromartieI don't think there's anyway to bind *err* to *out* across threads
23:21jcromartieis there?
23:21jcromartiethat's the trick
23:22jcromartiemaybe let
23:22AtKaaZi don't know if across threads, I only tried on same thread
23:23Sgeoalter-var?
23:23Sgeo,(doc alter-var)
23:23clojurebotGabh mo leithscéal?
23:23Sgeo,(doc alter-var-root)
23:23clojurebot"([v f & args]); Atomically alters the root binding of var v by applying f to its current value plus any args"
23:23jcromartielet over lambda :)
23:23xeqi(doc bound-fn)
23:23clojurebot"([& fntail]); Returns a function defined by the given fntail, which will install the same bindings in effect as in the thread at the time bound-fn was called. This may be used to define a helper function which runs on a different thread, but needs the same bindings in place."
23:24jcromartieI don't think (pst) works on the current thread
23:26jcromartie(pst) uses *e, which is only for the REPL thread
23:26jcromartieso
23:27jcromartieI need to catch and print the stack trace myself
23:27AtKaaZhow do you do that?
23:28jcromartie(g-do (try (/ 1 0) (catch Exception e (pst e))))
23:28jcromartiejust to illustrate
23:28jcromartiebut yeah, just try/catch
23:28AtKaaZcool thanks
23:28jcromartienot hard at all but not what I'm used to in Clojure :)
23:43Sgeo,(-> #'reify meta :added)
23:43clojurebot"1.2"
23:43Sgeo:/
23:43Sgeohttp://lispetc.posterous.com/hello-jwt-from-clojure
23:43SgeoThis code uses a macro to produce a proxy. Wouldn't reify work better without needing the macrology?
23:50JvJa
23:50JvJhey does anyone in here use penumbra?
23:53AtKaaZJvJ, I may want to use it eventually unless there's something better, but not currently using it.
23:54JvJAtKaaZ, Just wondering. I'm having some diffuculty using penumbra with my lein projects, and wanted to know if anyone had similar problems.
23:55AtKaaZJvJ: which fork are you using?
23:56AtKaaZJvJ, just wondering if you saw the ML
23:56JvJAtKaaz. What do you mean ML?
23:56AtKaaZmailing list for clojure
23:56JvJoh, I don't think I have
23:57AtKaaZyour dependency: [prismofeverything/penumbra "0.6.9"]]) maybe try just [penumbra "0.6.9"] or later version
23:57AtKaaZhmm actually 0.6.0 I notice it's on https://github.com/ztellman/penumbra/blob/master/project.clj
23:57JvJyeah, I've tried 0.6.0 and 0.6.9
23:59gert_emezeske: in a leiningen test profile I have a :cljsbuild > :compiler > :source-path "test-cljs" entry; this has a .cljs file with asserts in it, but how would it find my main "cljs" source path?