#clojure logs

2011-09-28

00:00technomancyhahaha http://wondermark.com/302/
00:00technomancyspeaking of confusing the crap out
00:02j941 (
00:02j941 (juxt #((map count ) ))
00:02j941is returning nothing (i.e. its not executing )
00:03j941(its in a larger context, of course.
00:03brehaut&((juxt #(map count %)) [1 2 3])
00:03lazybotjava.lang.UnsupportedOperationException: count not supported on this type: Integer
00:03brehauterr
00:03brehaut&((juxt #(map count %)) [[1 2 3] [2 3]])
00:03lazybot⇒ [(3 2)]
00:04brehautthats the closest i can work out that you might have meant
00:04brehautand juxt on a single functions is perhaps not the most useful thing ever
00:04technomancywow and this one is like basically a metaphor for emacs: http://wondermark.com/664/
00:04j941well.. im planning on adding more
00:04j941:)
00:05zerokarmaleftheh
00:05dnolentechnomancy: haha
00:05brehautahaha
00:06j941ok here
00:06j941http://pastebin.com/SA184uLy
00:06j941its odd, returning one of those cryptic #(ss_sss11_->cl_2_Z looking things.
00:06brehautj941: (require '[clojure.string :as str]) is quite nice too btw; eg str/join str/split
00:07j941oh yeah i gotta do that
00:07Apage43j941: juxt returns a closure
00:07j941im tired of importing methods
00:07Apage43more parens.
00:07j941whats wrong with a closure?
00:07brehautj941: you're a fan of C family languages?
00:07Apage43nothing
00:07Apage43you just have to actually call it
00:07zerokarmalefttechnomancy: dammit, this is a rabbit hole i don't need right now
00:07Apage43((juxt fn1 fn2) val)
00:07j941yeah especially when debuggin
00:08j941o ok
00:08technomancyzerokarmaleft: what, you haven't discovered wondermark? I must say I envy you; so much to look forward to!
00:08technomancyclojurebot: piranhamoose?
00:08clojurebotpiranhamoose is unadulterated awesome: http://blog.howfastareyou.net/wp-content/uploads/2009/08/piranhamoose.jpg
00:09technomancyclojurebot: absolut botsnack
00:09clojurebotforget botsnack is Thanks! Can I have chocolate next time
00:09carkmhh is it possible to "override" protected methods or not with proxy ?
00:09j941beautiful ! it worx!
00:09technomancyclojurebot: forget forget botsnack |is| Thanks! Can I have chocolate next time
00:09clojurebotI forgot that forget botsnack is Thanks! Can I have chocolate next time
00:10technomancyyou're going to blow your stack one of these days, I'm telling you
00:10brehauthes already pretty garbled since i did some apparently nafarious (use … earlier
00:10brehaut,(inc 1)
00:10clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
00:11technomancyheh
00:12brehautim going to blame arrows again
00:14j941so we can map a list into a map ?
00:14j941btw im gonna thank you guys on my thesis. this is the last table for my phd thesis !
00:15j941tryin to go [1 2 3] -> {:a 1 :b 2 :c 3)
00:15brehautj941: how do you mean?
00:15amalloy&(zipmap [:a :b :c] [1 2 3])?
00:15lazybot⇒ {:c 3, :b 2, :a 1}
00:15brehaut,(zipmap [:a :b :c] [1 2 3])
00:15clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox>
00:15j941oh awesome
00:15amalloybrehaut: irc.freenode.WrongBotException
00:16brehaut(dec brehaut)
00:16lazybotYou can't adjust your own karma.
00:16amalloy(dec clojurebot)
00:16lazybot⟹ 1
00:16brehautlol
00:17amalloybrehaut: did i tell you, when i was writing http://4clojure.com/problem/107 i got jealous of haskell again? just write a function of two args, don't worry about this manual currying nonsense
00:17brehautits easy to get jealous of haskell
00:17brehaut(from a distance anyway)
00:17amalloy*nod* that's why i never use is
00:18j941so... from a distance... what do the haskell tempations lead to?
00:18brehautj941: jenga towers of monads
00:18nappingwhat's hard about a curried function of two arguments?
00:18j941monads ?
00:19j941i thought those were okay
00:19amalloynapping: nothing is, really
00:19brehautthey are powerful and useful
00:19j941everyone talks about em like they are gods gift to programers
00:19j941ok ... but...
00:19nappingeveryone talks like people talk like they are god's gift to programmers
00:19brehautbut, if you have to stack them high, things get unwiedly
00:20amalloyit's just (fn foo [a b] ...) instead of (fn foo [a] (fn [b] ...))
00:20amalloysimpler
00:20j941like objects in java
00:20nappingaren't there macros for that?
00:20amalloy*shrug* you can write them
00:20j941does zipmap destructure for you ?
00:20amalloybut it doesn't actually simplify the code much since you have to specify # args
00:21brehauti need to find time do some 4clojure stuff
00:22nappingyou've seen the Racket syntax?
00:22alandipertonce you're hooked, the time will find you
00:22j941brehaut sounds like u do plenty of clojure
00:22brehautj941: not really, i dabble in my spare time
00:22j941really how u know it so well.
00:23j941oh oops i saw 4clojure, not clojure.
00:23brehauttheres a bunch of people in this channel who would probably laugh at that assessment
00:23j941not me
00:23nappinghttp://docs.racket-lang.org/guide/define.html
00:24napping(defn [[f x] y] body), basically
00:24j941(->> (map #(clojure.string/split % #"_"))) (->> zipmap [:a :b] )
00:24nappingdoesn't work so nicely with (defn name [params*] ...)
00:25j941ClassCastException
00:25j941was hoping the list would get destructured into the first two keys
00:31brehaut&(let [lines (map #(clojure.string/split % #"_") ["1_2" "b_c" "3_4"])] (map (partial zipmap [:a :b]) lines))
00:31lazybot⇒ ({:b "2", :a "1"} {:b "c", :a "b"} {:b "4", :a "3"})
00:32brehautno need to go threading macro happy ;)
00:32j941o ok
00:33j941i am threading obsessesd
00:33brehautif you did, it would be ##((->> ["1_2" "b_c" "3_4"] (map #(clojure.string/split % #"_")) (map (partial zipmap [:a :b])))
00:33brehautblast
00:33brehaut&(->> ["1_2" "b_c" "3_4"] (map #(clojure.string/split % #"_")) (map (partial zipmap [:a :b])))
00:33lazybot⇒ ({:b "2", :a "1"} {:b "c", :a "b"} {:b "4", :a "3"})
00:33brehautamalloy: whats lazybots inline eval symbol?
00:34j941threading is like pipes. and i like the feeling of "history | grep 'ls'
00:34amalloy##
00:34amalloybut you have to have a well-formed sexp :P
00:34nappingis it safe to do (for [x @my-ref] body) in a dosync?
00:34j941so can i persist a list by just doing (def a ll) if ll is a function?
00:35brehautamalloy: oh haha :)
00:35j941nope
00:35clojurebotI don't understand.
00:35j941(def a (ll))
00:35dnolennappy: laziness in a dosync is probably not a good idea
00:35j941that does it. wanted to store my list in memory
00:35dnolennapping: oops, sorry mistyped.
00:36nappingLaziness is what I was worried about
00:37amalloywell, everything is "safe" depending on what behavior you want
00:38nappingI want the ref lookup to happen in the transaction, and then filtering to happen sometime
00:40Apage43i suspect that form will work
00:40amalloyprobably, but it's easier to try it than to speculate
00:41nappingI don't know how to test whether it's delayed too long
00:41amalloy&(let [r (ref [])] (dosync (let [result (for [x @r] x)] (alter r conj 1) result))
00:41lazybot⇒ () ; Adjusted to (let [r (ref [])] (dosync (let [result (for [x (clojure.core/deref r)] x)] (alter r conj 1) result)))
00:41nappinghmm, maybe a ref-set later in the same transaction
00:43napping(def x (ref '(1 2 3))) (dosync (let [z (for [v @x] v)] (ref-set x '(4 5 6)) z))
00:43nappingproduces (1 2 3)
00:44amalloynapping: i just did that for you, up above
00:45technomancyI wonder if we could get a security audit done on clojars.
00:45technomancy(after we switch from sha1 to bcrypt for password hashes, of course)
00:55brehautquestion time. xml-rpc has an 'array' notation, necessary-evil currently deserializes it to a vector and only serializes vectors back to 'arrays'; It seems fairly obvious that i should also make PersistentList serialize to arrays, but should LazySeq also be included there?
00:56brehautIve explicitly avoided having lazyseq serialisation to avoid realizing infinite seqs and forcing the user of the library to make a decision about how those lazy values are handled.
00:56brehautim not sure if thats the right decision tough
00:56brehautthough*
01:00amalloybrehaut: it seems kinda rude not to handle lazy seqs
01:00brehautits a bit annoying yeah
01:00alandipertbrehaut: i vote all things seq-able... hopefully users understand there's no such thing as infinite xml
01:00alandipert(thank goodness!)
01:01brehautthe thought of an endless stream of xmlrpc xml is horrifying
01:01amalloy(repeatedly #(vomit xml))
01:02brehautlol
01:02brehautthanks for the feedback. i shall fix that in the next release
01:02brehaut(not that anyone in their right mind is using xmlrpc)
01:07j941how can i make a pre condition that asserts that the "type" of something is list
01:07j941:pre isList(l)
01:07ibdknox,(doc list?)
01:07j941i mean "pre isList(l)
01:07clojurebot"([x]); Returns true if x implements IPersistentList"
01:07brehaut:pre (list? l)
01:08j941wow thats cool
01:08brehaut(apropos '?)
01:08brehaut&(apropos '?)
01:08ibdknoxlol
01:08lazybotjava.lang.Exception: Unable to resolve symbol: apropos in this context
01:08brehaut&(clojure.repl/apropos '?)
01:08lazybotjava.lang.ClassNotFoundException: clojure.repl
01:08brehautfine
01:08brehautj941: there are lots of useful predicates like that
01:10brehautim sure theres some good joke code to me made with the rational? predicate
01:10brehaut&(rational? 'brehaut)
01:10lazybot⇒ false
01:11amalloyj941: you almost certainly don't want to assert that it's a list
01:11j941why
01:12amalloybecause you want to treat vectors and seqs the same, probably
01:12j941in any case ([a]) throws an exception
01:12j941&([a])
01:12lazybotjava.lang.Exception: Unable to resolve symbol: a in this context
01:12napping&(list? (filter (constantly true) '(1 2 3)))
01:12lazybot⇒ false
01:12j941&([1 2])
01:12lazybotjava.lang.IllegalArgumentException: Wrong number of args (0) passed to: PersistentVector
01:12j941oh ok
01:13j941how can i assert its an iSeq
01:13j941:pre .....
01:13clojurebotGabh mo leithscéal?
01:13brehaut&(seq? (list 1 2 3))
01:13lazybot⇒ true
01:13j941o ok
01:13amalloybrehaut: boooooo
01:13amalloy&(seq? [1 2 3])
01:13lazybot⇒ false
01:14brehautboo?
01:14clojurebotbook is http://www.pragprog.com/titles/shcloj/programming-clojure
01:14amalloyj941: you could write java instead? encumbering every list-handling function with "hey, first check that this is a list" is not a productive way to spend your time in a loosely-typed language
01:14brehautthanks bot
01:14j941hahah
01:14j941yeah your write
01:14j941right
01:15j941java just iterator pattern :)
01:15j941for (a : mySeq) {...}
01:15j941works on everything
01:15amalloybrehaut: well. aside from the dangers of telling people what they ask for instead of what they need to know, i think someone who wants to check whether something is "a list" probably is willing to accept vectors
01:15nappingnot a good way to spend time in any decent statictly-typed language either. That's what type inference is for.
01:16j941im starting to like clojure.
01:16j941too bad they dont have jobs for it. i guess it will always be a guilty pleasure .
01:16brehautj941: make your own job
01:17brehautamalloy: sure, point taken
01:17brehautits clearly time for me to go be productive elsewhere
01:17j941yup.
01:17amalloyj941: who is "they"?
01:17j941the man lol
01:18amalloyat least three people you've talked to in the last half hour make a living working on clojure
01:18j941thats true.
01:18j941its actually pretty popular esp in bigger cities. im in CT though.
01:19j941i think the supply is prob less than demand so in that sense, its prob better then python.
01:23brehautwhy on earth have i written (String. …) in some code. fail.
01:24j941im conflicted about functions. too many functions -> boilerplate
01:24j941i like bigger methods in clojure. big, domain specific blocks of code.
01:25j941the idea of needing a name for every method is a remnant of OO over modelling,
01:29j941( map (partial zipmap [_ :p _ :c _ _ :f])
01:29j941doesnt like the _'s
01:30j941( map (partial zipmap [_ :b _ :c _ _ :f])
01:30j941seems good 2 me :(
01:30j941&( map (partial zipmap [_ :p _ :c _ _ :f])
01:30lazybotjava.lang.Exception: Unable to resolve symbol: _ in this context
01:46j941how can i create a submap from a map ?
01:46j941{:a 1 :b 2 :c 3} -> {:a 1}
01:47j941seems like "filter" would do the trick. but not sure how.
01:50nappingmaybe
01:50nappingit can probably be done more efficiently
01:50j941remove
01:50j941(remove #(= (:name %) "eric") mylist)
01:51ibdknox,(doc select-keys)
01:51clojurebot"([map keyseq]); Returns a map containing only those entries in map whose key is in keys"
01:51nappingbut you could filter by a set of the names you want to keep
01:51j941(remove #(= (:name %) "eric") mylist)
01:51j941oh ok
01:52ibdknox,(select-keys {:a 1 :b 2 :c 3} [:a])
01:52clojurebot{:a 1}
01:53aamarAny recent opinions on profiling code? clojure.contrib.profile vs. jvisualvm vs. other?
01:53j941duh just found it
01:53j941!
01:53j941thanx
01:59scottjaamar: yourkit is the best I've seen
02:01aamarscottj: ah, a commercial option... $500. interesting.
02:02aamarI'll try it out; thanks for the tip.
02:02scottjyeah use the evaluation version
02:03scottjI think they have a free version somewhere for open source projects
02:39pyribdknox: great news!
02:52pyribdknox: still doesn't work for me
02:53ibdknoxpyr: forgot to push to clojars
02:53ibdknoxjust pushed it up
02:54pyrnope i had lein i nstalled it
02:54ibdknoxhm
02:54pyri use (pe/on (dom/query "a.something") :click ...)
02:54ibdknoxand that does what?
02:54pyrnothing
02:55ibdknoxhm
02:55pyrif i only (pjs/log "foo") in the event handler, nothing happens
02:55ibdknoxdo the a.something's exist already?
02:55pyryes
02:55ibdknoxif they don't it won't work
02:55ibdknoxhm
02:56pyrhmm lemme check though
02:56ibdknoxit works in the todo example if I change it to (dom/query "li")
02:56pyrerf
02:57ibdknoxbut only for the ones that already exist, since it doesn't try to run that query over and over again
02:57ibdknoxfor every possible hit target
02:58pyris there the equivalent of $() ?
02:58pyrso i can start my handlers when i'm sure everything is ready ?
02:58ibdknox(dom/query) is more or less equivalent
02:58ibdknoxoh
02:59ibdknoxyou mean $(document).ready?
02:59pyryeah
02:59ibdknoxno, but if you order your handlers after the append call it should be fine
02:59ibdknoxpyr: google closure intentionally doesn't have a document.ready solution
03:01pyrah, alright
03:01pyrstill no luck, must be doing something wrong
03:03ibdknoxthis is exactly what I'm using: https://gist.github.com/7a5b6722ccbaf7645525
03:03pyrindeed i was :)
03:04pyralright, great, having events on queries again is really nice
03:05pyri don't think i'm missing anything now
03:07ibdknoxsweet :)
03:09pyribdknox: it fixes a pain, since to have events i had to have a bunch of partials
03:09pyrand including partials in partials is cumbersome
03:09ibdknoxmm
03:09ibdknoxideally there would be named elements in a partial
03:09ibdknoxand you could bind events to those
03:09ibdknoxthat's the goal
03:09ibdknoxnot sure how to do that yet though
03:11ibdknoxbut that's it for me for tonight :) Good luck!
03:12pyrthanks :)
03:35rata_hi
03:37iAmerikanI'm checking out clojure, and was wondering if anyone could point out my issue here? http://snips.tk/nyd3/
03:38napping&(let [num 3] (if (= (rem num 5) 0) "buzz" num))
03:38lazybot⇒ 3
03:38hiredmaniAmerikan: think it through
03:38nappingfunction returns value of last expression
03:38raekiAmerikan: in functional programming languages, the expression is the building block rather than the statement
03:39rata_what do you think about allowing nested #(...) fns and using %%, %%1, %%2, and so on, as in (update-in m [k1] #(for [e %] (update-in e [k2] #(map f %%))))?
03:39raekbut clojure does provide an "imperative" construct that allows you to evaluate two expression in the place of one
03:39hiredmanraek: horrible
03:39opqdonutrata_: horrible
03:40nappingtasty deBruijn indices
03:40rata_why?
03:40raeknamely 'do'. it evaluates all expressions and returns the value of the last one
03:40clojurebotwhy not?
03:40raekdefn has an "implicit do", which means that your example is thr same as (defn fizz-buzz [num] (do (if ...) (if ...)))
03:41iAmerikanoooh
03:41opqdonutnapping: except those are not deBruijn indexes, right?
03:41nappingcould be deBruijn levels, I guess
03:41raeki.e. the value of the first conditional expression is evaluated and discarded. then the second is evaluated and returned
03:41nappingbut the number of % is how many binders out to go
03:41opqdonutdeB would be: %1 referring to the first argument of the innermost #(), %%1 to the next #() etc
03:41nappingwas that not the proposal?
03:41opqdonutmaybe I misread
03:42opqdonutor -understood
03:42raekiAmerikan: you can use 'cond' if you want something prettier than nesting a bunch of ifs
03:42nappinganways, deBruijn levels are the ones that count the other way, and are maybe not much better
03:42nappingraek: that's probably the wrong way to go
03:43iAmerikanI'll look into it, thank you, I'm extremely new to functional programming, and still a novice w/ OOP/procedural
03:43nappingiAmerikan: try the "str" function
03:43raek(cond (zero? (rem num 3)) "fizz", (zero? (rem num 5)) "buzz", :else num)
03:43nappingcall it with a few argumnets, and nills thrown in
03:45iAmerikancan I save to .clj then run clj foo.clj to run it?
03:45iAmerikanwhile I'm here can anyone suggest a clojure resource for beginners?
03:45rata_napping, opqdonut: it could be both ways (not at the same time obviously)
03:46raekiAmerikan: I recommend taking a look at leiningen.
03:46iAmerikanThank you
03:46nappingrata_: http://www.e-pig.org/epilogue/?p=773
03:47napping"M’colleague Bob Atkey once memorably described the capacity to put up with de Bruijn indices as a Cylon detector, the kind of reverse Turing Test that the humans in Battlestar Galactica invent, the better to recognize one another by their common inadequacies. He had a point."
03:47opqdonut:)
03:48raeklein new fizzbuzz, put stuff in fizzbuzz/src/fizzbuzz/core.clj, put (ns fizzbuzz.core) at the top of that file, make a function called (defn -main [] ...) that contains code you want to test, run with "lein run fizzbuzz.main"
03:49raekiAmerikan: but it is often more rewarding to develop in a repl. use "lein repl" in the project to get one, (require 'fizzbuzz.core) to load you file and (in-ns 'fizzbuzz.core) to move the repl into it
03:53raekiAmerikan: clojure does not come with a standard 'clj' script (unlike python and ruby, for example). there are tools that make it simpler to do "one-off scripts", but the project approach is simpler to use when you need to split up your code into more than one source file.
03:54raekso IMHO it's good to get acquainted with it as soon as possible
03:54iAmerikanThank you again :D
03:59hiredmanclojurebot should load a fresh clojure runtime for the sandbox every 10 minutes now, I think I figured out all the security problems I had with with reloading RT with a security manager in place
04:01ZolrathI'm looking for a postgresql library for clojure, is ClojureQL a good choice? Hasn't been updated in a while.
04:01rata_is there anyone from congomongo here?
04:02hiredmanZolrath: clojureql is not a postgresql library
04:02hiredmanyou'll want the postgres jdbc driver
04:03Zolrathno? the site says it compiles to SQL92 so its compatable with MySQL and PostgreSQL
04:03hiredmanright, it generates sql statements, which you have to ship off to an sql server
04:03hiredmanso nothing to do with postgres
04:04Zolrathahhhh okay
04:04hiredmanI recommend you just use clojure.java.jdbc together with the postgres jdbc driver
04:04ZolrathRealistically if theres a better option for another db I'd be open to that too
04:05hiredmannah
04:05hiredmanpostgres is great
04:05ZolrathI was using congomongo but I realize for this project a normal relational database would be better
04:08Blktgood morning everyone
04:13Zolrathhiredman: Thanks for your help!
04:15rata_Zolrath: why did you realize a relational database would be better? did you need the expressive power of SQL?
04:17Zolrathrata_: Well maybe it's just my lack of knowledge of mongodb but I'm trying to make a project that loads entries via AJAX
04:17rata_ok
04:18Zolrathand the ids of mongodb dont really lend themselves to incrementing an id to get the next entry
04:20rata_I think there's a way to have "normal" autoincrementing ids in mongodb
04:20ZolrathI actually have the logic and data in mongodb already so that would be awesome if so
04:21ZolrathThe only thing I saw seemed like it was something you'd have to run on the data every time there was a new entry, but I could have been interpreting it wrong
04:22carkit would take a lot for me to consider a nosql solution
04:22carkthere's so much you cannot do with those
04:23carkand so little benefit
04:23rata_cark: speed is not a benefit for you?
04:23rata_Zolrath: http://shiflett.org/blog/2010/jul/auto-increment-with-mongodb <- this is the first google hit, but haven't read it enterily yet
04:24carksur speed is good, but sql databases are already fast enough for me =P
04:24carksure*
04:24carkwhat's your project ?
04:25rata_my project or Zolrath's?
04:25carkyours, what project do you need a nosql database's speed for ?
04:26nappingis there a fancier version of cond?
04:26rata_napping: even fancier?
04:27nappingletting you bind the true result, for one
04:27carki have a project in production with several hundreds page views per second, postgres seems to be faring pretty good
04:27carkand that's only the gui side of things
04:29rata_cark: I'm working on a project for which I don't know how much page views per second I'll have, but I think that the faster the db goes, the cheaper the server on which you have to run it
04:29raeknapping: only if-let. (but that's for only one clause, of course) I think I once wrote a macro that looked like cond but expanded into nested if-let forms instead of if forms
04:29nappingI might also have a use for one that makes if-not forms
04:29carkrata_: and you're ready to loose referencial integrity, and do the bookkeeping manually for this ?
04:30carkit all depends on how you value your time
04:30ZolrathAm I correct in thinking that ids are the way to go for this auto-pagination type project? I was trying to think of a way to do it using the mongodb I already have but couldnt think of anything that made sense
04:31carkwhat do you mean by auto-pagination ?
04:31rata_cark: until now, it's a "query-only" db with weekly updates or so
04:32carkah i guess for simple use cases it fits the bill
04:32rata_yes
04:33ZolrathI want to make it so when you go to the page it loads the most current entry and as you scroll down it loads the earlier entries
04:33carktho project have a tendency to grow in complexity over time... then you're stuck with a nosql database
04:33Zolrathbut if you go to a url with the direct link to a specific entry it would load that entry
04:33Zolrathand allow you to scroll up for newer entries
04:33Zolrathand down for older
04:34carkZolrath: to me, autoincrement fields are only for identity
04:34carkyou need to have a date inserted field, then sort on that
04:34ZolrathI have a date field, hm
04:34carkand then the usual select * from x limit offset thing
04:35carkor whatever the mongodb equivalent is
04:35ZolrathI've actually never done any ajax loading before so this whole thing is an adventure
04:35carkare you using jquery or maybe clojurescript ?
04:36ZolrathI'm trying this with clojurescript
04:37carkahwell didn't give it a test run yet =/
04:37ZolrathI was going to attempt using pinot/goog.dom but I imagine it would be easier if I go with jquery and its horde of plugins?
04:37rata_Zolrath: in mongo it'd be db.collection.find().sort({date: 1}) or something like this
04:38carkno idea, i'm pretty sure clojurescript is up to the task
04:38carki always went the jquery route until now, next new project will probably be clojurescript
04:38rata_cark: if the project grows, I can leave this part as mongodb and use a relational database for the users part... this part is just public information I web-scrapped
04:39ZolrathI was trying to find an article out there that broke down how systems like this work so I could go at this with some knowledge
04:39carkrata_: ok =)
04:39ZolrathRight now I just have functions that will fetch an entry based on a fields value, or just all of them sorted by date
04:40ZolrathBut I'm not really sure how to call that information from the clojurescript in reference to the data already loaded
04:40carkZolrath: i recently converted an application to use a service based architecture in the spirit of wxhat you're doing
04:40carki have the web server producing json on different http requests
04:41carkalways encapsulated in the same message structure
04:41carkthen a single web page on the client side
04:41carkwhich requests information from the correct url depending on what it needs
04:42ZolrathHm, since I'm going Clojure/Clojurescript can I do the same idea via passing clojure maps between them?
04:42carkthat's a full application with maybe 50 "pages" all collapsed in a single javascript file
04:42cark that's what i would do
04:43ZolrathRight now I have all entries pass a normalized map with the same fields
04:43carkyou may want to have something around that
04:43carkso that you can pass errors etc
04:44carkor go the rest way, and just rely on http status ... i didn't go that route
04:44ZolrathI hope to have it allow you to go to
04:45Zolrathlocalhost:8080/entry/09/23/2011 and have it load that entry
04:45carkhum a date is a single piece of data
04:45Zolraththen allow you to scroll up/down from there depending on if there are entries either way
04:45carki would do localhost:8080/entry/09-23-2011
04:45Zolrathah okay, that works
04:46carkwoah the scroll up thing might prove difficult
04:46carkbut it would be neat if you make it =P
04:46Zolrathyeah I was trying to figure out how to get the previous/next entry in the db without ids
04:47ZolrathI can sort it by date, but how do I match that with where I am/what the next entry is
04:47carkwell i don't know about mongodb
04:50ZolrathThats why I was thinking about using an id field as I could go Hey Im on entry 32 try loading 31
04:52ZolrathI can't really reason a way to Say Hey I'm at 9-28-2011, lets sort by date, find all entries earlier than that entry, return the oldest?
04:52ZolrathThough I guess that way might work..
04:58clgvZolrath: a timestamp can be a good id as well if your problem environment assures its uniqueness
04:58carkif you do not plan to delete much from the database i guess the id thing could work
04:59carkbut that's forcing one database request per item
04:59Zolrathyeah each entry will have a unique timestamp
04:59carkmaybe more than one, if there are some deleted items
05:01Zolrathcark: Hm, would something like finding the first 5 entries with dates later than the current one be a better option then?
05:01carkwould be so easy with sql : item = select from table where date = x, page before = where date < item order by date desc, page after : where date > item order by date
05:02ZolrathTo be honest I still have research to do as how the actual ajax calls happen
05:02carkZolrath: sure you want to batch as much as possible, from the database, through your application, via ajax
05:03Zolrathhow it actually passes what the oldest/newest entries loaded so far are to the query
05:03carkyou don't want to get too chatty when coping with internet latencies
05:04carkZolrath: well you can start by passing test data, see how the ajax stuff works
05:04carkmy first ajax call was requesting a string that said "hello"
05:05carkon this last project i was talking about =)
05:08Zolrathhaha yeah I so far had it pull the title from the first entry
05:08Zolrathin the database
05:08Zolrathand that works
05:08cark=)
05:09ZolrathBut I have no idea how to bind calling more entries to screen position or anything like that
05:10Zolrathespecially based on information contained within the entry pulled
05:14ZolrathI'll make trying to get something based on the last entry the next challenge, before really figuring out how to tie that into the screen position
05:21Zolrathcark: Thanks for all your input! I'll hopefully be able to show you something "working" soon!
05:22carkhehe great =)
06:11shtutgartClojurescript newbie: I've created the script as described here (https://github.com/clojure/clojurescript/wiki/Emacs-%26-inferior-lisp-mode) and started it. I can see the prompt, but after sending some input repl hangs forever: http://dpaste.org/1nY07/
06:20robermannhello, maybe I'm missing something: this (http://pastebin.com/PVZqGLdb) is my partial resolution of a 4clojure problem (http://4clojure.com/problem/118). My problem is that it seems I'm not able to write a lazy recur/loop, not even using lazy-seq. Am I missing any fundamental concept?
06:21robermannmy resolution works for the first two problems, but the third goes on and on in timeout
06:21clgvrobermann: loop-rcur is not lazy
06:21robermannah ok
06:22clgvrobermann: you might use lazy-seq as standalone
06:25clgvrobermann: http://pastebin.com/KSbXE48c
06:26robermannthanks, but before check it I'll try to resolve it by my own. I was checking http://clojure.org/special_forms#recur , but I cannot find where it say itsn't lazy. How could I infer that a form is not "lazy-able"?
06:27clgvrobermann: "(almost) only lazy-seq is lazy"
06:28robermannI thought that (recur (next col) (lazy-seq (conj res (f cur)))))))) would recur in a lazy loop
06:28clgvloop-recur: is just a form to enable tail-recursion
06:28clgvclojure's function calls are not lazy evaluated
06:28clgvonly lazy sequences are
06:28robermannmmm correct
06:29robermannnow makes more sense :)
06:29robermannthank you
06:29clgvlet me rephrase: loop-recur is a form to enable optimized tail-recursion
06:30robermannand works as a function call, evaluating immediately
06:30clgvyes. it does
06:30robermannok
06:31Chousukeyou need to use regular recursion when you create lazy seqs, not recur
06:32Chousukethen just wrap the recursive function call in a lazy-seq form
06:32Chousukeyou can't do that with recur because it's not the tail position, but due to the laziness there is no stack growth issue
06:32clgvdoes the 4clojure problem list grow over time?
06:33Chousukeby the time the thunk gets evaluated, the original function call has returned.
06:35robermannChousuke: are you referring to clgv's solution right?
06:35BlafaselTrying to put a clojure environment on most of my machines here: How do you suggest doing that? For example, my fedora here packages 1.2.1. Would you use that or go with the .jar? Is there something like rvm or a tool of sorts to keep my environment current?
06:36clgvrobermann: I guess he didnt read it, since he describes it ;)
06:36Chousukerobermann: yes.
06:36clgvok, my error
06:37ChousukeI think you can actually do (cons (f (first coll)) (lazy-seq (my-sad-map (rest coll)))) too
06:39clgvyou forgot an f^^ otherwise you have to have another (possible anonymous) closure with f
06:40Chousukeright
06:40ChousukeI think that implementation of map will always force the evaluation of the first element of the seq though :/ because (when (seq coll) ...) is outside the lazy-seq form
06:42clgvChousuke: yeah I thought about moving it into lazy-seq. but to demonstrate lazy-seq it also works^^
07:00robermannclgv or Chousuke: could I use "next" instead of "rest"?
07:00clgvwhy?
07:00clojurebothttp://clojure.org/rationale
07:01robermannah ok, I found "rest versus next" on your book :)
07:02robermann(to be honest I read it, but just I forgot all those useful informations)
08:04chridohi, does anybody know how to get syntax-highlightning with *.cljs files in LaClojure/IntelliJ?
08:31fdaoud,(let [teams (range 1 9)] (map list (take 4 teams) (reverse (drop 4 teams))))
08:31clojurebot((1 8) (2 7) (3 6) (4 5))
08:31fdaoudbetter way to do that?
08:35nachtalpfdaoud: you don't need to use drop
08:35fdaoud,(let [teams (range 1 9)] (map list (take 4 teams) (reverse teams)))
08:35clojurebot((1 8) (2 7) (3 6) (4 5))
08:36fdaoudnachtalp: like that?
08:36nachtalp,(let [teams (range 1 9)] (take 4 (map list teams (reverse teams))))
08:36clojurebot((1 8) (2 7) (3 6) (4 5))
08:36nachtalpor like that
08:37fdaoudah, I like yours better
08:37nachtalpfdaoud: reverse is not lazy, however...
08:38fdaoudnachtalp: yeah I was wondering about that..
08:39fdaoudnachtalp: thanks
08:39nachtalpfdaoud: glad to help :)
08:40fdaoudnachtalp: appreciate it.. one more question?
08:40nachtalpfdaoud: sure
08:40fdaoudhow do you flatten by one level only?
08:41fdaoudhave [ [ [1 8] [2 7] [3 6] [4 5] ] [ [9 16] [10 15] [11 14] [12 13] ] ]
08:41fdaoudwant [ [1 8] [2 7] [3 6] [4 5] ] [ [9 16] [10 15] [11 14] [12 13] ]
08:41fdaoudsorry
08:41fdaoudwant [ [1 8] [2 7] [3 6] [4 5] [9 16] [10 15] [11 14] [12 13] ]
08:42clgvfdaoud: apply concat
08:42nachtalp,(reduce concat [ [ [1 8] [2 7] [3 6] [4 5] ] [ [9 16] [10 15] [11 14] [12 13] ] ])
08:42clojurebot([1 8] [2 7] [3 6] [4 5] [9 16] ...)
08:43clgvor you use mapcat when generating those two lists via map
08:43nachtalpapply makes more sense
08:46fdaoudclgv: mapcat does the trick :)
08:46fdaoudthank you both!
08:47fdaoudso much nicer than a ton of Java code..
08:52clgvfdoud: I guess you can skip the reverse by a clever use of partition and map
08:56fdaoudclgv: ?
08:57clgvfdaoud: with the following you get pairs of the ranges you want to combine: ##(->> (range 16) (map inc) (partition 4) (partition 2))
08:57lazybot⇒ (((1 2 3 4) (5 6 7 8)) ((9 10 11 12) (13 14 15 16)))
08:58clgvit shouldnt be that hard to continue from that to your goal
09:01fdaoudclgv: ok but I don't see how that skips the reverse?
09:02clgvfdaoud: right, I expressed that wrong - you only have to reverse what you actually use
09:02fdaoudclgv: ah, I understand
09:04jonasenAnyone know what's going on here: http://build.clojure.org/job/data.csv/org.clojure$data.csv/lastBuild/console ?
09:04jonasenI don't know why it fails. Running 'mvn clojure:test' locally works fine but fails on build.clojure.org
09:05fdaoudclgv: great thanks
09:20dnolenjonasen: clearly this commit broke things, https://github.com/clojure/data.csv/commit/8608a2c62aac58eb2deab5801e55323a75d2e06c
09:20cemerickjonasen: .setLength is only in JDK 6, IIRC
09:21jonasencemerick: ok, I didn't know that. Thanks
09:25carkis there a problem in 1.3 where recompiling a defmulti has no effect ?
09:25cemerickjonasen: sorry, no, that's not right; that sort of error is something I hit before on Clojure 1.1, but it should be fine in 1.2
09:26carki mean without restarting the repl
09:26jonasencemerick: this is on 1.3.0-beta1
09:28jonasenI found this on the mailing list https://groups.google.com/forum/#!msg/clojure/rp7vMFYqzTM/ZSF0DfK8z2AJ
09:28jonasenmight be related?
09:29cemerick,(.setLength (StringBuilder.) 0)
09:29clojurebotnil
09:30jonasenI have not been able to reproduce the exception locally
09:33cemerickjonasen: I've hit this before, but now I can't seem to reproduce it on Clojure 1.1 either: https://github.com/clojure/tools.nrepl/blob/master/src/main/clojure/clojure/tools/nrepl.clj#L166
09:33clgv,(clojure-version)
09:33clojurebot"1.3.0-master-SNAPSHOT"
09:33clgv&(clojure-version)
09:33lazybot⇒ "1.2.0"
09:33cemerickcark: The dispatch fn is cached; you need to ns-unmap the var, and then reload the definition.
09:34carkallright i thought it was something like that
09:34carkthanks !
09:36jonasencemerick: i found this http://www.davidflanagan.com/2004/10/abstractstringbuilder.html
09:37jonasensetLength is in AbstractStringBuilder, which is a private class. Maybe that is the reason it fails?
09:39carkgrrr not being able to access protected methods from a proxy is a real pain
09:40carkthere is no way to keep a repl and effectively work with swing components
09:40carkno way to derive = loose
09:40carkpaint me frustrated
09:40carklose*
09:47cemerickjonasen: In any case, since it works locally, but fails in hudson, you "just" need to find the difference in environment. I'd certainly like to know what the real cause is.
10:02robermanndoes anyone installed the Emcs's starter-kit? I followed these instructions, all went well but now Emacs's toolbar and icons are disappeared
10:03robermannhttp://technomancy.us/153
10:04ZolrathI'm pretty sure thats part of the starter kit
10:04ZolrathRemoving the toolbar and icons
10:04robermannmmm :)
10:04ZolrathForce you to drop the mouse hah
10:06robermannwell, here I'm on Windows, I have some mouse and not ASCII icons :D
10:07robermannplenty of "antifeature", maybe
10:10joegalloi think it's a polite suggestion from the author that you'll prefer it that way, eventually.
10:11joegalloif you disagree, you can put it in your emacs config that you want those back, and they shalt appear
10:11joegallohe's attempting to provide what he considers to be sane defaults
10:11joegalloif you disagree, feel free to change them back
10:11carkyou just need to learn about navigating the config screens... i think the fastest would be to learn going without the toolbar
10:20robermannyes, you all are right, but I was trying to understand if this starter-kit would be an easier setup than Clojurebox
10:23robermannevery "raw" installation of Emacs on Windows does not work properly; I thought this version (http://code.google.com/p/emacs-for-windows/updates/list) had included all binary dependencies (like "sh")
10:23robermannbut, instead of it, I also loose the toobars :D
10:25robermannby now I'll keep with Clojurebox on Windows. I don't regret command line setups, just searching for a ready-to-go Clojure-environment setup
10:28clgvrobermann: you could try eclipse with ccw under windows
10:31robermannlast time I checked it was lacking something like indentation; it seemed to me a beta version
10:33duck1123Why not just add (tool-bar-mode 1) to the bottom of your ini file?
10:33duck1123If you're using the starter kit,create <username>.el and put it there
10:33clgvah well beta would be an insult. but the feature set has a lot growth potential, indeed ;)
10:38robermannyes clgv :) Maybe I checked it time ago; it surely has a lot of growth potential :)
11:08kzarIs there a function that takes a map, key and function and returns a new map which just changed the given key by running the function on it's value?
11:10clgvkzar: update-in
11:11kzarclgv: Aha, had a hunch there was something that did that. Thanks
11:35kzarDoes noir work OK if you use Clojure 1.3 in your project?
11:35ZolrathYeah just use noir "1.1.1-SNAPSHOT"
11:36kzarZolrath: Great OK
11:36ZolrathWhen working with the DOM in ClojureScript/Pinot if I add a click handler to images and use that to add new images, the new images don't have the click event.
11:37ZolrathIs there any way to make the click handler that is generating the images reinitialize itself I suppose?
11:47Blktcould anyone help me understanding why I get this kind of error?
11:47Blkt#<CompilerException java.lang.RuntimeException: java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IPersistentVector (NO_SOURCE_FILE:0)>
11:50kzarBlkt: I guess you're doing something that expects a vector but it doesn't get one. Something like this:
11:50kzar,(subvec (seq [1 2 3]) 1)
11:50clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.PersistentVector$ChunkedSeq cannot be cast to clojure.lang.IPersistentVector>
11:50Blktmmm
11:50Blktlet me see
11:50kzar,(subvec [1 2 3] 1)
11:50clojurebot[2 3]
11:51Blktthanks kzar!!!
11:51BlktI just found the freaking erro!
11:51Blkterror*
11:52kzarsweet good work
11:52BlktI've been digging the code for hours...
11:53kzarBlkt: What're you making, anything cool?
11:53zippy314Has anybody used clojurescript and a goog.ui.Dialog to hold components, i.e. form elements? I figure out how to load up the content with anything but straight html, when I want to fill it with dynamically constructed elements.
11:54Blktkzar: I'm using Clojure to handle some neural network stuff in Java
11:54Blktusing neuroph
11:54Blktpretty good library
11:55kzarBlkt: oo cool
11:55Blktyes, I'm pretty happy about it
11:55Blktit's not common in Italy to work with AI
11:59kzarGotta run anyway, ciao
11:59Blktciao
12:01Bronsaitaliano Blkt?
12:03ZolrathIs there any way around events not working with event created elements or am I out of luck?
12:04dnolenZolrath: what are you referring to?
12:04BlktBronsa: si :D
12:05Bronsayeah
12:05BlktBronsa: you too?
12:05Bronsayep
12:05Blkt:)
12:05Zolrathdnolen: Oh I guess that was incredibly non-specific. ClojureScript/Pinot click event handling
12:06fdaoudit's not common in Italy to work
12:06fdaoud:(
12:06dnolenZolrath: events work fine. I haven't played around much Pinot yet.
12:06pyrZolrath: you just have to make sure event handlers are setup after your elements are created
12:07pyrZolrath: or alternately, use a partial as reference
12:08ZolrathThe issue here being if I made a <li> that generates more <li>s when clicked, the generated items don't have the click event
12:08ZolrathTrying to figure out if theres a way to make the event function wrap the new elements
12:11dnolenZolrath: are you add click events to the newly adding li elements?
12:12dnolenerg I meant - are you adding click events to the new added li elements ?
12:12duck1123Does the Closure library have something equivalent to JQuery's live?
12:15ZolrathI'm not adding it to the newly added elements specifically, I was reallllly hoping adding the event to a dom type would propigate to newly created ones or I'd be able to have the function that wraps the elements run again automatically
12:15ZolrathjQuery.live looks exactly like what I was thinking
12:15ibdknoxZolrath: events on partials are delegated like that
12:17ZolrathYeah? hm
12:18ibdknoxhttps://github.com/ibdknox/pinot/blob/master/examples/todo.cljs#L43
12:18ibdknoxthat line essentially says for anything created by that partial function ever, bind this event
12:20Zolrathis there any way to select an element of a partial for the click handler in the query or would I need to make the section of the partial I want to put the handler on into its own partial?
12:25Zolrathibdknox: While I have a direct line to the man himself, am I incorrect in thinking that Noir can't handle %20 in the address bar?
12:25Zolrathibdknox: I have images with spaces in their names and if I try to go to them I just get a white screen, but if I remove the spaces they work.
12:26ibdknoxZolrath: huh, I haven't tried. It should do whatever compojure does in that instance, as resource routes are handled purely with compojure
12:27clgvshort question: I want to use a classic SQL database like postgresql - is there already a clojure frontend?
12:28hiredman~google jdbc
12:28clojurebotFirst, out of 1780000 results is:
12:28clojurebotJDBC - Oracle
12:28clojurebothttp://www.oracle.com/technetwork/java/javase/jdbc/index.html
12:28hiredman~google jdbc postgres
12:28clojurebotFirst, out of 42300 results is:
12:28clojurebotPostgreSQL JDBC Driver
12:28clojurebothttp://jdbc.postgresql.org/
12:28clgvhmok. I thought that there is plenty in the java world ;)
12:28clgvbut there was also a chance that a comfortable clojure layer already exists ...
12:28ibdknoxZolrath: it appears you are correct that it doesn't url parse them
12:29ibdknoxclgv: clojureql
12:29clgvibdknox: oh right^^
12:29Zolrathibdknox: Yeah it doesnt seem to be able to handle any %__ characters
12:30ibdknoxinterestingly, it will pick up hey%20how as a route
12:30ibdknoxZolrath: I'll see what can be done about that
12:31Zolrathibdknox: You're my hero, thanks!
12:31seancorfieldclgv: clojure.java.jdbc is a reasonable wrapper for SQL / jdbc - depends what you want
12:32clgvseancorfield: yep. I have to find out what I want. right now I am performing $joins and $rollups on incanter datasets ;)
12:32clgvthat might not scale with my bigger datasets
12:33seancorfieldfor raw performance you're going to want to stay "close to the metal" so c.j.jdbc will let you do that
12:34ibdknoxZolrath: I'm actually confused, ring *does* decode the url...
12:35Zolrathibdknox: Hm so at some mysterious undefined point from there to here it goes awry. That's less fun.
12:36ibdknoxyeah lol
12:39ibdknoxZolrath: ok, it only decodes the body for form params, but never sets the URI to a decoded state. The fix is a very simple piece of middleware. I'll add it tonight, or maybe earlier if I get some free time
12:41jriddyquick question: is there a builtin function f : (f [[k1 v1] [k2 v2] ... ]) -> {k1 v1, k2 v2, ... }
12:41Zolrathibdknox: Aweeeeeesome. Thanks for looking into it!
12:41jriddy?
12:41ibdknoxjriddy: (into {} ...)
12:42jriddy(partial reduce (fn [m [k v]] (assoc m k v)) {}) works
12:42jriddyoh
12:42jriddythanks
12:42ibdknox,(into {} [[:a 1] [:b 2]])
12:42clojurebot{:a 1, :b 2}
12:57bendlas`I want to use clojure.java.data, but it's not released yet
12:57bendlas`which repository should I use for snapshots?
12:58bendlas`My guess is https://oss.sonatype.org/content/repositories/snapshots/, but it's not documented anywhere
13:26justicefriesso I'm getting more and more into clojure...I'm using homebrew to install leiningen, when I enter lein repl it's version 1.2.1
13:26justicefriesshould I be on 1.3? if so...possible with lein?
13:27bhenrytry lein upgrade
13:27gtrakjusticefries, make your project.clj point to 1.3
13:27bhenryoh yeah
13:27bhenryderr
13:27justicefriesah
13:27justicefriesperfect
13:27justicefriesthank you
13:28justicefriesgtrak: is there a global one? I'm not in the context of a project at the moment...but I suppose that's the idea behind lein is to be in that context.
13:28gtraknot sure.. simply do lein new and you'll be in one
13:29gtrakany pure repl work probably shouldn't care about 1.3 vs 1.2
13:29justicefriesah okay sure.
13:30justicefriesi'm coming over from the world of RVM/ruby/bundler, so. :)
13:31BlafaselHmm.. vimclojure seems to be quite nice and good enough for all my needs. Let's steal some .vimrc ideas from the net.. :)
13:31gtrakjusticefries, I wouldn't know about that stuff, but welcome!
13:31justicefriesthanks!
13:32justicefriesBlafasel: I'm of the same mind but emacs/swank/slime seems so nice.
13:32hiredmanimagine if bundler had been around from the start and people looked at you crazy if you tried to do it differently
13:32justicefriesmakes sense.
13:32justicefrieskind of like npm with node js
13:32hiredman"wait, you want to install thingks globally? whatever for?"
13:33Blafaseljusticefries: I'm used to vi/vim - and don't want to get started with emacs as an ide only. So - not for me, not right now :)
13:40technomancyI think there's a plugin for a "global lein project", but I think it's silly to have a special case like that; just make a new project since they are cheap.
13:43Raynestechnomancy: It's useful to be able to configure dependencies and such for a 'default' repl outside of any other project. I don't know how that global lein project plugin does it, but the way cake does it results in cljr-like functionality.
13:44technomancymust be solving problems I don't have
13:45RaynesMust be.
13:46technomancyquestion is if it's a problem others have or a problem they think they have
13:46robermannI add my "default" jar/source foders in the lein script file, hard coded
13:46RaynesI'm not sure it's a problem in general.
13:46technomancyI get so many requests to solve the latter
13:47RaynesIt's just handy.
13:47duck1123robermann: but wouldn't your build fail if someone else checked out your project?
13:47gtrakjust make a project and a default-repl bash script...
13:48robermannyes of course, they are local dependencies
13:48RaynesOr just use the global project.
13:48gtrakbut what do you guys do in a repl like that except toy things?
13:49gtrakit has to be attached to swank or something to be useful, imo
13:50RaynesMeh, I don't even use swank these days.
13:50robermannI use Emacs's REPL
13:50gtrakthe inferior-lisp?
13:50RaynesJust cake's repl is fine for me.
13:50robermannno, now i'm on Windows + Clojurebox
13:51robermannvery cool
13:51gtrakI like the navigation and compilation stuff in slime
13:51gtrakesp if you're looking at other people's code... what do you do?
13:52robermannultimately I added to my clojurebox setup the tabber and rainbow stuff, now I'm an happy man
13:52RaynesMust be solving problems I don't have.
13:52Raynes;)
13:52robermann:)
13:53technomancyheh
13:53robermanngtrak: I added to my emacs load-path this file (a revisioned version of): http://pastebin.com/dVivdqpB
13:53robermann[ the original was here: http://www.learningclojure.com/2010/03/conditioning-repl.html ]
13:54robermannit contains useful function to inspect other people's code,
13:54robermannor just to study the core funcitons
13:54gtrakpretty useful, yea
13:56robermannthis is a part of .emacs http://pastebin.com/gLq0zrDt
13:56robermannmy .emacs
13:56gtrakI just type something and use M-.
13:56gtrakand find-doc or source is available from the repl
13:56robermannbut you have to remember to require its namespace before
13:56gtrakor compile it from emacs
13:57justicefriesgah emacs is hard.
13:57justicefriesdo people use aquamacs or base emacs?
13:57gtraktrue
13:57justicefriesi'm trying to figure it out. ;)
13:57robermannI use aquamacs too
13:57justicefriesi can't even figure out how to switch between my SLIME window and a regular buffer
13:58robermannbut I was not able to do a clojure-jack-in mode
13:58gtrakM-x describe-bindings
13:58gtrakC-x b is buffer switch
13:58gtrakI suggest printing out the cheat sheets
13:58technomancyaquamacs is unsupported and nonportable
13:59justicefriesi'm coming from vim so I feel helpless
13:59robermannin order to work with aquamacs, I had to disable autodoc
13:59robermannand now with M-x slime-connect I can do something
14:00gtrakooo, technomancy v2 starter kit
14:01robermannon windows i'm still using clojurebox http://clojure.bighugh.com/
14:02robermannthe best IMHO :) (congrats technomancy)
14:02technomancyit's been out for a while; just formally announced last night.
14:03robermannI have to run away - no wife no party
14:03robermannbye
14:27shep-homeHmm, I parsed "technomancy v2 starter kit" as "technomancy is having a child"
14:27scgilardi:)
14:33justicefriesaaah emacs is just frustrating.
14:33amalloyjusticefries: what are you used to using?
14:33justicefriesvim.
14:34justicefriesi'm actually trying to go throught he tutorial right now.
14:34justicefriesand figure out what's going on.
14:36justicefriesand install emacs 24 in osx.
14:36justicefriesi'm about to roll with slimv and vimclojure. :D
14:43justicefriesor I could just slug it out.
14:44gtrakjusticefries, emacs is easy peasy
14:44gtrakafter about 2 days I was able to get rid of the menu bars
14:44justicefriesah nice.
14:44justicefriesI was thinking of using technomancy's starter kit.
14:44hiredmanyou should
14:44gtrakyea.. I started from modifying his stuff
14:44hiredmanabosolutely
14:45amalloygtrak: you make it sound like it took you two days to figure out how to get rid of them, rather than learning how to go without them
14:45gtrakthen printing the cheat sheets for emacs and paredit... and M-x describe-bindings for the rest
14:45gtrakamalloy, yes, I mean, learning how not to need them anymore took about 2 days of using it at work
14:46amalloygtrak: C-h b, btw
14:46gtrakya
14:48gtrakand I'd been meaning to get around to it for about 10 years...
15:03amalloyi think ten years ago i was just realizing programming might be fun
15:04amalloyif i'd thought emacs was required, at the time, i might have given up. scary stuff to learn, at first
15:04technomancyten years ago I was just recovering from the damage "Learn C++ For Macintosh" inflicted on my enthusiasm for computoring.
15:04amalloynice
15:04gtrakyea... in high school I read Learn C++ in 21 days
15:05pcavs ⁃ /clear
15:05gtraki didn't learn it in 21 days
15:05amalloyTI-BASIC ftw
15:07ibdknox_10 years was VB6 for me lol
15:10fdaoudThere is no possible way to say it without offending someone so I'll just be blunt:
15:10fdaoudI think emacs is lame.
15:10fdaoud--Doug Hoyte
15:11NikelandjeloHi. I'm trying to use matching lib https://github.com/clojure/core.match . But I have problem with little code snippet (I deleted all reduntant information): (match [expr] [[:div num den] 0 [[func]] 0) . It throws IndexOutOfBound exception while expanding macro. Is it lib bug or my?
15:11gtrakfdaoud, !
15:11jriddyfdaoud: +1
15:11amalloyfdaoud: yeah, i read that. doug hoyte is a bit of a tough read
15:11fdaoudamalloy: indeed
15:12amalloyNikelandjelo: your deletion is incorrect, since that isn't a well-formed sexp
15:12fdaoudpersonally I prefer vim over emacs but I just keep my mouth shut about it; to each their own.
15:12amalloyi did get a few useful things out of LoL, but most of it is a lot more useful for CL than clojure
15:13amalloyhuge focus on mutation
15:13fdaoudtrue, true
15:13fdaoudstill good food for the brain
15:13amalloy*nod*
15:13amalloyprovided you spit out the evangelizing (about CL *and* vim) before you swallow
15:13fdaoudheh
15:14fdaoudwell I don't get into editor wars; I think each should use what makes them *productive*
15:14amalloyindeed
15:14fdaoudso choose *one* editor and become an expert user of it.
15:14Nikelandjelo@ammalloy, Oh, sorry. I missed one bracket after 'den', but it typo while copying to chat. Is it still incorrect?
15:14amalloythe blog post i wrote about editors is basically "i like emacs, you should use either emacs or vim"
15:15fdaoudi.e. if you're using the mouse, or the arrow keys most of the time, you didn't learn enough about the editor, or the editor's commands are weak
15:15amalloyNikelandjelo: i dunno, i have no idea how to use match. i'm just saying, you should get something that reproduces your actual error, and then copy-paste that verbatim; trying to make edits by hand will just introduce errors and confuse the issue
15:36duck1123I just recently found some old printouts of TI-basic games I had written. How did I ever live with only GOTO for flow control
15:42dnolenNikelandjelo: do you have a gist? there are typos in what you pasted I think.
15:42Nikelandjelodnolen: https://gist.github.com/1249029
15:42dnolenNikelandjelo: that said, core.match is very alpha and in the midst of some big changes - so use at your own peril.
15:43dnolenNikelandjelo: what input is failing?
15:44dnolenNikelandjelo: and are you getting match from Clojars?
15:45Nikelandjelodnolen: it fails while trying to expand match. Fails when I defining test. I use lein, so it must be from clojars
15:46dnolenone second, I'll update it which should fix your issue
15:46dnolenNikelandjelo: done
15:46NikelandjeloOk. I'll try now
15:46dnolenNikelandjelo: in general tho, it's best to use from source until I do a proper release.
15:48dnolenNikelandjelo: all that said, I certainly encourage people to experiment with it and file issues here - http://dev.clojure.org/jira/browse/MATCH
15:50Nikelandjelodnolen: ok, thanks. Yes, it works now. Thanks for link to jira project.
16:01bsod1hi, I'm trying to implement some algorithms in clojure, can anyone tell my why this code fails when I run (next-prime 16) but doesn't when I run (next-prime 11) ? http://paste.pocoo.org/show/484010/
16:02bsod1sorry, forgot to mention, the exception is 'infinite or NaN, java.lang.NumberFormatException'
16:03gtrakbsod1, which line errors out?
16:03bsod1gtrak: I don't know, I'm using counterclockwise and it doesn't tell this kind of useful information
16:04gtrakah.. you don't get a stack trace?
16:04gtrakI'll give it a go
16:05bsod1gtrak: here's my stack trace http://paste.pocoo.org/show/484014/
16:05gtrakit says line 151
16:06gtraklooks like the mod has an infinity
16:06gtrakthe one all the way on the right would get eval'd first
16:07gtrakhmm, actually not sure about that
16:08gtrakI would say add a bunch of lets and print statements, there's a useful trace macro floating around somewhere
16:08gtrakhttp://stackoverflow.com/questions/2352020/debugging-in-clojure
16:08bsod1gtrak: ok, thanks for the link
16:09gtrakbut you can see it's all promoted to bigdecimal
16:20hiredmanhttp://hg.openjdk.java.net/mlvm/mlvm/hotspot/file/0afdd88556bc/tagu.txt very exciting
16:24amalloyhiredman: so that's like...i'm not entirely sure i know what tagged unions are in this context. union types, basically? "An object whose type is either Integer or String"?
16:25hiredmanfixnums
16:26gtrakwhat's a fixnum?
16:26hiredmannon-primitive composite value types
16:26amalloy*blink*
16:27hiredmanhttp://blogs.oracle.com/jrose/entry/fixnums_in_the_vm
16:29amalloythanks
16:30hiredmannow we just need tco
16:33pjstadigthen we'll be where guy steele wanted us to be in 1998
16:34hiredman:D
16:35hiredman~lisp machine
16:35clojurebotmy lisp machine is the jvm
16:40amalloyhiredman: neat. i'm surprised he says that closures and method references could benefit from this treatment; it seems to me that (a) the types might not be that frequently used, and (b) closures will generally have a payload that is larger than a few words
16:41gtrakdo you need tco for CPS?
16:42hiredmangtrak: depends
16:43technomancyooooooooh tagged unions are fixnums?!
16:43technomancywhy didn't they say so =)
16:46hamzaHow exactly do i add clojure.data.priority-map to leiningen ? tried [org.clojure/data.priority-map "0.0.1"] can find it.
16:46hamza*can't
16:47gtrakhamza, check clojars
16:47hamzait is not there
16:47hiredmanhamza: most likely no one has done a build
16:49hamzahmm but who build the one here http://build.clojure.org/job/data.priority-map-test-matrix/
16:51gtraknot sure i get it
16:51hiredmanoh there is a build, but you need to use the snapshot repos
16:52hamzaok but how do i refer to it? in dependencies
16:53hiredmanyou need to use the full version "0.0.1-SNAPSHOT"
16:55hamzawith this [org.clojure/data.priority-map "0.0.1-SNAPSHOT"] I get unable to resolve artifact
16:56hiredmansure, as I said you need to use the snapshot sonatype repo
16:57hamzado i need to add a repo?
16:59devnhamza: by what hiredman said: "use the snapshot sonatype repo"
17:10khaliGThe clojure ants link doesn't seem to work anymore. has anyone got the clj handy to paste up?
17:18sridclojurescript repl doesn't work for me -- TypeError: Cannot call method 'appendChild' of null
17:19sridwhat scares me is that there is source information in the traceback
17:19sridit only shows the compiled js. which means writing large scale javascript in clojurescript is just not a good idea yet.
17:39jaoA FF7 reviewer: "a great improvement on my old MBP with only 5 Gb of RAM". *Only* 5Gb. Ludicrous.
17:39jaooops
17:39jaosorry, wrong window
17:40gfrederi`that's the craziest password I've seen yet
17:40brehautsecure though
17:40gfrederi`surely
17:40gfrederi`well, not anymore
17:40gfrederi`switch out one of those 5's for an S maybe
17:41amalloygfredericks: still 100% secure. we'll all assume he's changed it, so we won't try the old one
17:41gfredericksI bet that was his motivation all along...
17:41gfrederickshe's won this round, but next time we'll know what to watch for.
17:42amalloyi really can't help but read that FF as Final Fantasy; i can't believe they want us to think it means FireFox
17:42jolysame here
17:43gfredericksmaybe they should have gone with MF. That doesn't mean anything else.
17:44technomancyFF7 really was the best.
17:48NetpilgrimIf I want to create an empty vector with a certain length, would (vec (repeat length nil)) be considered idiomatic?
17:49gfredericksNetpilgrim: looks fine to me
17:49brehautits not really empty though is it, its full of nils
17:49gfredericksI think calling it an "empty" vector is a bit misleading, as brehaut points out
17:49gtrak,[]
17:49clojurebot[]
17:49NetpilgrimWell, you can't really create a vector that's both empty and has a length greater than 0, can you?
17:50gtrak,(empty? [])
17:50clojurebottrue
17:50gtrak,(empty? [nil])
17:50clojurebotfalse
17:50amalloyno, you can't, which is why people are guessing at what you actually mean
17:50gfredericksNetpilgrim: I think "empty" normally communicates "of length 0", so that'd be contradictory in that case
17:50amalloyi mean, it's easy to make a vector of N nils, which seems like what you asked for
17:50Netpilgrimamalloy: OK, sorry. I'll try to be clearer next time.
17:51amalloynah, i'm just being pedantic. your included example-code made your desire clear
17:51Netpilgrimamalloy: I really don't care for the nils. I need a vector with a certain length to use it with assoc later.
17:51amalloy&(vec (range 10))
17:51lazybot⇒ [0 1 2 3 4 5 6 7 8 9]
17:52gfredericksthe poor processor running the ADD command for naught
17:52gtrakmeh, 80/20 rule
17:52gfredericks:)
17:52Netpilgrimamalloy: Doesn't feel right. If I populate it with numbers it looks as if I cared about the content.
17:52gfredericks&(repeat 20 :dont-care-bout-this-content)
17:52lazybot⇒ (:dont-care-bout-this-content :dont-care-bout-this-content :dont-care-bout-this-content :dont-care-bout-this-content :dont-care-bout-this-content :dont-care-bout-this-content :dont-care-bout-this-content :dont-care-bout-this-content :dont-care-bout-this-content :do... https://gist.github.com/1249359
17:52gfrederickswoops, not a vec
17:53amalloygfredericks: gist abuser!
17:53gfredericksamalloy: but if it was only 4 it wouldn't have seemed realistic!
17:53gtrak,:nil
17:53clojurebot:nil
17:53gfredericks,(boolean :nil)
17:53clojurebottrue
17:53gtraknull keyword pattern :-)
17:54gfredericksgtrak: a chapter in your upcoming book?
17:54gtrakha, yes
17:54gfredericks"Design Patterns for the Savvy Clojure Coder"
17:54gfredericksgtrak: I want a section on :nil vs. :null
17:55gtrakthere will be a special chapter on the :nil visitor factory memento
17:55gtrakfacade
17:56gfredericksI also think we need a certification exam
17:57gtrakindeed, I'll implement java in macros for a proper OO
17:59TimMc(do-java '(public class Foo \{ ... \}))
18:00gtrakyea, like that
18:00TimMcErr, that's a function, hold on
18:01TimMc(do-java public class Foo \{ ... \})
18:15sridcan new dependencies be added to a lein project without having to restart swank?
18:19amalloyno
18:38michaelr525hmm
18:38michaelr525just installed ido-ubiquitous
18:38michaelr525now i get Symbol's values as variable is void: collection when I press M-x
18:39michaelr525anyone know something about it?
19:56ataggartanyone know to whom we speak to get a new contrib version pushed to maven?
19:57jeremyheilerfor 1.2?
19:58ibdknoxataggart: I assume one of the stuarts
19:58ataggartyeah, I'm just going to send an email to clojure-dev
20:13pdk,(Math/pow 1 0)
20:13clojurebot1.0
20:13pdk,(Math/pow 2 0)
20:13clojurebot1.0
20:13pdk,(Math/pow 0 0)
20:13clojurebot1.0
20:14hiredmanhttp://en.wikipedia.org/wiki/Exponentiation#Exponents_one_and_zero
20:16amalloywhew, thanks hiredman. i was bracing myself for another aleph-0 iterations of (Math/pow x 0)
20:16ibdknoxlol
20:16gfredericks,(nth (map #(Math/pow % 0) (range)) 84872)
20:16clojurebot1.0
20:17gfredericksmaybe it's getting bigger but the difference gets rounded out of the float
20:21jeremyheilerhiredman: http://en.wikipedia.org/wiki/Exponentiation#IEEE_floating_point_standard
20:24hiredmanwhat about it?
20:25jeremyheilerhiredman: not sure, what was your point in the first place?
20:25jeremyheilerhiredman: oops, meant to @pdk
20:25jeremyheilerlol
20:25jeremyheilermy bad
21:54zakwilsonSo I'm running in to an issue where I'm using clj-time and the time objects it uses don't print readably. In CL, I'd be able to define a print function and a reader macro (and most likely, the library would have done so itself). What's the idiomatic way to make this easier to work with in Clojure?
21:57carki beleive the pretty printer has some way to customize its output
21:58brehauthttp://clojuredocs.org/clojure_core/1.2.0/clojure.core/print-dup
21:58carkahwell even better =P
21:58brehautzakwilson: i believe you define a method on print-dup for the class
21:59zakwilsonI was unaware of print-dup and print-ctor. Thanks.
21:59brehautno problem
22:00dnolen,#java.util.Date[0]
22:01clojurebot#<Date Wed Dec 31 16:00:00 PST 1969>
22:01brehautim curious what the -dup part of print-dup means
22:01dnolenzakwilson: if you're on 1.3.0 there literals now for deftype/record/classes
22:02dnolenzakwilson: but print-dup/ctor probably more flexible
22:04zakwilsondnolen: I'm not on 1.3 yet. My project uses quite a few libraries and I haven't gotten around to making sure they all work.
22:04dnolenzakwilson: gotcha
22:04cark,(binding [*read-eval* false] (read-string "#java.util.Date[0]"))
22:04clojurebot#<Date Wed Dec 31 16:00:00 PST 1969>
22:05carkmhh
22:05zakwilsondnolen: and it's in production, so I don't want to update it haphazardly even though it's not in a very important role yet.
22:09zakwilsonOn another note, I have a bunch of maps and I want to persist them in a data store that makes getting them by key easy. I do NOT want all of my data in memory at once or I think Redis would be the way to go. I'm tempted to just use the filesystem and slurp/spit but that doesn't seem to be the most performant way to go. Any suggestions?
22:10carksqlite =)
22:10dnolenpretty awesome to see that the ClojureScript compiler is eatin Clojure's own dogfood - no types, just plain maps and multimethods
22:11seancorfieldzakwilson: MongoDB?
22:11zakwilsonI'm very sure an RDBMS isn't what I want. Mongo might be.
22:11carkoh you're the one !
22:11seancorfieldwith congomongo it's easy to save / read maps against mongodb...
22:11seancorfieldwe have that in production at world singles
22:11brehautdnolen: why?
22:12zakwilsonWhat's world singles?
22:12carkdnolen: i had some strange thing hapenning with core.match, wasn't working the same from a AOT program
22:12dnolencark: yup, this why I should have used maps and multimethods. that should be fixed now.
22:13carkah ok i see i'm coming after the battle =P
22:13dnolenextend-type is not something that AOT can know about.
22:13dnolenso bad stuff was happening if you weren't using core.match at the REPL
22:13brehautdnolen: would multis and plain maps had as good performance?
22:13carkthat's the troulbe, multis are slow
22:14carktho usually good enough for me
22:14brehautcark: but match uses them in the compiler right?
22:14dnolencark: brehaut: this a compiler we're talking about, I'm not sure it would have made much difference here.
22:14dnolennot one that most users would care about anyway.
22:14brehautdnolen: that does make sense.
22:14carkahh ok
22:15brehauthttp://xkcd.com/303/
22:17chouserdnolen: multimethods instead of deftypes?
22:17dnolenchouser: yeah
22:18amalloybrehaut: "dup" has always sorta seemed to me to be related to "duplicate", but it's not really clear how that fits in with "print readably"
22:18dnolenchouser: actually, we already using multimethods everywhere. really just representing our types w/ maps.
22:18chouserah
22:18brehautamalloy: yeah thats as far as i could get (eg, dup2 in posix)
22:19dnolenchouser: types and the protocols those types are involved in
22:23dnolenwow backtracking saves a lot of space!
22:23dnolenGOTO FTW
22:24zakwilsonIf I want to use a Clojure function instead of the constructor, is there a more reasonable thing to do than (str "#=(parse (formatters :rfc822) " (unparse (formatters :rfc822) o) ")")? Outputting code by string concatenation seems the the Wrong Thing.
22:32tomojso why output code by string concatenation?
22:32tomojI don't get it
22:40nappinghttp://www.haskell.org/hoogle/?hoogle=setHeaders
22:40zakwilsontomoj: I want both human and reader readability here. I'm not sure how best to get it.
22:40nappingsorry, wrong channel
22:41nappingclick through to the haddock
22:41nappinggrr
22:42nappingclick through to the haddock
22:42tomojzakwilson: huh?
22:42tomojwhat are you actually trying to do?
22:43zakwilsontomoj: were you present in the channel for the initial question about clj-time and readable printing?
22:45mcoffbyonehi all, I have been looking the internet for hints on how to implement undo/redo in clojure (I am manipulating a stateful Java object) this is my prototype (http://pastebin.com/Zm7vcazy), could anyone have a look its pretty short.
22:48tomojzakwilson: ah, no
22:48tomojI mean, yes
22:48tomojbut I hadn't seen it
22:50cark,(prn (let [o "hello"] `(parse (formatters :rfc822) ~o)))
22:50clojurebot(sandbox/parse (sandbox/formatters :rfc822) "hello")
22:50carkno string concatenation
22:50carkdoes this answer your question ?
22:50brehautmcoffbyone: i think a vector zipper of functions of current state -> new state should do
22:51tomojstill going to have to concatenate #= onto str of that
22:51tomoj?
22:51brehautmcoffbyone: look at clojure.zip/vector-zip
22:51carki guess =)
22:51mcoffbyonebrehaut: thanks, I will have a look
22:52amalloymcoffbyone: you should be aware of ##(doc update-in)
22:52lazybot⇒ "([m [k & ks] f & args]); 'Updates' a value in a nested associative structure, where ks is a sequence of keys and f is a function that will take the old value and any supplied args and return the new value, and returns a new nested structure. If any levels do not exist, hash-maps will be created."
22:52amalloyand also :keys destructuring, it looks like
22:54mcoffbyoneamalloy: update-in is exactly what I I need, thanks
22:59zakwilsoncark: yeah, what tomoj said. I think I'll just use print-ctor and not worry about human-readability.
23:00sjlCan anyone point me at a sane README for how to use Redis with Clojure?
23:02sjlI'm trying to use redis-clojure but one of the following happens: the lib is out of date, the new version doesn't match the docs, or I get cyclic dependencies.
23:04mcoffbyonebrehaut: the zipper is new to me, although it is similar to functional-graphs (http://web.engr.oregonstate.edu/~erwig/fgl/haskell/), I generally find it difficult to think of trees/graphs in inductive terms.
23:05brehautmcoffbyone: the zippers are a little confusing for linear structures as its a general tree walking lib
23:06brehautmcoffbyone: you could write a pathalogical one by hand to handle just a doubly linked list
23:08mcoffbyonebrehaut: I have two stacks where move forward/backward by moving do/undo functions between them, its ugly
23:09brehautyeah thats the one
23:09brehautand its not ugly :P
23:09brehaut(conceptually)
23:11mcoffbyonebrehaut: I have to avoid saving copies of objects, because ontologies can become huge
23:11brehautmcoffbyone: dont save the _state_ save the transformation
23:12mcoffbyonebrehaut: this is what I do the a "do" function modifies the object and returns the "undo" function+arguments
23:13mcoffbyonethis part would be difficult in java without some huge designe patterns
23:16amalloysjl: just use aleph's redis support. redis-clojure is not so great from what i hear
23:17ibdknoxsjl: https://github.com/nathell/redis-clojure/branches/clojure-1.2
23:17sjlamalloy: I've never heard of aleph (I'm usually not a clojure person)... I'll take a look, thanks.
23:18ibdknoxI've used that one for typewire, had no real issue with it
23:18ibdknoxthere's also this one, which wraps the fairly well built java redis library: https://github.com/mmcgrana/clj-redis
23:19ibdknoxI would probably go with clj-redis
23:20ibdknoxZolrath: I pushed that change up, you should be able to have spaces in your routes now :p
23:20Zolrathibdknox: You're the man, thank you very much!
23:21Zolrathibdknox: Thanks for letting me know that putting an event on a partial makes it work on newly created partials as well!
23:22Zolrathibdknox: I'm sinking back into closure to achieve what I'm trying right now as I assume theres no way with pinot to find the last occurance of a partial on the page?
23:23ibdknoxhm
23:23ibdknoxnot that I can think of, no
23:25Zolrathibdknox: Good to know, trying to make an auto pagination thing that calls for the next elements based on data in the last element
23:25Zolrathibdknox: pinot already does so many things I didnt think it would, seemed like a good idea to ask!
23:39brehauthahaha
23:39brehautsjl: having trouble with clojars?
23:48dnolencore.match is now a backtracking optimizing pattern match compiler
23:51sjlbrehaut: Nah, I tried aleph on amalloy's suggestion and it's working great.