#clojure logs

2012-09-13

00:07gtuckerkelloggtechnomancy: thanks. For some reasons nrepl-jack-in starts an nrepl server, but doesn't connect my clojure buffer to it
01:08MZAWebHi. I need to convert #{{2 2} {3 1} {1 4}} to #{2 2, 3 1, 1 4}
01:09RaynesThat isn't a map.
01:09RaynesThat is a set.
01:09RaynesYou can't have duplicate elements in a set.
01:10MZAWebactually I need key value
01:11RaynesIf you want to convert that set to a map, ##(into {} #{{2 2} {3 1} {1 4}})
01:11lazybot⇒ {2 2, 3 1, 1 4}
01:11MZAWeboh, cool, I think that's it
01:12MZAWebIndeed.
01:12MZAWebThanks a lot
01:17l1xhey guys, how could i write a function which takes all numbers except 0 and 1?
01:18l1xis there an idiom for this?
01:20l1xi was thinking (when-not ((= n 0) or (= n 1)) ...)
01:23amalloy(complement #{0 1})
01:26l1x,(and true false)
01:26clojurebotfalse
01:27l1x,(let [n 1] (and true (= n 1))
01:27clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading>
01:27l1x ,(let [n 1] (and true (= n 1)))
01:27clojurebottrue
01:27l1xgood
01:28amalloywhat result were you worried you might get?
01:29l1xi want to exclude some numbers from some functions
01:41l1xamalloy: https://github.com/l1x/euler/commit/8ff8a72b129baed081f62fef41e0d2656b2175c3#L0R184
01:41l1xlet me know if there is a better way of doing that
01:42amalloy(or (or x y) z) is just (or x y z)
01:42amalloy(if x false true) is (not x)
01:45l1xinteresting, i tried and x y z and it was not working
01:45l1xlet me try with or
01:46amalloythe same equivalence applies to and
01:49l1x (if (and (not (= n 1)) (not (= n 2)) (= (sum-of-factorials n) n)) true false))
01:50l1xyeah it works with and
02:05carkwould it be possible to have lein 1 and lein 2 coexist ?
02:05carki mean on a single home rather than on a single project
02:22amalloycark: easy. just name the executables (symlinks, whatever) lein1 and lein2
02:25amalloy(or, indeed, anything you want. my point is, just install them both; they don't conflict in any way)
02:26carkcool thanks ... i have some old projects that i still need to maintain, but don't want to upgrade
02:40tomojhuh, the clojure JIRA flowchart clearly shows patch submission coming _after_ the issue is verified by a clojure/core member and vetted by a clojure committer
02:54no7hingi'm trying to destructure a map to some keys in a macro, but all the symbols/keys are nil
02:54no7hingthe map itself is there allright
02:59carkdo you have a short gist showing your problem ?
03:00clgvno7hing: please make a gist where you show how your macro call should look like and what the expansion should be.
03:01clgvand your current implementation of course
03:01no7hingwriting it
03:16no7hingthe gist https://gist.github.com/3712523
03:17no7hingi *could* just do (:body body#) later on, but i might need the other keys too - and actually am curious what i'am doing wrong ;)
03:17carkaction# is not action
03:18hiredman,`action#
03:18clojurebotaction__27__auto__
03:18no7hingwhen i just use action the macro uses namespace/action
03:18carkyou should pass the full map as a parameter then destructure yourself
03:19clgvno7hing: so action/action# is the problem?
03:19no7hingyes
03:19no7hingit's nil later on
03:19clgvah right
03:19carkor destructure like this :
03:19clgvno7hing: well, do you really want to inject those names implicitely? in general that is discouraged
03:20cark(fn [{action# :action}]
03:20no7hinghaven't thought of that
03:20clgvcark: that wont work either since he cannot use it in the body
03:21carkoh indeed, didn't read the rest of it !
03:22no7hingbtw the choice of body as a key in the map and for the passed in function body is poor
03:22no7hingdon't let that distract you
03:23clgvno7hing: if I were you, I would pass the whole map and let the user destructure it
03:23clgvno7hing: otherwise it's likely that you curse yourself soon because you need an additional attribute from the map which you did not destructure
03:26carkhow about (fn [{:keys [~'action]}]) then goal is to capture the action "variable" right ?
03:26no7hingfamous last words: the three keys will never change; apart from that i'am trying to keep the passed in function as small as possible
03:26no7hingyes
03:27carkwell then there you go i think
03:27Guest94126cark: thats the implicit name capturing I meant before. (I forgot what the officil term was).
03:28no7hingit
03:28no7hing's not working anyway :D
03:30carkworking for me !
03:30no7hingumm
03:31carkhttps://gist.github.com/3712581
03:36no7hingthanks for helping guys
03:53sunkencityrylehwhat is the current best way of communicating with a repl from vim?
03:54sunkencityrylehI'd like to launch swank or whatever with lein and then send stuff to eval from a region
04:11Guest94126sunkencityryleh: do you use vim-clojure?
04:12sunkencityrylehGuest94126: I just downloaded slimv for vim
04:13sunkencityrylehGot it sort of running, but not quite, it doesn't seem to load much of clojure
04:13Guest94126sunkencityryleh: I heard that vim-clojure is actively developped
04:17kralnamaste
04:17sunkencityrylehOK, I'll look into vim-clojure
04:32lpetitBonjour tout le monde !
04:32RaynesWhatever you said right back at ya!
04:33lpetit;) I said "Hello everybody"
04:34carkoh you're french
04:34carkshould've been oblivious with your name !
04:35lpetitcark: so because I speak french, I'm French ? :)
04:36carknope, i'm from belgium and speak franch
04:36carkfrench
04:36carkso you're not ?
04:37lpetitIn Counterclockwise editor tabs (revealing the name of the edited file), how about displaying the namespace in reverse order ? e.g. for namespace "somebody.someproject.core" it displays "core.someproject.somebody" ? So that when there are a lot of tabs open, what disappears first is the end of the displayed string (which contains less context that the start) ?
04:37lpetitcark: no, I am. I was just kidding
04:38carklpetit: only a french person talks english with such an accent =)
04:39lpetitcark: (blush) (and blame my parents ;) )
04:39lpetitso true, btw
04:39carkhaha
04:40carkanyways just kidding, as long as people understand... who cares
04:41ro_stif we were all exactly the same, what point would there be to more than one of us :-)
04:41lpetitI wish I had a good english accent.
04:42antares_lpetit: a more common approach is to abbreviate initial ns parts, e.g. s.s.core
04:42antares_I believe Eclipse itself can do that, IDEA can, too
04:43lpetitantares_: already does the abbreviation, but sometimes it's still too long. So right now I'm adding an option for people to switch back to old behavior (which is just displaying the file name). But while doing it, the above mentioned idea occurred to me
04:45antares_lpetit: sounds like if you are completely out of space, only displaying the rightmost part is the best idea
04:45antares_reversing is likely to be even more confusing
04:45lpetitantares_: probably, yes
04:46ro_stcan you not hover a tab to see the full path or ns?
04:46ro_st(not a ccw user, just curious)
04:48lpetitro_st: you can, indeed, but some people have lots of open editors and don't want to move their mouse over each tab, wait for the slight delay before the popup shows up, etc.
04:48ro_styeah
04:53carkin emacs, i have it so that it will only show what's different so if i have cark.data.lenses and cark.example.lenses it will show lenses<data> for the former and lenses<example> dor the later
04:53clojurebothave you heard about the bird? is<reply>The bird, bird, bird, the bird is the word.
04:53carkdor/for
04:55borkdudewhat can I tell people about the usage of clojure, any numbers?
04:59lpetitcark: sounds great
04:59carki wonder how you could find such numbers
05:04ro_stthe google group has 5k+ members
05:04KIMAvcrphi
05:05antares_ro_st: I think it has closer to 7K
05:05ro_stoh right :-)
05:05KIMAvcrpI found something strange using enfocus and a browser connected repl
05:06KIMAvcrpif I user set-attr to set the value of a field the browser does not update the change
05:06KIMAvcrpmanual changing with (.-value (dom/getElement ...) "text") does work
05:06KIMAvcrpany idea ?
05:07ro_stdoes the code work when you run it in a compiled cljs context?
05:07ro_stpaste the code on refheap as well, please
05:10KIMAvcrpit doesnt work in the compiled context
05:10KIMAvcrp heres the code
05:12KIMAvcrphttps://www.refheap.com/paste/0b3021f60da47e24a572de369
05:12ro_st"press" is telling enfocus to look for a tag named press
05:12ro_stie, <press />
05:12ro_stdo you not perhaps want .press or #press instead?
05:13KIMAvcrpsaw it just the instance
05:13ro_styou can also use :keywords instead of "strings" now
05:13KIMAvcrpstrangely dom/getElement works with "press"
05:13ro_stwhat do you have in html? class="press" or id="press" ?
05:13ro_stgetElement will find id="press"
05:14ro_st# is a css selector thing, the js vm knows nothing about it
05:14ro_stbe nice once the js vm does have getElementsByCSSSelector :-)
05:15ro_stKIMAvcrp: https://github.com/robert-stuttaford/demo-enfocus-pubsub-remote/
05:18borkdudeis this table correct, did I forget anything important? https://www.dropbox.com/s/9w16xwjd4x88u46/comparison.png
05:18borkdudeit's in dutch but I think you can figure out what the words mean
05:18borkdudeit's not so much about language features that are theoretically possible, but about the learning experience
05:18borkdudeso what concepts will you meet, when working in a language
05:18ro_sthomoiconicity
05:22KIMAvcrpin the html <input type="text" name="press" id="press" value="1" size="1"/>
05:22KIMAvcrpbut if i use "#press" or :#press as selectors again the browser window doesn't change
05:23KIMAvcrpis (em/set-attr :value "5") right ?
05:24ro_stset-prop
05:24ro_stfor :value
05:24ro_stthat one caught me as well
05:24ro_stusing attr you'll see the html source view in chrome updates, but the actual rendered view doesn't
05:25ro_stthis is because set-attr affects the dom but doesn't trigger the form side of things. set-prop does
05:26borkdudegtg
05:30carkhow would i go about creating a set, where identity is on a function of the set item rather than the set item itself ?
05:31KIMAvcrpthank you @<ro_st>
05:31KIMAvcrpit works
05:31KIMAvcrpbtw: is there a better way to require libraries in the live-repl as via the ns macro ?
05:32carksomething like (set-by :id [{:id 1 :name "paul"} {:id 2 :name "john"}])
05:32ro_stso you want a set of the ids, here?
05:32ro_st(set (map :id items))
05:33carknope i want a set where adding {:id :name "cark"} would "overwrite" {:id 1 :name "paul"}
05:33carknope i want a set where adding {:id 1 :name "cark"} would "overwrite" {:id 1 :name "paul"}
05:33ro_stah, that you'd have to implement yourself
05:34cark=(
05:34ro_sta gatekeeper fn that checks and replaces
05:34KIMAvcrpwhy don't you use a map from :id to :name instead of a set
05:35ro_styeah
05:35ro_stmap keys have to be unique
05:35ro_st(assoc m (:id item) item) would replace
05:35carkthat's only an example, i'm storing an "object" that can only be queried for id via a function
05:36carkand i want to have set capabilities
05:36carkbut that's no big deal, i can work around it
05:36ro_styeah
06:07Guest94126lpetit: hello overthere
06:08lpetitGuest94126: Hello stranger
06:11Guest94126stranger? damn. have to relogin then ^^
06:12clgvlpetit: better now.
06:13clgvlpetit: it's a pity I cant use CCW 0.10.0 at work, yet. this "build all" error makes it unusable in that project... :(
06:14lpetitclgv: remember me the issue number please
06:14clgvlpetit: 425
06:14clgvthe new one ;)
06:15lpetitclgv: It's on my todo list for today.
06:15ro_st*helps lpetit with his english* "remind me"
06:15clgvlpetit: hooray! :D
06:15lpetitro_st: that's what happens when I type too fast
06:16lpetitI meant when I type too quick :-P
06:16lpetitclgv: but first I'm currently working on correct support for tagged literals
06:30lpetitclgv: that's the focus of the day
06:52KIMAvcrphi
07:02clgvlpetit: can you answer me a question about the nrepl setup of CCW?
07:02lpetitclgv: sure
07:02lpetitand also cemerick could be of some help
07:03clgvlpetit: do I have access to the nrepl namespaces from the CCW repl?
07:03cemerickclgv: yes
07:03cemerickThe server-side of it, anyway.
07:04clgvlpetit: so it is on the classpath and I might get problems if I want to use a different nrepl version in my project?
07:04lpetitclgv: no, it is only added to the class path if it is not found in your project's java build path
07:05clgvlpetit: interesting. thx.
07:05lpetitclgv: anyway, this will probably evolve in the (near) future, when CCW will use a (yet to be implemented) Leiningen Eclipse Launcher
07:06xeqidoes ccw implement the "describe" and "file-load" ops?
07:06cemerickIt uses them when available, yes.
07:06lpetitcemerick: time to enlighten me
07:06lpetit(I only have a vague idea of what's happening under the hoods)
07:07cemericklpetit: See REPLView.getAvailableOperations, and usages of it.
07:07clgvlpetit: I want to migrate that debug-repl macro (or "break it's called in slime) to use nrepl. so that I can connect with a CCW replview
07:08clgvxeqi: what's "describe"?
07:08lpetitcemerick: i will
07:10xeqicemerick: thanks, I was hoping to use ccw as a refrence point when looking at the nrepl.el impl
07:10xeqiclgv: an op code used under the hood by nrepl to determine what other op codes the server accepts
07:11cemerickxeqi: FWIW. REPLView and its helpers are in dire need of a refactoring. Typical Java pig-pile in there.
07:12clgvcemerick: can I initialize an nrepl server similar to clojure.main/repl via :init?
07:13cemerickclgv: no; nrepl is a network service, not an in-process thing bound to *in*, *out*, etc. See clojure.tools.nrepl.server.
07:14clgvcemerick: yeah. knew that. but I thought, maybe the is some way to do an initialization of threadlocal storage for its execution thread
07:15cemerickclgv: Sorry, what are you trying to do?
07:15clgvcemerick: you know `debug-repl` or `break` ?
07:15cemerickSure, the SLIME stuff.
07:17clgvboth start a clojure.main/repl or similar. I would like to replace that with the nrepl server. one nrepl-server per `debug-repl` statement. I would suspend the executing thread until a (resume) is evaluated
07:17lpetitcemerick: sure thing, REPLView could be refactored. But now may not be the time. I think the right time will prompt when it's too difficult to work with the current codebase anymore
07:17cemericklpetit: Yeah, not in any hurry to actually do it. :-)
07:18cemerickclgv: Sure, definitely doable.
07:18cemerickYou shouldn't need to start another server, though.
07:18cemerickAnother connection, yes.
07:19clgvcemerick: how would you mange different contexts in a multithreaded application then?
07:19clgvjust one server and one connection while representing context as data in a given variable?
07:20cemerickNo, one server, many connections.
07:21clgvmay use case looks like the following: debug-nrepl starts a server if there is none, stores the context info and prints connection info to the repl. I connect via CCW's repl view to the nrepl and can start to investigate.
07:22cemerickEach break would need to prep a queue, and hijack the newly-connected client's "eval" messages into that queue to be evaluated in the break context.
07:25clgvcemerick: what's the reason not to start multiple servers on different ports do that each active break has a random port that is printed to stdout for the user to connect to?
07:27cemerickWhy bother with another server?
07:28cemerickYou still need the same sort of coordination between the paused execution context and the new incoming client messages.
07:29ejacksonhow do I disconnect from an nrepl attached via nrepl-jack-in in emacs ? Preferrably killing the server so I cant start another ?
07:29xeqiejackson: kill the *nrepl-server* buffer
07:30ejacksonxeqi: thanks
07:32cemerickxeqi: Nice post re: pedantic. :-D
07:33clgvcemerick: where would I start to implement this? a custom handler for nrepl?
07:33xeqicemerick: heh, I was wondering if I was just rewriting the readme at one point
07:34cemerickxeqi: to some extent you were, but that's fine; no one reads READMEs.
07:37cemerickclgv: Aside from the suspension functionality of (break), you're probably looking at some middleware to intercept "eval" messages from a client that connects and joins that "debug context".
07:38cemerickThat said, I do always hope that someone (else ;-) will get around to implementing debug-repl in conjunction with proper JVM breakpoints, rather than the (break) approach that SLIME used.
07:41clgvhumm still not sure if nrepl's session could be used for storing the context
07:42cemerickclgv: You can store anything in the session you want — it's just an atom.
07:42clgvthe descriptors give a nice usage summary though ^^
07:43cemerickYeah, once I flesh them out more, a script will be used to dump a listing of the ops supported by the available middlewares.
07:44clgvhumm you get the initial session by connection and after that you clone it to get more?
07:45clgvbut overall it seems more complicated than I thought. got to postpone the idea
07:56mccraigibdknox: i made a (tiny) patch for korma, which doesn't affect current behaviour, but allows it to use connections opened elsewhere https://github.com/korma/Korma/pull/88 . does that seem reasonable ?
07:59carkI just pushed a first public version of the little lenses library i was working on. Lenses are also known as functional references. there is a little tutorial included as well, i'd love to see îf some people would use these. it's at https://github.com/cark/data.lenses
08:01clgvcark: your readme is contradicting. it says no clojars upload but provides an entry for a project.clj ;)
08:01carkyou need to install in the local repository
08:01clgvah ok
08:02carki *think* lein install is all that's required to do that
08:02carkmaybe a lein deps first
08:19ordnungswidrighi all, I'm looking for an simple web application idea which i can use for a liberator tutorial. I'm bored by all that todo-list-tutorials.
08:21carka super-hero powers database
08:22carkeverybody loves suyper-heroes
08:23ordnungswidrigcark: nice idea
08:24carkyou get 2 sets, 2 entity types, and relation between them, good for demonstrating your rest api
08:25ordnungswidrigcark: you mean heroes and super powers?
08:25carkyes
08:25ordnungswidrigi think that can work out
08:26carkit's actually many to many, so i guess 3 entity types
08:26carkanyways
08:26ordnungswidrigcark: depends on your model. it would be two http resource collections.
08:27carkfor many-to-many you may require a hero-power collection too
08:28carkbut it's just a tutorial, you could make it so that flying power for superman is different than flying power of err ... metalman
08:28carkwhat's his name =/
08:29clgvironman? ;)
08:29carkindeed =)
08:29carki suck at super-heroes =)
08:29clgvit is different: one is natural the other technical ;)
08:29carkif you ask me, neither is !
08:30ordnungswidrigcark: is there a encyclopedia of superhero?
08:30carkordnungswidrig: i suck at super-heroes ! i wouldn't know that !
08:33carkyou only need a couple heroes and powers for a tutorial, you can even make them up
08:33carkhttp://www.superherodb.com/characters/
08:34carkwhere you learn that superman has super smell ...
09:11naegwhy does (bit-shift-right 30 8) => 0 but (bit-shift-right 0011110 8) => 18 ?
09:13jsabeaudrynaeg, because 30 != 4680
09:14naegjsabeaudry: ,(Integer/parseInt "0011110" 2)
09:14chouser,(format "%o" 0011110)
09:14clojurebot"11110"
09:14chouseroctal
09:15naegoh, i thought that was binary
09:15chouser2r0011110
09:17jsabeaudrychouser, oh nice I wasn't aware of binary litterals in clojure thanks!
09:17chouserarbitrary radix literals up to, I think, 36
09:18chouserjsabeaudry: but that means you haven't read the book. tsk tsk.
09:19jsabeaudryelementary my dear chouser ;)
09:45naegblog post about checking for a winner in connect four in clojure: http://programmablelife.blogspot.co.at/2012/09/clojure-connect-four-1-checking-winner.html
09:45naegwould be great if someone could give me some feedback before i put it on HN, etc.
09:50casionnaeg: reading
09:51naegcasion: i'm just adding two code line explanations to the bitboard algo...
09:52casionI'm confused by your bitboard
09:52naegcasion: the picture?
09:53casionsec, app broke
09:53clgvnaeg: doall + map for printing is not ideal ^^
09:53naegclgv: I guess I should use doseq?
09:53clgvnaeg: if you print the array brackets anyway, you could just use pprint ^^
09:54clgvnaeg: yeah, doseq
09:54naegI now remember why I did it: just as a quick hack because map didn't really execute the printlns
09:54clgv,(pprint (repeatedly 5 (range 10)))
09:54clojurebot#<CompilerException java.lang.RuntimeException: Unable to resolve symbol: pprint in this context, compiling:(NO_SOURCE_PATH:0)>
09:54clgv,(use 'clojure.pprint)
09:54clojurebotnil
09:55clgv,(pprint (repeatedly 5 (range 10)))
09:55clojurebot#<ClassCastException java.lang.ClassCastException: clojure.lang.LazySeq cannot be cast to clojure.lang.IFn>
09:55clgv,(pprint (repeat 5 (range 10)))
09:55clojurebot((0 1 2 3 4 ...)
09:55clojurebot#<SecurityException java.lang.SecurityException: denied>
09:55clgvdamn...
09:55naegclgv: I don't have pprint available
09:56clgvit's in clojure.pprint and usually available in a repl
09:57casionnaeg: why is there a a vector board and bitboard in the same vector?
09:58naegcasion: because of insert and the game loop (which I didn't show here)
09:59casionnaeg: ok, that was confusing me quite a bit
09:59clgvnaeg: how did you benchmark?
09:59naegcasion: really? why would it mather?
09:59naegmatter*
09:59naegclgv: there's a paragraph about performance, but not really benchmarking
09:59casionnaeg: because I read code top to bottom?
09:59casionin the bitboard example if I seen a 2d board rep, I'm sitting here wondering why it's there and if/why it's used
09:59clojurebotIt's greek to me.
10:00clgvnaeg: you should at least wrap the code in dotimes and measure the time of the repeated executions ^^
10:00naegcasion: that's just for us humans to better understand it. in the code it's just passing around longs
10:01naegclgv: i did that and put the average time into the article
10:01casionnaeg: not when the person reading it has spent dozens of hours using bitboards ;)
10:02naegcasion: then that algorithm shouldn't be too hard to grasp ;) but I'm confused by his explanation (which differs from mine: http://stackoverflow.com/questions/7044670/how-to-determine-game-end-in-tic-tac-toe/7046415#7046415)
10:02casionnaeg: I was having trouble following you epdating 2 board representations
10:02casionupdating*
10:03casionmy mistake I think, I took the header for that section too strictly
10:04naegcasion: I can't follow you? I need two boards, because each player has his own pieces
10:05casionnaeg: I was getting tripped by the vector board being in that example, that's all
10:05casionquite simple and silly :)
10:06naegok. I just want to be sure it's understandable, you see ;) but I think I mentioned that I use 3 boards
10:07casionyou do, as I said it's my deficiency
10:09casionnaeg: when you explain the board checking in bitboards, it maybe helpful to label the rows when explaining the steps
10:09casion'0110100 & 0011010 = 0010000' row 2, '0111100 & 0011110 = 0011100' row 1, etc..
10:10naegcasion: label what exactly with what?
10:10casionI gave an example, ctrl-f the stuff in quotes
10:12casionthe logic section is nead
10:12casionneat*
10:12naegcasion: label like that?
10:12casionyeah
10:12casionthat's more clear I think
10:12naegcasion: indeed, thanks. I like the logic solution the most actually
10:12naegit's also the one I put the most thinking in myself
10:17naegclgv: removed all the doall's, thanks :)
10:29naegcasion: would you say you understood everything I tried to explain?
10:32aibHow would I go about using this library in "lein repl"? https://github.com/clojure/algo.monads
10:33casionI don't totally understand the code in the logic example yet
10:34casionI get how it's doing the search, but how the code is achieving is has me constantly referring to core.logic docs
10:35casionI've never used core.logic (or any logic programming) so, I'm not sure if I'm the target audience for that or not
10:36clgvaib: you got a project setup?
10:36aibclgv: nope, just want to play around in the REPL
10:37clgvaib: leiningen 2?
10:37jweissis there a simple way to use defrecord, but have it error out if you try to access a field that wasn't part of the original definition? the normal behavior is to return nil. for instance if i fat-finger :foo as :floo in (myrec :floo) - i want an exception instead of nil.
10:37naegcasion: I don't even know how exactly core.logic works internally, if that is what you mean. But I'm able to work with it (since I know how Prolog works internally)
10:37aibLeiningen 1.7.1 on Java 1.7.0_07 Java HotSpot(TM) Client VM. I need an update?
10:38clgvaib: I do not know if you can specify dependencies in a file under ~/.lein/
10:38naegcasion: but you understood it from a "user" perspective, so core.logic is like a black box with which he could work
10:38clgvaib: with lein2 you can define profiles in ~/.lein/profiles.clj
10:39aibclgv: I can't just type (use 'clojure.algo.monad) as my first REPL command or something?
10:39clgvaib: there you could add the desired libs as :dependency in the :user profile
10:39aibhmm
10:39clgvaib: you can - but it wont find anything ;)
10:39aibahh
10:39the-kennyIf I do a subvec on a large vector, will it stop the large vector from being gc'd when I don't reference it anymore?
10:41aibwell, let me play around a bit with lein2 first. thanks :)
10:41clgvthe-kenny: yeah. it holds onto it. otherwise it would be O(n) instead of O(1)
10:41the-kennyclgv: Okay, thanks
10:44casionnaeg: I don't know logic programming _at all_, and it seems that it's a pre-requisite to understand algo-3's implementation. If that was your intent then I can't comment… but if you intended on explaining to someone with no logic programming experience, then it's not working for me
10:45aiberm, https://cloud.github.com/downloads/technomancy/leiningen/leiningen-2.0.0-SNAPSHOT-standalone.jar returns Access Denied :/
10:45aibah, leiningen-2.0.0-preview10
10:45xeqiaib: you need to use `lein new` and make a project, add [org.clojure/algo.monads "0.1.0"] to the :dependencies, and `lein repl` in the project will let you use it
10:46aibxeqi: okies, thanks :)
10:47clgvxeqi: do you really need to? I think you should be able to add it as dependency to the :user profile
10:47clgvthe same you do with :plugins you always need on that machine
10:47xeqiclgv: perhaps, though do you really want algo.monads accessible everywhere?
10:48clgvxeqi: well he can define a different profile then :user e.g. :monads and use "lein2 with-profiles :monads repl"
10:49clgvwithout the ":" I think ^^
10:50xeqiheh, thats not really any simpler
10:51clgvbut if he doesnt want a project it's the only way
10:51naegcasion: I actually wanted people with no experience in LP to understand it
10:51naegwill have to re-work that paragraph then
10:53clgvis clojure.core/require threadsafe?
10:54naegcasion: I just read through it again, and I don't know what I could add beside explaining +fd
10:54xeqisure, but if a project isn't desired, no reason to use a build tool designed for projects
10:54casionnaeg: that's exactly the part that I'm struggling with, lines 17-18
10:55casionand 7
10:55clgvxeqi: well lein doesnt necessarily need a project to start a repl. a better solution would be to add pomegranate and use it to get the deps to play with
10:55casioninfd and +fd, and I'm having trouble even finding docs for it
10:55naegcasion: for all those lines I just wrote what the line as a whole does, not what each function does. could that be the source of your confusion?
10:56naegcasion: those functions are alpha
10:56xeqieh, pomegranate doesn't do any dependency tracking of whats already on the classpath; it might work, or it might pull in a completely different version of clojure
10:56naegonly documentation is the source code and examples you find in the web
10:56clgvxeqi: no I mean he could get the monads lib via pomegranate ^^
10:56xeqiit'll pull in all transative dependencies
10:57xeqiand some of the org.clojure stuff uses 1.3.0-alpha versions
10:57casionnaeg: yeah, lines 17 and 18 have different descriptions for the same function (17 declaring, 18 'making sure') so I'm trying to find out what infd does
10:57clgvI dont think it is that buggy. leiningen uses it and it's advertised especially for that purpose
10:57naegcasion: well, declaring and making sure is the same. those are just rules
10:58clgvthough I haven't used it much, yet
10:58xeqiclgv: given a full dependency list it will work out what transative deps to use
10:58xeqiwhich is how lein does it
10:58casionnaeg: well, I don't work with logic, so when I see 'declare' I think some sort of constant, and 'making sure' I think of a conditional
10:58naegcasion: I'm reverting it to a draft again, so make sure either to not reload the tab or copy the content somewhere. I'm leaving now, add a few more explanations later that evening and then publish it. do you think it's suitable for planet clojure?
10:58xeqibut if you're adding to the classpath, and just give it one dep, it might pull in a different transative version of a dependency already on the classpath
10:59casionmaybe in this domain it's semantically the same, but I wouldn't know that :(
10:59clgvxeqi: so it's not safely usable for this: https://github.com/cemerick/pomegranate#add-classpath-usage
10:59naegcasion: it's the same. I wrote a note about your confusion, you're probably not the only one
10:59clgv?
10:59casionnaeg: sure, it seems overall good to me :)
10:59casionI learned some things from it for sure
11:00naegcasion: it's not meant for "clojure experts", that's why I wasn't sure
11:00naegbut as you said, I think even clojure experts might learn one or two things from it
11:01naeg(especially if they haven't done anything with core.logic yet)
11:01casionnaeg: I'm not a clojure expert, and I learned from it… even the logic part (though I'm still not 100% clear on it)
11:01naegcasion: thanks for all your input and bye all
11:01xeqialways safely, no, but it should work most of the time
11:01xeqior work well enough
11:01casionthanks to you too :)
11:03clgvxeqi: do you know whether clojure.core/require is threadsafe? I have to use it from different threads since I must resolve functions from symbols
11:05xeqino idea, haven't done any work on clojure internals
11:07clgvok. I try to find out ^^
11:07uvtcWhat's a good way to provide a user-editable config file for your Clojure project?
11:08uvtcA resources/config.properties file?
11:09nDuffuvtc: Depends. If you're trying to interoperate with the Java world, a properties file makes sense. If you don't care about that, using the Clojure reader can certainly be handy.
11:10uvtcHm. Just have your users edit a config.clj file.
11:10uvtcnDuff: Thanks.
13:22cemerickdnolen: thanks for the quick patch turnaround. Greatly appreciated. :-)
13:23dnolencemerick: np
13:35thorbjornDXhash-map from two seqs: (hash-map (interleave seq1 seq2)) ? Or is there a better way.
13:36dnolenthorbjornDX: zipmap
13:36thorbjornDXdnolen: thanks :)
13:38thorbjornDXdnolen: from the source, it looks like this will go until one of the seqs gives nil, is that correct?
13:39borkdude,(zipmap [nil 1 2 3] [1 2 3 4])
13:40clojurebot{3 4, 2 3, 1 2, nil 1}
13:40thorbjornDXborkdude: oh, hm. What does the '(if (and ks vs)' in the function definition do then?
13:41dnolen,(zipmap [:foo :bar :baz] (range))
13:41clojurebot{:baz 2, :bar 1, :foo 0}
13:41thorbjornDX,(seq nil)
13:41clojurebotnil
13:41borkdudethorbjornDX dnolen why use English if we can speak clojure
13:42thorbjornDXborkdude: english can be a bit verbose, especially for abstract cs
13:42dnolenthorbjornDX: yes the shortest sequence limits the size of the map.
13:43thorbjornDXdnolen: that's what I expected, thanks ;)
13:43thorbjornDX,(next '())
13:43clojurebotnil
13:43thorbjornDX,(rest '())
13:43clojurebot()
13:44thorbjornDXok, things are getting more clear now
13:44borkdudegtg, bye
13:44abalonein cljs and clj, .replace affects all occurrences. in the generated js, it affects only the first. where should i report this?
13:45dnolenabalone: it's an interop call, there's no promise about that stuff.
13:46abaloneoj
13:46abaloneoh
13:46abalonethanks
13:51TimMcHey, anyone ever seen a metadata destructuring proposal?
13:52TimMcI don't feel a need for it, but I'm curious if anyone else has.
13:53cemerickVery occasionally, but the extra line of code hasn't bothered me enough to suggest adding the necessary complexity to the language.
14:07LicenserOut of curiosity what book should I give a clojure beginner? (no programming experience)
14:08ystaelcemerick: I am trying to add an nrepl server endpoint to an existing Java server application. Is the advice you gave in February in https://groups.google.com/d/msg/clojure/6jEdlYSX_zg/Q33_egSaxxEJ still current?
14:09ivanLicenser: I'm not sure Clojure is a good idea for someone with no programming experience until Light Table is productive
14:09cemerickystael: should be, yup
14:10Licenserivan well it's just baby steps for now so the current LT's live repo is enough for a few month I guess :)
14:10ystaelcemerick: cool, thanks
14:10scriptorLicenser: I think I saw one online thing that used clojure but aimed at complete beginners
14:10scriptorcan't remember the name though
14:11ivanLand of Lisp?
14:11Licenserscriptor yea the one with the robot right?
14:11scriptorLicenser: yep
14:11casiona lot of colleges start with scheme as a first language (mit does still I think?)
14:11scriptorI think
14:11casionmany start with java...
14:11Licenserscriptor we're past that one :)
14:11casionwhy not start with clojure? :)
14:11cvkem_Hi, I recently noticed that dynamic generated code via (eval (read-string ...))
14:11Licensercasion my point exactly!
14:11technomancyI'm not sure starting programming with a book that is spread across 3 or 4 different languages is such a good idea =\
14:12casiontechnomancy: 3-4 languages?
14:12technomancycasion: Land of Lisp focuses on CL with some chapters for Scheme and Clojure IIRC
14:13scriptorI get the impression that most clojure books assume about the same level of programming experience
14:13aduwhich languages?
14:13casiondid someone mention land of lisp?
14:13casionI'm a bit lost
14:13casionoh, someone did
14:13aduivan
14:14curiousgerogeHi, I am interested in Clojure. Have done some work in haskell years ago. On what type of projects is a FP languages such as clojure a good fit?
14:14aducasion: I think scheme makes a great first language, the function names are long, verbose, and unambiguous
14:14casionLand of Lisp is the sole reason why I tried clojure instead of CL or scheme
14:14technomancycuriousgeroge: anything where you can use the JVM, so as long as you don't need a low memory ceiling, fast startup time, realtime, or zippy numerics.
14:14HodappI'd love to get through SICP sometime.
14:14Hodappbut... bleah, busy
14:14casionit scared me away from cl pretty fast :|
14:15technomancycasion: interesting. I only read the sample so I thought it was biased in favour of CL.
14:15technomancythe Clojure port of Casting SPELs by the same author was a bit half-baked
14:15wastrelwhat's Land of Lisp ?
14:15curiousgerogetechnomancy: hm okey cool
14:15casiontechnomancy: it is, heavily
14:15aduCL has obscure, 3LA, and archaic names mixed in with long-verbose-names, and clojure somehow has short, clear, names, I don't know how
14:15casionand it made (makes?) CL look terrible IMO
14:15technomancycasion: oh, but it didn't have the intended effect then? interesting =)
14:15ChongLicuriousgeroge: it's also worth learning clojure for a different perspective
14:15technomancyheh
14:15casionat least to a C programmer
14:15wastreloic land of lisp is a cl book
14:16curiousgerogei do ruby and javascript daily
14:16ChongLicuriousgeroge: have you ever done a lisp before though?
14:16technomancycuriousgeroge: the only thing Clojure can't do that Ruby can is proper unixy glue stuff.
14:16curiousgerogeChongLi: no, i am also interested in lisp. was going to buy then I decided to go with vim instead of emacs so I never picked up lisp
14:16LicenserI kind of get the feeling that most clojure books aim at seasoned programmers :(
14:17adualso, I think I might use Clojure as the basis for an algorithm database, because of it's beautiful metadata notation
14:17ChongLiit really broadens your mind to learn a lisp like clojure and all that entails
14:17ChongLihomoiconicity, macros etc.
14:17curiousgerogeis it less code with clojure? than for eg ruby?
14:17scriptorcuriousgeroge: that's a tricky thing to measure
14:17curiousgerogeof course it depends
14:17technomancycuriousgeroge: usually less, but the important thing is that it's clearer.
14:17curiousgerogebut you always get a feeling
14:17curiousgerogetechnomancy: ah cool
14:18ystaelLicenser: part of the problem is that the "out-of-the-box" experience of clojure is difficult for many people ... i would not want to explain to a non-programmer how to get started writing clojure programs
14:18nDuffclearer certainly in the sense that there's less spooky action at a distance -- something Ruby is rife with
14:18Licenserystael for the moment I'm pretty happy with just writing a few simple functions
14:18ChongLiclojure includes a ton of cool macros and really great ideas
14:18ChongLilike making abstractions the default rather than concrete data structures
14:19ChongLiand making keywords functions that look themselves up in a map
14:20ystaelcuriousgeroge: many things you do with object-model metaprogramming in ruby are instead done with syntactic metaprogramming (macros) in clojure
14:20ChongLicuriousgeroge: have you watched any of rich hickey's talks?
14:20ystaelthe end result in expressive power is comparable but the way you get there feels different, and in some ways macros are a lot easier to understand
14:21curiousgerogeChongLi: nope none
14:21ChongLicuriousgeroge: ah, you should
14:21curiousgerogeChongLi: will definetelly do that
14:22casionystael: I've had the opposite experience
14:22casionI've never tried a language that was as easy to get going with as clojure, but maybe that's because I'm using os x
14:22ChongLihe does a very good job of conveying his ideas on values and pure functions
14:23technomancycasion: wow, really?
14:23technomancycompared to which others?
14:24ChongLicuriousgeroge: http://www.infoq.com/presentations/Value-Values
14:24ChongLione of his more recent ones
14:25casiontechnomancy: compared to java, python, c, c++, lua, objc
14:25curiousgerogeChongLi: thanks!
14:25ChongLicuriousgeroge: it's a very interesting way of categorizing languages
14:25casionobviously you can get hello world working in osx pretty damn fast with c/objc… but getting a sane environment is stupid.
14:25ChongLiinstead of looking so much at syntax, rich looks at semantics
14:25technomancycasion: interesting. I don't know the others, but I've always found Python to be very accessible and much better-documented than Clojure
14:25casionand dealing with python 3 on os x is a huge pain
14:26technomancyoh sure, the 2-vs-3 split would probably kill you there
14:26technomancyI was only thinking of 2
14:26ChongLithis tends to lump all of the imperative languages together in a more obvious way
14:26casiontechnomancy: most material I've seen these days is on 3
14:26technomancykind of surprised you had a harder time with lua too though
14:27casionlua is easy to get going to learn I guess
14:28technomancyI guess if you're embedding it in a larger system it could be hard
14:28casionbut having a sensible environment to learn in, not so much
14:28casionand installing clojure-mode or CC is dead simple comparatively
14:28casion(for an environment)
14:28technomancyyeah I guess you have a leg up on Clojure if you already use emacs
14:29ChongLiUnsatisfiedLinkError ~/test2/target/native/linux/x86_64/liblwjgl.so: ~/test2/target/native/linux/x86_64/liblwjgl.so\
14:29ChongLi: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch) java.lang.ClassLoader$NativeLibra\
14:29ChongLiry.load (ClassLoader.java:-2)
14:29ChongLiwhat am I doing wrong here?
14:29ChongLihehe
14:29ChongLiI'm trying to (import org.lwjgl.opengl.Display)
14:30casionChongLi: you're on a 64-bit system aren't you?
14:30ChongLiyeah
14:30ChongLiI figured the libraries in the x86_64 directory would be 64-bit binaries
14:30ystaeltechnomancy: What is the morally correct way to specify repositories/mirrors build-system-wide as opposed to in a single project.clj? Are these settings still ignored from profiles.clj?
14:31ChongLieverything in target/native was put there by lein
14:31ChongLilein deps
14:31ChongLi :dependencies [[org.clojure/clojure "1.4.0"]
14:31ChongLi [org.lwjgl/lwjgl "2.7.1"]
14:31casionChongLi: you're getting the wrong lwjgl version it seems
14:31ChongLi [org.lwjgl/lwjgl-util "2.7.1"]
14:31ChongLi [org.lwjgl/lwjgl-native-platform "2.7.1"]]
14:31TimMcChongLi: Please use a pstebin (such as refheap.com)
14:31TimMc*pastebin
14:31ChongLisorry
14:31technomancyystael: you can put :mirrors in ~/.lein/profiles.clj now
14:32ystaeltechnomancy: awesome! time to update the build agents
14:32ChongLithere's a lot of different versions of lwjgl on clojars and maven
14:32ChongLiI don't know which one works
14:32technomancyystael: pretty sure that's working anyway, best to double-check
14:32casionChongLi: afaik, you have to make sure you're using the x86_64 version, which is fairly new
14:33ChongLiI don't know which one is officialy
14:33ChongLiall these on clojars seem to be uploaded by whoever
14:36casionChongLi: I have no idea how to help you beyond that. you would probably get a better answer in #jme or #java
14:37ChongLioh I think I solved it
14:37ChongLijust used 2.8.4
14:40ChongLiso yeah I just needed to use the latest version
14:40ChongLithanks :)
14:51cvkem_Dynamic generated code based on (eval (read-str s)) is inefficient. Does anyone know whether (load-string s) return code that performs better?
14:52technomancycvkem_: why do you say it's inefficient?
14:52cvkem_By inefficient I mean that the code needs a print-dup method to get its data (if it is something like a java.sql.date
14:54cvkem_technomancy, Furthermore the dataset is translated to a text-file. In my use-case this textfile is too large to fit in a single class-file which causes trouble.
14:55cvkem_I was wondering whether load-string produces different code.
14:55technomancyI don't know what you're talking about, but Clojure only has a single compiler.
14:57cvkem_I thought so too. But for some reason the code works fine and with large data if I compile it, while the code produce by eval requires me to make an implementation of print-dup before it accepts java.sql.date as data.
14:57cvkem_Did not think of the solution myself, but saw a post by Stuart Sierra that exactly described the errors I got.
14:58amalloy`(str (java.util.Date.)) will compile fine: it's a list containing: the symbol str, and a list containing the symbol java.util.Date. -- compare to `(str ~(java.util.Date.)), which won't compile well at all: it's a list containing: the symbol str, and a Date object
14:59amalloyusually the right solution is to generate actual code instead of objects embedded in lists, not to invent ways to print/read the objects you accidentally embedded in your code
15:01cvkem_amalloy, I'm trying use dynamic generated clojure code to let me play in an interactive way with my database. I started using eval, but it crashes if the data passed in exceeds a 65k boundary.
15:02cvkem_... and 64k is reached easily when you expand everything via a print-dup I guess.
15:09ClojureDoes anyone know if Datomic supports authentication between services running on different nodes?
15:10lpetitClojure: you should really choose another nickname than Clojure, IMHO
15:10ClojureThought i did, having issues with Colloquy this morning...
15:10cgagi like it
15:11ohpauleezbasically, what he says goes
15:11cgagvery authoritative
15:11Clojure:)
15:11ohpauleezIt's Clojure's word vs yours
15:11casionhe'll be very popular, eveyone comes in here to talk about him
15:11ohpauleezwe'll see who wins
15:11gfredericksquick quick assemble your questions
15:11firesofmayHi, running lein command I am getting java error out of no where. -> http://pastebin.com/vNnQLStN
15:11gfredericksClojure: why can't we have a clojure.core/update?
15:11ohpauleezClojure is now a self-writing-macro AI
15:11firesofmayany ideas what could be wrong?
15:11hiredman~clojure
15:11clojurebotclojure is the best way to learn java
15:11hiredman~clojure
15:11clojurebotclojure is a very attractive hammer with a nice heft to it
15:12casionbest part is I can tab complete Clojure now
15:12technomancyfiresofmay: maybe using gcj by accident or something?
15:12ClojureI guess I should be offering answers instead of asking questions
15:12firesofmaytechnomancy, gcj? I was running it fine. And suddenly this happened.
15:12technomancyClojure: why hasn't the patch to speed up multimethods been applied I mean come ooooooon
15:13technomancyfiresofmay: what does `java -version` say?
15:13technomancyalso, `lein version` if you can
15:13Clojuretechnomancy: works on my machine
15:13firesofmaytechnomancy, java version "1.7.0_03"
15:13firesofmayOpenJDK Runtime Environment (IcedTea7 2.1.1pre) (7~u3-2.1.1~pre1-1ubuntu3)
15:13firesofmayOpenJDK 64-Bit Server VM (build 22.0-b10, mixed mode)
15:13technomancyhm; it's not that then
15:13technomancycould be a misbehaving plugin
15:14firesofmaytechnomancy, lein is 2.x i am not sure which exact version.
15:14firesofmaytechnomancy, I recently ran an update on unbuntu btw.
15:15firesofmayubuntu*
15:16firesofmaytechnomancy, any ideas what I should do?
15:18technomancyfiresofmay: it looks like a problem with your JDK. maybe try falling back to java 6 to see if that helps?
15:18firesofmaytechnomancy, I have this in my profiles.clj btw :
15:18firesofmaymankaj@mankaj:~/src/ios-moby-testing$ cat ~/.lein/profiles.clj
15:18firesofmay{:user {:plugins [[lein-difftest "1.3.8"]
15:18firesofmay [lein-marginalia "0.7.1"]
15:18firesofmay [lein-pprint "1.1.1"]
15:18firesofmay [lein-swank "1.4.4"] ]}}
15:18firesofmaytechnomancy, oh okay.
15:21xeqifiresofmay: theres a similiar bug I found on google for another project https://bugs.eclipse.org/bugs/show_bug.cgi?id=389533 ; last comment mentions updating to a different version
15:22firesofmayxeqi, sounds like it's the same problem. will try this and let you know if works.
15:28firesofmayxeqi, thanks a lot that worked :)
15:28firesofmaytechnomancy, its a bug with java update. had to remove and re-install java as pointed out by xeqi in above link. :)
15:29technomancyouch, that sucks
15:29technomancyjust an Ubuntu fubar?
15:31firesofmaytechnomancy, its working. I guess the ubuntu update didn't get the latest package and that had some bug. removing and installing again did it (weird!)
15:34technomancy=\
15:34zmarilLet's say I want to hack on two clojure projects at once and I want to connect them via leiningen
15:34xeqicheckouts
15:35zmarilAh! Yes! That was the word. I've done this before, but I forgot what it was called.
15:35zmarilThank you!
15:47firesofmayhow would you convert a string to a vector with , seperated values like ex : "wool,word,work" to ["wool", "word", "word"] ?
15:47scriptorfiresofmay: http://clojuredocs.org/clojure_core/clojure.string/split
15:47firesofmayscriptor, thanks.
15:48Sweden_jack["wool" "word" "work"] right?
15:48hfaafbcommas are allowed
15:49Sweden_jackno I mean "work"
15:49scriptorI think he means the word/work
15:49hfaafbWOOPS
15:49firesofmaySweden_jack, scriptor, its what I wanted. :)
15:49abalonewhen would you use clojure.string vs .split ?
15:50scriptor.split doesn't return a seq, right?
15:50scriptorwell, neither does string.split I guess
15:50firesofmayscriptor, it returned me a clojure.lang.PersistentVector
15:50S11001001,(doc clojure.string/split)
15:50clojurebot"([s re] [s re limit]); Splits string on a regular expression. Optional argument limit is the maximum number of splits. Not lazy. Returns vector of the splits."
15:53visheshIs there any function by which I can replace nth memeber of a collection with another?
15:54gfredericksvishesh: if you are using a vector you can do that with assoc
15:55hfaafbassoc?
15:55clojurebotthen its perfect. but of course, there are a lot of other parts too that changes. so after I make assoc :show, is there a problem I make again (def data (assoc data :list ...)
15:55gfredericks,(assoc [1 2 3 4 5] 3 :foo)
15:55clojurebot[1 2 3 :foo 5]
15:59visheshgfredericks: Ok. For string work I can convert it to vector first and then use assoc, or is there any better way?
16:00gfredericksif you're doing random updates a lot and are worried about performance, then vectors are definitely the choice
16:00gfredericksstrings would require full copies afaik
16:02visheshOk. I'm just learning Clojure, so no specific requirement as such right now.
16:02visheshSo would like to know any direct method I can apply on string too, for educational purposes at least
16:05gfrederickscertainly all java methods are at your disposal
16:06gfredericksI don't see anything in the string class for updating a particular character, and wouldn't expect once since it's ineffecient
16:06gfredericksbut you can do it by hand:
16:06gfredericks,(let [s "foo and bar"] (str (subs s 0 4) "X" (subs s 5 (count s))))
16:06clojurebot"foo Xnd bar"
16:09visheshOk. Thanks. I think if I really need performance benefits, I should use rather StringBuilder
16:09gfredericksyeah that sounds right
16:15konr_trabI can't "bind the qualified name e" when running (defmacro oops [code] `(try ~@code (catch Exception e "Oops"))) - isn't this valid code?
16:15amalloye#
16:15konr_traboh, that's it!
16:15konr_trabthanks!
16:16amalloy&(let [code '(blah)] `(try ~@code (catch Exception e "Oops")))
16:16lazybotjava.lang.SecurityException: You tripped the alarm! catch is bad!
16:16amalloy,(let [code '(blah)] `(try ~@code (catch Exception e "Oops")))
16:16clojurebotamalloy: Gabh mo leithsc?al?
16:16amalloyi hate you guys
16:17hiredman~hate
16:17clojurebotPardon?
16:19cemerickwhew, the reader fails on tagged literals within commented regions
16:19gfrederickscemerick: commented with #_ ?
16:19hiredmancommented how?
16:20cemerick,*clojure-version*
16:20clojurebot{:interim true, :major 1, :minor 4, :incremental 0, :qualifier "master"}
16:20cemerick,#_ #foo/bar 5
16:20clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: No reader function for tag foo/bar>
16:20hiredmanwell, yeah
16:20xeqi,(comment #foo/bar)
16:20clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: Unmatched delimiter: )>
16:20hiredmanthe forms following #_ still have to be readable
16:21gfrederickshiredman: it could read both pieces and then not call the data-reader fn
16:21cemerickhrmph; it shouldn't go looking up the reader fn
16:21gfredericksI can't think of any downside to that
16:21rplevytrying to figure out if I am unnecessarily reinventing a wheel for a simple lein plugin. similar to s3-wagon, but just for simply pushing application uberjars to s3 without any need for maven. you specify bucket in project.clj, and it puts the jar in a directory like bucket/app/branch/*.jar
16:21hiredman*shrug*
16:21amalloy,'#(f %1 #_%2) ;; another entertaining side effect of #_, if anyone hasn't seen it
16:21clojurebot(fn* [p1__99# p2__100#] (f p1__99#))
16:22mindbender1please Brenton, have a second look at CLJS1. It's simply the best!
16:23cemerickamalloy: that's cute
16:23hiredmanrplevy: we have a a bin/ci that the ci server runs, that runs tests and pushes artifacts to s3 using s3cmd
16:24rplevyhiredman: that's a good idea
16:28mindbender1I wonder how people keep building things that don't take arguments
16:28hfaafbeasy []
16:29mindbender1Yes, evil is easy. The hard part?
16:29hfaafbsleeping at night
16:29mindbender1boo!
16:33technomancyrplevy: I don't know if that's been done, but it's a good idea
16:37rplevycool, I will go ahead with the idea then. Good idea to have a ci server call such lein command...
16:37firesofmayI am getting this error even though faker-en file is created : Exception in thread "main" java.io.FileNotFoundException: Could not locate ios_testing/faker_en__init.class or ios_testing/faker_en.clj on classpath:
16:38technomancyrplevy: yeah, keeping as little as possible in the jenkins config is definitely the way to go
16:38firesofmayAny ideas what could be wrong?
16:38technomancybin/ci lets you avoid a lot of hassles keeping job config in line with various branching
16:43thorbjornDXis there a better-defined way of doing this?: (def updated-stuff (for [d small-seq q big-map] (assoc q :small-seq d)))
16:43thorbjornDX(sorry about the symbol names)
16:44gfredericksif big-map is a map I don't think that can possibly work
16:44gfredericksso it's not clear what you want exactly
16:45gfredericksyou just want to take a map and add a key :small-seq?
16:45gfredericksyou might want let instead of for
16:45thorbjornDXgfredericks: er, sorry. big-map should be seq-of-big-maps
16:46thorbjornDXgfredericks: hence the 'for'
16:46amalloythorbjornDX: better-defined? seems perfectly well-defined
16:46thorbjornDXamalloy: okay, so if I want to do this multiple times, I should go ahead and define a macro?
16:46gfrederickswoah man no macros
16:47thorbjornDXgfredericks: oh, okay :(... why not?
16:47gfredericksso what you have there will give you a cartesian product
16:47gfredericksis that what you want? every big map paired with every element of small-seq?
16:48thorbjornDXgfredericks: ah, no I don't. I'd like a 1:1 pairing
16:48gfrederickstry (for [[d q] (map vector small-seq big-map)] (assoc ...))
16:48amalloyfehhhhh. (map (fn [d q] (assoc ...)) small-seq big-map-seq)
16:50thorbjornDXamalloy: oh, I think that makes perfect sense
16:50gfredericksamalloy: yays
16:50thorbjornDXgfredericks: thanks for the tip about the cartesian product, I think I have some broken code to fix :P
16:51gfredericksI hadn't realized that map can be simpler for some anon-fn cases
17:07naegcasion: ping
17:10mindbender1I can't believe some people in Clojure still recommends SICP to budding programmers
17:11Sweden_jackmindbender1: it depends a lot on the student
17:11naegwould appreciate feedback on myblog post about different checking algorithms for a connect four board: http://programmablelife.blogspot.co.at/2012/09/clojure-connect-four-1-checking-winner.html
17:12rplevyit's a good book / online lectures, why not?
17:12mindbender1Sweden_jack: No matter what.. it's evil in my opinion
17:12emezeskemindbender1: What do you have against SICP?
17:12Sweden_jackthen that's a silly opinion, in my opinion
17:12mindbender1emezeske: Imperative
17:12mindbender1swapping
17:12mindbender1statefulness
17:12mindbender1all the goobledygook
17:13Sweden_jackWhich would rule out 99.9% of all programming books?
17:13rplevywell Lisp pre-clojure is more multi-paradigm
17:13rplevythere's a reason we use Clojure
17:13scriptorthey can still take all the other lessons from SICP
17:13mindbender1which brings me to an opinion I have. Almost all books needs revisiting
17:14mindbender1including some early ones in clojure
17:14rplevyhave you looked at "how to design programs" (I haven't)
17:14mindbender1I have it
17:14mindbender1same thing
17:14rplevyok
17:18dnolenmindbender1: SICP is grand, imperative techniques won't being going out of style anytime soon - and for good reason. The problem w/ SICP w/ respect to Clojure is that ... it's about *Scheme*
17:19dnolenwell ... framed in terms of Scheme.
17:20Sweden_jackdnolen: didn't you hear? C is worthless as well because it's stateful and imperative
17:20Sweden_jacktsk
17:20rplevythere are plenty of cases where it makes sense to be imperative even in Clojure
17:21mindbender1dnolen: it probably won't even go out of style at all
17:22dnolenmindbender1: good call
17:22mindbender1there's always a camp..take a position
17:22emezeskemindbender1: Not all programming is functional
17:22amalloy"almost all books need revisiting"? come back when you're done rewriting every book, i guess
17:23rplevymindbender1: what about performance optimizations for isolated parts of otherwise beautifully functional code
17:23naegis there a way to submit an article to planet clojure without syndicating your whole blog?
17:24amalloynaeg: i don't think so, but you can probably ask alex
17:25hfaafbstring/replace takes 2 arguments but my repl is throwing number of argument errors... am I incorrect?
17:25naegamalloy: alex?
17:25amalloyalex ott, who runs planet clojure
17:25xeqi(doc clojure.string/replace)
17:25clojurebot"([s match replacement]); Replaces all instance of match with replacement in s. match/replacement can be: string / string char / char pattern / (string or function of match). See also replace-first."
17:26xeqihfaafb: looks like 3 arguments
17:26hfaafboh, wait, I want to use the core replace...
17:28hfaafbIDE bug
17:28hfaafb:>
17:37senethWhy can˙t you define functions like this (defn test1 [x] #(* % %))
17:38senethit doesnt complain, but i cant use it like (test1 2). Returns <user$test1$fn__1449 user$test1$fn__1449@1444986>
17:38senethits adress or something
17:38gfredericksyou can define them, it's just not doing what you want
17:39senethwhat is it actually doing?
17:39gfredericksyou can (defn test1 [%] (* % %)) if you have some thing for percent signs
17:39gfredericksyou're making a function that returns another function
17:39gfredericksyou can also (def test1 #(* % %)) if you like
17:39gfredericksmaybe that's the sort of thing you were hoping for
17:39S11001001%1 %1
17:40amalloy((test1 'sdfaslkjfsadf) 4) ;; returns 16 as desired, har har
17:40gfredericksS11001001: eh?
17:40S11001001,'#(* % %) ; gfredericks
17:40clojurebot(fn* [p1__27#] (* p1__27# p1__27#))
17:40S11001001what
17:40amalloyS11001001: why wouldn't that work?
17:40S11001001amalloy: it would
17:40S11001001for some reason
17:41amalloyit's a perfectly normal thing to do
17:41S11001001I was under the impression that % was like <> in srfi 26
17:41gfredericks% ===== %1
17:41seneth"you can also (def test1 #(* % %)) if you like", thats what I was looking for.Thanks
17:41S11001001except positionable at any depth
17:41amalloyi don't know srfi, but i guess you mean that % % was %1 %2?
17:41gfredericksseneth: cool
17:41S11001001seneth: that has other disadvantages so maybe don't do it?
17:42gfredericksdammit I hate disadvantages
17:42amalloygfredericks: an extra-cautious ex-programmer of js or php or something? the fourth and fifth =s just for style points?
17:43gfredericksamalloy: ===== is legal somewhere?
17:43gfrederickssign me up for this language
17:43S11001001seneth: e.g. it will lack :arglists metadata for your editor to help you with
17:44rplevyS11001001: or swiss-arrows Clojure lib, which was inspired by a util we wrote at Akamai, which was inspired by srfi 26
17:44S11001001rplevy: indeed
17:44senethI wont be using that notation for defining fns.I am just exploring the language
17:48amalloygfredericks: ##(let [===== =] (===== 1 1)) ;; welcome home
17:48lazybot⇒ true
17:49S11001001I think cute from srfi26 would be handy in some situations
17:50rplevycut?
17:50clojurebotexecutable jar is a sample executable jar build using ant : http://github.com/cark/clj-exe-jar/tree/master
17:50S11001001cute
17:51rplevyI see: http://srfi.schemers.org/srfi-26/cut.scm
17:52S11001001with recursion: (cute + (a) (* (b) % (c)) (d)) |> (let [a# (a) b# (b) c# (c) d# (d)] #(+ a# (* b# % c#) d#))
17:52S11001001well with + and * evalled also
17:57visheshquit
18:00senethWhy #(2) can be defined, but cannot be invoked (#(2))? Maybe because its lazily eveluated?
18:00S11001001,'#(2)
18:00clojurebot(fn* [] (2))
18:01S11001001,'#(do 2)
18:01clojurebot(fn* [] (do 2))
18:01senethIf you invoke it (#(2)) you get an error
18:01S11001001yeah, 2 isn't a function
18:02senethBut then why didnt complain when I defined it
18:02raekClojure is not a statically typed language
18:02scriptor,(#(2))
18:02clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.Long cannot be cast to clojure.lang.IFn>
18:03nDuffseneth: ...you defined a function that tries to call 2 as a function. That's a valid thing to define, it's just not a valid thing to run. :)
18:03Raynes&(read-string "(fn* [] (2))")
18:03lazybot⇒ (fn* [] (2))
18:03senethcan i redefine 2 to point to a function?
18:03scriptorseneth: it doesn't create an error when you define for for the same reason it wouldn't work in a lambda
18:03scriptor,(fn [] (2))
18:03clojurebot#<sandbox$eval107$fn__108 sandbox$eval107$fn__108@48661a83>
18:03gfredericksseneth: no
18:04seneththen when I defined it, it should have known since i cant redefine numbers?
18:04gfredericksseneth: technically the compiler could catch that, yes
18:04senethok thanks
18:04raekseneth: if you want a function that returns to, you could either write (fn [] 2) or (constantly 2)
18:04scriptorbut it wouldn't be very consistent
18:04scriptor(fn [n] (n)) is perfectly valid code
18:04raek*two
18:05scriptorbut it'll break if you pass it a number, or anything else that can't be called as a function
18:05scriptorseneth: if you need to create a function that always returns one value look up constantly
18:05scriptor,(doc constantly)
18:05clojurebot"([x]); Returns a function that takes any number of arguments and returns x."
18:16gstampin marmalade nrepl-ritz seems to depend on nrepl 0.1.4 which isn't in marmalade yet. How annoying.
18:18thorbjornDXthis is my first macro: (defmacro tack [m item] (assoc m (keyword item) item)), is it terrible?
18:19hugodgstamp: sorry about that - I messed up there - it does work if nrepl.el is installed from melpa
18:21gstampno worries. I was hoping to avoid adding melpa. I might just install it manually.
18:21amalloythorbjornDX: i have a hard time imagining a scenario in which that is not horrible, but i suppose it could happen
18:21thorbjornDXamalloy: haha, I need a reality check once in a while :)
18:22Raynes&(map println [\a \b \c])
18:22lazybot⇒ (abcnil nil nil)
18:35Mandarhey guys
18:35Mandari'm trying to learn about refs
18:35Mandardoes dosync retry the transaction until it works?
18:36metellusyes
18:36Mandarthanks
18:36Mandarso i don't have to use a timeout or anything else
18:37Mandarit will just work
18:37thorbjornDXamalloy: in general, should I avoid modifying my data structures? I'm trying to change quite a few old habits.
18:39technomancygstamp: M-x package-install-file makes it easy to work from git
19:00konr_trabIs there a way to reference any anonymous function from inside? like #(if (< % 0) (this-function (- %)) ... )
19:00konr_traban*
19:02konr_trabrecur!
19:08Mandarsecond noob question: what's the use case for atoms? i don't get where compare-and-set! could be useful in an application?
19:09Mandar(if you have a link that explains it better than this page: http://clojure.org/atoms it's great too)
19:14aperiodicMandar: whenever you want something to be able to change, but don't need to synchronize changes to that thing with changes to anything else. an example would be if you're building a todo-list application, you could keep all the current todo items in an atom that contains a set
19:15aperiodicMandar: when the user adds a new item, you'd (swap! todo-items conj new-item), and when they remove an item, you'd (swap! todo-items disj new-item)
19:15TolstoyThat's how I kinda user it. Like a ConcurrentHashMap, sort of.
19:16Mandarthis is a bit weird to me
19:16TolstoyOr sometimes as a sentinal value.
19:16aperiodicMandar: i've never needed to use compare-and-set!, and i don't think using it is at all common
19:16Mandari get the example
19:16ChongLiMandar: the beauty of it is that it's thread safe
19:16Mandarbut in this case why couldn't we just call a function returning a function with the new value of the clojure?
19:17Mandaroh
19:17Mandarokay
19:17Mandarnow i get it
19:17ChongLithe atom is accessible and
19:17ChongLi"mutable" from any thread
19:17ChongLiin a safe way
19:17aperiodicMandar: values are immutable. try constructing such a function without using an atom in that function's closure
19:18ChongLisince only the reference itself is changed, the value it points to is immutable
19:18ChongLiso when another thread is working with that value, it won't be harmed
19:19Mandarokay
19:19TolstoyI'm guessing compare-and-set reduces the locking for those cases where most of the time the value doesn't really need to change?
19:19ChongLiand of course, once the old value is no longer needed it'll simply be garbage-collected
19:19aperiodicif you want to be pedantic, the value of the reference (the atom) never changes (you can use it as the value of a final field in a java class), only the value you get when you dereference the reference changes
19:20Mandaraperiodic, i'll try that, i come from erlang where such thing is easy because each process has its own immutable variables
19:20Mandar("immutable variable" is a weird combination)
19:20ChongLiwell, mutable variable is actually the weird one
19:20ChongLivariables were immutable for centuries before programmers came along
19:22ChongLiI like rich hickey's description of "places"
19:22ChongLia mutable "variable" being a place in memory
19:22ChongLinot a value
19:23aperiodicTolstoy: you get that for free using swap!, since swap! internally does the compare-and-set!
19:24TolstoyExcellent. ;)
19:27Mandaraperiodic, you were right, i cannot write such a function because i cannot store the closure containing my data in a place where other functions have access to it
19:28Mandarso basically, an atom is a thread-safe shared var
19:28Mandarright?
19:28clojurebotflatten |is| rarely the right answer. What if your "base type" is a list
19:29aperiodicMandar: basically, yup
19:29Mandarthanks guys, much clearer now
19:32madsyWhat's actually happening here? A def gets evaluated at compile time? http://squirrel.pl/blog/2012/09/13/careful-with-def-in-clojure/
19:35aperiodic&(doc def)
19:35lazybotjava.lang.SecurityException: You tripped the alarm! def is bad!
19:36aperiodic:-(
19:37aperiodicmadsy: if you'll look at the docstring for def, you'll notice that if an initial value is supplied, it's evaluated, and the var is set to that value
19:38amalloycompiling a clojure program is just evaluating each top-level form, and saving any classes that get generated as a result
19:38hiredmanhttp://clojure-log.n01se.net/date/2008-11-12.html#16:07
19:38madsyaperiodic: Yeah, I never bothered because I thought def was a nobrainer. Thanks.
19:38casionwouldn't he want something like (def my-def #(get-my-value))
19:40madsycasion: No need to wrap it. Just don't call it.
19:40casionyeah
19:48akhudekdo people have a good go to library for parsing UserAgents in clojure?
20:18konr_trab12 hours of work today :( - but it's all good because it is in - CLOJURE!
20:18konr_trabgood night!
21:57cjfriszHmm...trying to use 'nil' as a function gives a NullPointerException
21:57cjfriszI guess that makes sense...not sure if it's what I was expecting
21:59jweisslein run is suddenly giving me "ClassNotFoundException" on my :main namespace. tried cleaning, re-self-installing, notthing fixes it. was working earlier today.
22:02cjfriszMan...just not on it right now
22:03akhudekjweiss: bracket type in your main class maybe?
22:04akhudekor perhaps gen-class somehow got dropped?
22:04akhudektype=typo
22:04jweissakhudek: i never had :gen-class.
22:04jweisswhy would I need that?
22:04jweissi'm not compiling into an uberjar or anything
22:05jweissi've been using the same version of lein and everything else and it suddenly stopped working today, it's got to be something in my main namespace
22:05jweissbut it compiles fine at the repl
22:06xeqijweiss: whats the value for :main ?
22:06jweiss :main ^{:skip-aot true} katello.tests.suite
22:07xeqido you have a -main function?
22:07jweissi think i see the problem. starting a fresh repl, i have a compile error in my main namespace (really in a dep).
22:07jweissthat's a shitty error to give. classnotfound. that is not the real error
22:11Hodapphttp://pastebin.com/NHx5bfyZ - someone want to tell me what obvious thing I'm missing here that this should be a NullPointerException?
22:11amalloytoo many parens
22:13Hodappwhere?
22:13clojurebotwhere is log
22:15xeqiHodapp: ((println ..) ...)
22:15xeqi* print
22:15Hodappis there some other way to express that the 'then' portion should execute multiple things?
22:15xeqi(doc do)
22:15clojurebotexcusez-moi
22:15xeqi,(do (print "hi") (+ 1 2))
22:15clojurebothi
22:15clojurebot3
22:16Hodappugggggh
22:20Hodappis there some way to convey, when attempting to work with lein-tarsier, that I want to work with this code without exceuting it? The REPL is not very useful when it's stuck inside of something...
22:21Hodapppart of it is probably this quil weirdness with 'defsketch' executing things
22:21xeqi"work with this code"?
22:21aperiodicHodapp: that is exactly it. put your defsketch in your -main
22:22xeqiah
22:22Hodappaperiodic: if I put it in my -main, will it not execute when I run 'lein vimclojure' so I can use vim with it?
22:22aperiodicHodapp: yes, because it's not top-level, so won't be evaluated when your namespace is compiled
22:23Hodappnow what do you even mean by -main?
22:24Hodappnevermind, think I see
22:32Hodappalright, now just have to figure out how to actually execute said main from witihn that nailgun session...
22:33aperiodiconce you load the namespace, you should just be able to evaluate `(-main)`
22:54axle_512Hmm, I am stuck trying to implement authentication with cemerick/friend…
22:54axle_512trying to use form based authentication.
22:54cemerickaxle_512: what's the problem?
22:54axle_512cemerick: just using: (friend/authenticate {:credential-fn (partial creds/bcrypt-credential-fn users)
22:54axle_512 :workflows [(workflows/interactive-form)]})
22:55axle_512my form is posting to action="/login" method="POST"
22:55axle_512and the form has two text inputs, one with id="username" and one with id="password"
22:56cemerickaxle_512: you haven't specified the form-based workflow.
22:57axle_512cemerick: ah, ok. I thought interactive-form was how I specify that.
22:57cemerickand form fields need e.g. name="username" attributes
22:58cemerickaxle_512: nm, didn't see the second line of your paste
22:58axle_512cemerick: ahh, name instead of id. doh!
22:58axle_512cemerick: thanks, let me correct that.
23:17muhoocemerick: have you any interest in exposing the Ax attributes portion of the openid workflow so that someone using the library can pick which attributes they want, instead of "carpet bombing"?
23:18cemerickmuhoo: I personally don't. Patches welcome, of course. :-)
23:19cemerickOnce some oauth2 basics are in place, I'll definitely get the openid workflow out of the main project so that it can be forked separately, etc.
23:19muhooif i can find a way to do it without a breaking change to the api, i'll do that
23:19cemerickYou can go bash out the vars that contain the attr maps, assuming you don't need to customize the attrs requested per account/provider/etc
23:20muhoobash out?
23:20cemerickalter-var-root, etc
23:20muhoooh, cool.
23:20muhoothat feels kind of icky though.
23:21cemerickoh, definitely a hack :-)
23:21cemerickwhat do you mean by "carpet bombing", BTW?
23:22cemerickjust not being selective in the requested attrs?
23:23muhoohttps://github.com/cemerick/friend/blob/master/src/cemerick/friend/openid.clj#L33
23:23muhoo"might as well carpet-bomb for attributes"
23:23cemerickhaha
23:23cemerickI don't see any reason not to *shrug*
23:24muhooIIRC, the user gets a scary screen in google asking them to approve granting access to all this information
23:24muhoowhen all i want is their email, first/last
23:24cemerickOf course, providers can define custom attrs, so being able to adapt to that is important for certain contexts.
23:24cemerickoh, I see
23:24cemerickSo, sure, alter-var-root, and you'll be rid of that.
23:25muhooperfect, that'll work, thanks.
23:25axle_512cemerick: hmm, still no luck. I confirmed I now see [:params {:password user_password, :username jane}] in the request map. But still getting a redirect with an empty username=
23:25cemerickFWIW, it'd be a crazy simple patch to parameterize the map of attrs requested, so feel free to give it a shot.
23:26cemerickaxle_512: can you paste your code and your html page somewhere?
23:26axle_512cemerick: sure, one sec
23:26muhoofunny, i ran into exactly this problem in may: http://nelsonmorris.net/2012/09/13/solving-version-conflicts.html
23:27cemerickmuhoo: see his new post about lein-pedantic
23:28xeqiI helped solve it like 3 times in a week, and I'd been fighting with cemerick that soft version ranges were better for like a month, so I had to go write something to fix their problems
23:28cemerickmuhoo: BTW, could you file an issue for the attrs thing?
23:28muhooxeqi: hahaha
23:28xeqi* soft versions were better then ranges
23:28muhoothanks for writing it, i'm sure i'll run into that again.
23:29muhooyeah, i don't think technomancy will go for ranges
23:29muhoocemerick: will do
23:31cemerickxeqi: The topic contains multitudes, but you've gained a ton of ground. ;-)
23:31cemerickmuhoo: thanks!
23:31axle_512cemerick: https://gist.github.com/3719615
23:31axle_512cemerick: and my html is here: https://gist.github.com/3719619
23:33cemerickaxle_512: handler/site needs to be applied after friend/authenticate
23:33xeqi(inc cemerick)
23:33lazybot⇒ 10
23:34axle_512cemerick: thank you. sorry to bug you. I will try that.
23:34cemerickIt's a bummer that there's no metadata on middlewares indicating dependencies like that. :-(
23:34cemerickaxle_512: no worries, ping back if problems come up again :-)
23:35axle_512cemerick: in my project.clj, do I specify my ring handler as app? or secured-app?
23:35cemerickaxle_512: whichever one you want to run/test. Should probably be the secured-app.
23:36axle_512cemerick: ok, thank you!
23:42axle_512cemerick: success!
23:42cemericksalut!