#clojure logs

2011-05-31

00:00bpr`so you're working with a complete graph right?
00:00bdeshamI love clojure to pieces but sometimes I just want to set a variable ;-)
00:00bpr`well, sometimes it's the right thing to do
00:01bpr`though, i'm not convinced that this is such a case
00:01bdeshamwell, theoretically, yes... I'm implementing the graph as a hash so that d[i,j] corresponds to (d [i j])
00:02bpr`I assume (= (d [i j]) (d [j i)) ?
00:03bdeshamactually, no
00:03bdeshamone of (d [i j]) and (d [j i]) is zero
00:04bpr`oh, ok
00:04bdeshamoh wait, sorry
00:04bdeshamI was thinking of p
00:05bdeshamyou're right, d is symmetric, as in the table at http://en.wikipedia.org/wiki/Schulze_method#Example
00:05bdesham...er, not symmetric
00:05bpr`i was going to say, that if not then your "voters" are silly lol
00:05bdeshamsorry, little scatterbrained on this one
00:05bpr`yeah, that's symmetric
00:05bdeshamheh
00:06bpr`wait, but that table's not symmetric
00:08bpr`oh, ok, yeah that doesn't need to be symmetric
00:22bpr`would something like https://gist.github.com/999855 work?
00:26bdeshamhmm... recur has to be the last form in the loop or else it won't work
00:27bdeshamthere needs to be a conditional in here somewhere
00:27bdeshamlet's see...
00:27bpr`i clearly didn't run that
00:27bdeshamoh, no, I think the final "map" just isn't in the right place
00:28bdeshamhehe
00:28bpr`right
00:28bpr`you'd have to do (id (done?) map (recur ...)) in there
00:28bpr`and there's a typeo in the assoc form
00:29bpr`and i'm not sure what would happen with that for loop
00:29bpr`err, for form lol
00:29bpr`it might keep resetting your i j k s
00:29bpr`so you might have to pull the i j k stuff up into the loop and then use recur to update them
00:30bdeshamyeah, I'm not sure you'd still be able to use for when you're recursing
00:30bdeshamif that's a word
00:42kornyshi folks - is there something like get-in that will get multiple values from a nested structure?
00:43kornysi.e. something better than {:screen-name (get-in tweet [:user :screen_name]) :tweet (:text tweet)})
00:44kornysto get just the screen name and the tweet values from {:text "foo" :user { :screen_name "fred" } }
00:44bdeshamhmm... better how
00:44bdesham?
00:44amalloykornys: you can't really do a lot better, i think? i mean, you can avoid repeating the "tweet" identifier, but everything else there is carrying real information
00:45kornysIf I wanted to pull 5 or 6 values out of a twitter message, it would mean repeating :tweet a lot
00:45kornysI can't immediately think of a better syntax though :)
00:45amalloykornys: give an example where having this magic function would actually help, then we can build the magic
00:46bdeshambpr`: I tried an implementation with refs: https://gist.github.com/999873
00:46bdeshamthough it seems to give the same results
00:46bdeshamso I'm not sure whether the process is actually wrong or if I'm relying too much on wikipedia
00:47bdeshamkornys: if you were going to use those values a *lot*, you could use (let [screen-name (get-in tweet [:user :screen_name]), tweet (:text tweet), date (:date tweet)] ...) or whatever
00:48kornysamalloy: trying to extract parts of a twitter response, like the ones at http://dev.twitter.com/doc/get/statuses/public_timeline
00:48bdeshamkornys: although that probably wouldn't be worth it unless you were going to refer to those values a bunch
00:48kornysanyway, if there's no simple idiomatic way, i can live with what I posted
00:48kornysjust new enough to clojure to always suspect there's some obvious thing i've missed :)
00:49bdeshamkornys: that takes a while to wear off ;-)
00:53amalloykornys: https://gist.github.com/999885 maybe?
00:54amalloysolves some of the problem without making the rest worse
00:55kornysamalloy: nice - thanks.
00:55amalloyif the things you want to get are hardcoded, you can probably get something more concise with nested map destructuring
00:55kornysprobably wouldn't use it for 2 fields, but for 5 or 6, it'd be great.
00:56kornysyeah - need to get my head around nested destructuring. I've done it in scala, but the clojure syntax is still confusing me a bit
00:58amalloykornys: updated gist with a destructured example
00:59kornysamalloy: thanks - I think that's what I need. I tried something similar, but I think I just got the syntax wrong.
01:00amalloyyeah, it's easy to do that especially with map destructuring
01:00amalloyyou probably had the keys and bindings switched
02:02seancorfield__i have a seq and want to apply a function f to every other element - what's a slick idiomatic way to do that?
02:03amalloyseancorfield__: leaving the other elements untouched, or what?
02:04seancorfield__given f and [1 2 3 4 5 6] i want [1 (f 2) 3 (f 4) 5 (f 6)]
02:04seancorfield__yeah, apply identity then f then identity then f
02:04amalloy&(let [xs (range 10)] (mapcat (fn [[a b]] [(/ a 2) b]) (partition 2 xs)))?
02:04sexpbot⟹ (0 1 1 3 2 5 3 7 4 9)
02:05amalloynot exactly gorgeous, but reasonable
02:06opqdonut_,(let [f (partial * 2)] (map #(%1 %2) (cycle [f identity]) [1 2 3 4 5 6]))
02:06clojurebot(2 2 6 4 10 6)
02:06seancorfield__hmm...
02:06opqdonut_there ya go
02:06seancorfield__cycle... ooh... that sounds more like it
02:06amalloyah, cute
02:06opqdonut_it's a shame #(%1 %2) doesn't have a name. it's my favourite function
02:06seancorfield__lol
02:06amalloyopqdonut_: i defined it as invoke
02:06opqdonut_or rather, (fn [f & args] (apply f args))
02:07amalloyopqdonut_: funcall, if you like common lisp :P
02:07opqdonut_:)
02:07tomojamalloy: with juxt I like your version better
02:08amalloytomoj: it doesn't really work with juxt though
02:08tomoj&(let [f (partial * 2)] (mapcat (juxt identity f) [1 2 3 4 5 6]))
02:08sexpbot⟹ (1 2 2 4 3 6 4 8 5 10 6 12)
02:08tomojis that not right?
02:08tomojhmm
02:08opqdonut_partition
02:08tomojoh, right
02:08amalloyright, but once you partition it you can't easily juxt it
02:08tomojthat's wrong
02:09bpr`wow, opqdonut_ that was nice (the mapping you just posted)
02:10tomoj#(%1 %2) seems like it should have a name somehow
02:10amalloy&(-> inc (.invoke 1))
02:10sexpbot⟹ 2
02:10amalloyoften almost as good as giving it a name
02:14tomoj#(apply % %&) ?
02:14tomojdoes that do what I think it does
02:17amalloyno
02:18amalloy&(#(apply % %&) println 1)
02:18sexpbot⟹ 1 nil
02:18amalloyoh. huh. maybe it does?
02:18amalloytomoj: i have a bad habit of asserting you are wrong. i hope you don't mind
02:18tomoj(apply #(apply % %&) f x y z) is (f x y z)
02:18tomojif people agree with me I see no real need for them to say anything to me mostly
02:19amalloytomoj: sure. it's just that usually i'm *wrong* when i tell you you're wrong :P
02:19tomojer
02:20tomoj(f x y z) is (#(apply % %&) f x y z), right
02:20amalloytomoj: i assumed %& was "all the arguments", not "all the args i haven't touched yet"
02:20amalloybut apparently it's not
02:20amalloy&'#(% %&)
02:20sexpbot⟹ (fn* [p1__17398# & rest__17399#] (p1__17398# rest__17399#))
02:21amalloy&'#(%2 %&)
02:21sexpbot⟹ (fn* [p1__17409# p2__17407# & rest__17408#] (p2__17407# rest__17408#))
02:21tomojwacky
02:21amalloytomoj: how so?
02:22tomojthe one disappears
02:22amalloywell, naturally
02:22tomojthat's interesting..
02:22amalloyyou're not referring to it, and %& can't somehow include it
02:22tomojyeah
02:22clojurebotexcusez-moi
02:22tomojso is (#(apply % %&) #(apply % %&) f x y z) also (f x y z)
02:22amalloy*blink*
02:23tomoj&(#(apply % %&) #(apply % %&) #(apply % %&) #(apply % %&) + 1 2 3)
02:23sexpbot⟹ 6
02:23amalloyi guess it must be
02:23tomojwhat is that strange thing
02:24amalloya delegator?
02:27tomojit's $
02:31amalloytomoj: i guess. but $ is only useful because of its order of precedence
02:31amalloyin a lisp it's not much good
02:31amalloyi guess you can combine it with apply to get out something useful
02:31tomojwell, `($) ($) ($) ($) (+) 1 2` is 3
02:32amalloy&(apply #(apply % %&) [+ 1 2)
02:32sexpbot⟹ 3 ; Adjusted to (apply (fn* [p1__17442# & rest__17443#] (apply p1__17442# rest__17443#)) [+ 1 2])
02:32tomojhuh..
02:33tomojso.. (partial apply #(apply (resolve %) %&)) is almost like eval
02:34tomojbut no macros, no special forms
02:36amalloytomoj: it also doesn't resolve any of the other args
02:44tomojoh, right
02:50amalloy$findfn 2 [1 2 3 4 5] [4 5]
02:50sexpbot[clojure.core/take-last]
02:51bpr`wow, that's a neat feature
02:51bpr`very prolog-y
02:53bpr`it's gotta be fairly limited though.. right?
02:53amalloybpr`: yeah
02:55amalloybpr`: you have to pass args in the right order, it only tries a few standard namespaces, and it only looks up direct function calls. it would never find (comp last butlast), for example
02:55amalloythere's a $findarg (map % [1 2]) [2 3] version that's supposed to yield inc, but it wasn't very well tested and seems to have stopped working shortly after it was added
02:55bpr`is it doing something like prolog? an elaborate pattern match? or something like just call each function that takes 2 args and see if it gives the answer?
02:55amalloythe latter
02:56bpr`ah
02:56amalloyah, i was using it wrong:
02:56amalloy$findarg map % [1 2] [2 3]
02:56sexpbot[clojure.core/unchecked-inc clojure.core/inc]
02:57bpr`that's pretty nice
02:57amalloyyeah, mec wrote that version
02:58bpr`i kinda assumed it would only do clojure.core, but you say "a few namespaces". does that branch out to contrib?
02:59amalloy#{clojure.core clojure.set clojure.string clojure.contrib.string}
02:59amalloy$findfn 2 "test" "te"
02:59sexpbot[clojure.contrib.string/butlast clojure.contrib.string/take]
05:06Dranikhow is 1.3 going? when we will see the beta?
05:08hoeck1Dranik: http://dev.clojure.org/jira/secure/Dashboard.jspa?selectPageId=10014
05:09Dranikhoeck1: thanks
05:09Dranikwow, we're really close to that!
05:10hoeckI'm already using the alpha without problems (of course not in production)
05:10hoeckDranik: yeah, lots of approved tickets :)
05:11Fossigiven that 3 of 4 remaining items are docs and release notes, yes ;)
05:11Dranikhoeck: how is it with error handling there? is it informative at last?
05:12Fossinullpointers are such a treat :>
05:12Fossior arrayindexoutofbounds ;)
05:12Fossitons of clojuer programmers wouldnt nkow what to look for anymore if you fix that ;)
05:13hoeckDranik: I updated from a half a year old version, and I believe I actually got linenumbers for compiler errors
05:14Draniku mean 1.3 or 1.2?
05:14Fossii guess it's still more of a "feature" release though
05:14Fossihttp://dev.clojure.org/jira/browse/CLJ-742
05:14Fossioh noes
05:15Fossiit got fixed :(
05:15Dranikone more question: where I could read about the main new features of 1.3?
05:15Fossii guess until release notes are done in the bugtracker ;)
05:15DranikI see :-)
05:16Fossias the one open item is Document clojure.org differences between 1.2 and 1.3
05:16Fossihttp://dev.clojure.org/display/doc/1.3
05:16Fossimight do actually
05:16fliebelI hope this gets in at some point before 1.3 :)
05:16fliebelhttp://dev.clojure.org/jira/browse/CLJ-803
05:19Dranikis there any roadmap to 1.4 or further?
06:02ilyakWhat's the right way to force evaluation of a whole lazy sequence?
06:04raekilyak: doall
06:05raekbut if you don't care about the values, e.g. you have something like (map prn coll), dorun is better
06:05ilyakIt would return values won't it?
06:06ilyakI care about values because it's what it's all about
06:07raekilyak: yes, doall returns the exact same sequence. the only difference is that it has traversed the whole sequence once
06:07ilyakcool
06:34clgv##(type (range 10))
06:34sexpbot⟹ clojure.lang.LazySeq
06:34clgv##(type (doall (range 10)))
06:34sexpbot⟹ clojure.lang.LazySeq
06:35clgv##(let [l (range 10)] (type l))
06:35sexpbot⟹ clojure.lang.LazySeq
06:35clgv##(let [l (doall (range 10))] (type l))
06:35sexpbot⟹ clojure.lang.LazySeq
06:37ilyakFor some reason it seems that after I added doall there, the whole outer sequence (where this sequence is used in each element) became eager
06:38ilyakAnd it doesn't work
06:39clgvhumm I remember doall returning an array. maybe it was only for map
06:42cemerickilyak: that's the point of doall
06:43cemerickclgv: neither doall nor map return arrays :-)
06:55ilyakWhen I use (first , it works
06:55ilyakwhen I use (doall, it fails
06:56cemerickilyak: those two functions do entirely different things
06:56cemerickwhat is failure in this case?
06:57ilyakcataska: Failure is that doall majorly disrupts the flow of my program (I can no longer read items by one from the other lazy seq)
06:58ilyakI'll check another possible reason
06:58ilyak,(take 1 [1 2 3])
06:58clojurebot(1)
06:59cemerickdoall forces the evaluation of each item in a seq provided to it. Don't use it if you want that seq to remain un-realized.
06:59ilyakcemerick: I want this seq to remain un-realized, but not the other seq which contains items which contain the sequence i *do* want forced
07:00ilyakHowever, it seems that my problem is in some unrelated part
07:00ilyaklet me check
07:06ilyakIt seems that I have a problem in my algorithm
07:13opqdonut_"if code is data, where are all my refactoring tools?"
07:13cemericksheesh, where is that chestnut from?
07:16opqdonut_co-worker of mine just now
07:17manutterheh, and the snippy reply is "if code is open source, why aren't you writing the tools you want?" ;)
07:17cemerickopqdonut_: tell him that the availability of refactoring tools is dependent upon the availability of type information, not anything related to syntax.
07:19manutterIt's an interesting point, though. I'm trying to think what "refactoring" would mean in a non-OO context
07:20manutterI suppose you could do the "break a long function into several smaller functions called by a parent" refactor
07:20cemerickPerhaps not a lot. "rename" is the only one I've missed in any real way.
07:20opqdonut_make a protocol, split a protocoll
07:20manutterYeah, rename would make sense too
07:20opqdonut_thread extra parameter through a call chain
07:21cemerickextra parameter?
07:21manutterhmm, those sound interesting
07:22opqdonut_cemerick: like "oh, I need to have access to the foo-params map in function bar"
07:27manutterhow would you automate the process of identifying which functions make up the chain to add the extra param to?
07:28opqdonut_1) calculate call graph 2) ask questions
07:29opqdonut_even lower level tools liks "grab me a list of callers of this function and let me edit each one in turn" would be nice sometimes
07:29manutterOh, ok, I thought you meant like a recursive call graph or something
07:29manutteryeah, the call graph shouldn't be too hard
07:29opqdonut_of course with a dynamic language you can't get all callers
07:29opqdonut_but you can get something that works for 99% of the cases
07:30manuttertrue, and macros make it even more fun
07:40ilyakwhen I'm in a let-block, are let variables guaranteed to eb already evaluated?
07:40ilyakWith all the side effects
07:41opqdonut_yeah
07:41Chousukelet evaluates things sequentially
07:41opqdonut_thus the (let [a (foo x y) _ (mutate a) b (bar a)] ...) "idiom"
08:07markomanhi i have #:field{:k 1 :l 2 :m 3 ,,,} but I want only selected keys reserved say -> #:field{:k 1 :m 3}
08:09markomanthere are more keys to be removed that reserved and I need to have either the copy of original #:field or same with removed keys
08:12fliebelmarkoman: is field a defrecord?
08:13markomani think its defentity
08:13markomanapp engine entity type / map
08:13fliebel??? ##(doc defentity)
08:13sexpbotjava.lang.Exception: Unable to resolve var: defentity in this context
08:13fliebelah
08:14markomani got entity from datastore, modified it a lot, and now need to save it, but i think all modified keys needs to be removed
08:14fliebelAnyway, you could maybe do (select-keys #:field{...} [:k :l]) and pass the result to the constructor for field?
08:14markomanor actually added keys
08:15markomanok, trying
08:22markomanits was other good, but its normal map after select, not keeping original form
08:59ilyakCool
08:59ilyakmy "stateless" event-based xml-parser is ready
08:59ilyakGot to share it somehow and post to groups
09:00manutteroo cool, where is it?
09:00ilyakNowhere yet
09:00ilyakHave to write some kind of example and perhaps replace javolution with some other stax parser
09:35gtrak`can you do a tree traversal with fn and recur?
09:37Vinzent,(into {} '((:a 1) (:b 2)))
09:37clojurebotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry
09:38Vinzenthm, why?
09:39manuttergtrak`: you might be interested in http://inclojurewetrust.blogspot.com/2009/11/tail-recursion-and-function-composition.html
09:39manutter,(into {} '(:a 1 :b 2))
09:39clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
09:40manutterinteresting
09:40manutter,(doc into)
09:40clojurebot"([to from]); Returns a new coll consisting of to-coll with all of the items of from-coll conjoined."
09:40stuartsierramanutter: `into` a map requires a seq of pairs.
09:41manutterMakes sense
09:41gfrlog,(apply hash-map '(:a 1 :b 2))
09:41clojurebot{:a 1, :b 2}
09:41manutterstuartsierra: did you see Vinzent's code?
09:41gtrak`hm, well the question is more of principal, the recur just rebinds some bindings and does a jump, so even though it's in the tail position you can't recur on both children of a tree node?
09:41Vinzent,(into {} (map vec '((:a 1) (:b 2))))
09:41clojurebot{:a 1, :b 2}
09:42gfrlog,(into {} (partition 2 '(:a 1 :b 2)))
09:42clojurebotjava.lang.ClassCastException: clojure.lang.Keyword cannot be cast to java.util.Map$Entry
09:43manuttergtrak`: Did you see the funky stuff at the end of that blog post about building closures to handle traversing the other child node?
09:44CozeyHi All. Has anybody used Clojure with some of Spring framework? I am particularly thinking aobut using clojure for business logic with Hibernate to access database. Also I'm thinking about using spring-security - since it brings some goodies like OAuth for free. What would be a better approach: to wrap embed clojure code inside spring, or to use clojure as a host and just create some spring contexts with beans?
09:45stuartsierraCozey: Chas Emerick (@cemerick) wrote a blog post about using Spring security with Clojure.
09:45gtrak`oh, I see, interesting
09:45gtrak`in java you solve problems by creating objects, in clojure you do it by anonymous functions :-)
09:46stuartsierraAnonymous functions ARE objects. ;)
09:46cemerickstuartsierra: I don't think I did, though I do use spring-security in all my webapps
09:47stuartsierracemerick: I know I read something about that somewhere.
09:47cemerickCozey: spring-security is entirely orthogonal to Clojure or not-Clojure. I agree that it's a good (best? only sane?) option for what it does.
09:48Cozeyfrom what I see spring-security works from web.xml as a filter. thats good. Actually I have some team-mates who insist on spring
09:48Cozeybut are not agains clojure
09:49CozeySo I thought that if they want to implement db + some data manipulation logic using hibernate, let's do it
09:49cemerickRight -- you add its filter to web.xml, and configure it however you like in applicationContext.xml and such.
09:49cemerickTotally reasonable. :-)
09:49CozeyI'd really like to use clojure as a host - ie. write the dispatcher of a web app in clojure, and call out to spring context - but perhaps i'm getting myself into trouble going this way?
09:50Cozey(if they will want to use some otherspring things, i'm especially afraid of annotation or AspectJ based things)
09:50cemerick"host" here implies that your primary servlet is written in Clojure?
09:50Cozeyyes
09:50cemerickSure, that shouldn't be a problem.
09:51Cozeyand just loads spring context
09:51Cozeycool :-)
09:51cemerickAnnotations are also available, but other things (like runtime classpath scanning and autowiring of Clojure-generated) are probably more trouble than they're worth, if you can avoid them.
09:52CozeyI need to do some small project atm using python, and even with python 3 i must say it seems so incoherent.. You guys creating Clojure really do a great job!!
09:52Cozeyannotations in clojure? with gen-class or ?
09:52cemerickI've never really used spring proper though (only spring security in depth), so all of the above is FWIW. </disclaimer> :-)
09:53cemerickRight.
10:09clgvin clojure 1.3 how do I set a new value on a (def ^:dynamic bla nil) ?
10:10fliebelclgv: Just as you'd do in 1.2 with any var.
10:10fliebelso that'd be binding and alter-var-root! I think.
10:10clgvfliebel: I redefined it with def and another value in 1.2
10:11clgvprobably not clean I guess
10:11fliebelclgv: And what happens when you do the def in 1.3?
10:11clgvit complains that I have to set :dynamic so it seems not the proper way I guess ;)
10:12stuartsierraRepeating def without ^:dynamic will lose the ^:dynamic.
10:12clgvsince declaring it with dynamic once should be sufficient
10:12clgvso alter-var-root! is the way to go if I cant use binding?
10:12stuartsierrayes
10:12clgvthanks :)
10:13stuartsierrano `!` on `alter-var-root` by the way
10:13clgvthx. saw it in the api already.
10:15fliebelDoes anyone know if cake has a secret setting for baud rate? because when I paste something, it appears slower than I type.
10:18clgvWhen doing: (alter-var-root *enable-timing* (constantly false)) I get: #<ClassCastException java.lang.ClassCastException: java.lang.Boolean cannot be cast to clojure.lang.Var>
10:18stuartsierraclgv: Use #' notation to get the Var instead of its value.
10:19clgvoh right. thx.
10:21clgvthat's the first time I use alter-var-root
10:34bendlashey, folks
10:34bendlasgfrlog: hey, saw you way too late last time :)
10:34clgvwhat is that supposed to mean: java.lang.IllegalArgumentException: Duplicate case test constant: quote
10:35__name__Hey folk.
10:36bendlasclgv: code?
10:36stuartsierraclgv : Are you using `case` with a quoted symbol or list?
10:36clgvstuartsierra: with quoted symbols yes
10:37stuartsierraclgv: try it without the quote marks
10:38clgvstuartsierra: ok it compiles now. let's see if it still works. I had it running in 1.2 with the quotes
10:42clgvstuartsierra: ok it still works like intended :) thx!
10:46clgvhumm leiningen fails on my clojure-1.3.0-alpha8 project with Exception in thread "main" java.lang.RuntimeException: java.lang.NoClassDefFoundError: clojure/lang/ILookupHost :(
10:46clgvit's leiningen 1.5.2
10:47stuartsierratry a clean build
10:49clgvok that worked. strange error though but I'll remember cleaning up next time
10:54fliebelDo people get notified when I add a file to Jira without a comment?
10:58gfrlogis there any good functional approach to the DB auto-increment situation?
11:18pjstadiggfrlog: does an atom not work for you?
11:19pjstadigor do you mean returning the success/failure of an update statement, and also the auto-increment id?
11:19gfrlogpjstadig: I'm talking about using a DB (mysql), and using clojureql or c.c.sql to connect to it. When I insert a record, I don't think either library has a way for me to get the new ID of the record without creating a "SELECT LAST_INSERT_ID()" query
11:19gfrlogI need it because I'm creating other records that need the ID for their foreign key fields
11:20gfrlogthis all works much more seamlessly in rails' ActiveRecord, which of course is not very FP at all;
11:20pjstadigthere may not be a clean way to implement something like that in a database agnostic way, which is why those libs don't provide the feature?
11:21pjstadigin which case you just have to do it the mysql way
11:21gfrlogyeah. I was also thinking that it's even schema-dependent. Since you don't have to create a single auto-increment primary key in your table
11:22gfrlogactiverecord is opinionated about the schemas
11:22pjstadigwell i'm guessing that clojureql and c.c.sql work at a lower level of abstraction
11:22stuartsierraI think JDBC provides a semi-standard way to get the last insert ID.
11:22pjstadigyeah AR makes it's own assumptions about how you should do things, and provides higher level abstractions, as opposed to "execute this SQL query", which is the level that the clojure libs live at
11:23gfrlogstuartsierra: brief googling backs that up
11:23gfrlogpjstadig: I feel like clojureql is a bit higher level, but in a different way than AR. At the very least it could have a method like conj! but that returns the last insert id instead of the table
11:24pjstadigcould be...honestly i'm not that familiar with either clojure lib
11:25gfrlogpjstadig: okay, thanks
11:28gfrlogif clojure and haskell had a baby, would it be a good replacement for scala
11:28gfrlog?
11:36clgvhmm clojure 1.2 seems to have problems with ^:dynamic -> java.lang.IllegalArgumentException: Unable to resolve classname: :dynamic
11:36clgvso I can't include this to be compatible to 1.3?
11:37stuartsierra1.2 doesn't support the ^:foo syntax.
11:38stuartsierraYou can use ^{:dynamic true} instead, which is equivalent.
11:38gfrlog^{:supports-foo-syntax true}
11:38clgvok. 1.2 assumes ^:dynamic to be ^{:tag :dynamic} I guess
11:39stuartsierraexactly
11:42bsteuberit'd be nice to have ^"foo" mean ^{:doc "foo"} in a similar way, wouldn't it?
11:48stuartsierrabsteuber: ^"foo" currently means ^{:tag "foo"} as well, which was sometimes useful for primitive arrays
11:48stuartsierrae.g., tags like ^"[[C"
11:50imadeis there any function that gives seq of tails? like (tails [1 2 3 4]) => ((2 3 4) (3 4) (4))
11:51imadeI mean no problem to write it myself, but thought that maybe exists, couldn't find myself tough
11:51stuartsierra,(iterate next [1 2 3 4])
11:51clojurebot([1 2 3 4] (2 3 4) (3 4) (4) nil nil nil nil nil nil ...)
11:52imadeoh, nice, thanks stuartsierra
11:52bsteuberstuartsierra: ic, didn't think of that :)
11:53gfrlog,(keep identity (iterate next (range 10)))
11:53clojurebotExecution Timed Out
11:53gfrlogoh I see
11:53gfrlogwell apparently that's not how you use (keep) :)
11:55stuartsierraThe seq is still infinite.
11:55Raynes&(reductions conj [] [1 2 3 4]) ; I love excuses to use reductions, even if the results are backwards.
11:55sexpbot⟹ ([] [1] [1 2] [1 2 3] [1 2 3 4])
11:56stuartsierra,(take-while identity (iterate next [1 2 3 4]))
11:56clojurebot([1 2 3 4] (2 3 4) (3 4) (4))
11:56bsteuber,(take-while identity (iterate next [1 2 3 4 5]))
11:56clojurebot([1 2 3 4 5] (2 3 4 5) (3 4 5) (4 5) (5))
11:56bsteuberdamn too slow
11:57stuartsierraThe don't call me The Pareditor for nuthin' :)
11:57bsteuberyou use paredit for chat? oO
11:57stuartsierrawell no
11:57bsteuberok copy&paste
11:58stuartsierraBut I could probably use Emacs.
11:58Raynesbsteuber, stuartsierra: I was typing that out as well, but I didn't even bother hitting enter. :<
11:58bsteuber:)
11:58RaynesI know my place.
11:59stuartsierraGood to know I can leave #clojure in your capable hands, bsteuber & Raynes.
11:59Raynes:D
12:04bsteubertoo bad there are sometimes harder tasks than knowing take-while ^^
12:05bsteuberstuartsierra: btw, what's your current hair color? :)
12:06stuartsierrabsteuber: boring old brown
12:26Jeffrey04anyone done 4clojure here?
12:29manutteryou mean the whole thing?
12:30RaynesJeffrey04: What do you mean?
12:31Jeffrey04@Rayes I'm stuck at the problems involving graphs/trees
12:31RaynesOh.
12:31Jeffrey04and there's one on word chain, roman literals, game of life
12:31manutterI haven't made it that far yet
12:32Jeffrey04only started with clojure last week, still can't seem to wire my brain properly to program in FP style :/
12:32Jeffrey04my solutions are still ridiculously long compared to other ppl (according to the graph) :(
12:33RaynesIf you've made it that far on 4clojure, you're doing better than you think you are.
12:33manutter4clojure is really good for exercising your FP skills
12:33RaynesSome of those problems are pretty difficult.
12:33manutterI've done a few that needed to be redone
12:33Jeffrey04@manutter yea, it is, learned a lot through it
12:35Jeffrey04@Raynes I hope so (:
12:35Jeffrey04been staring at the problem and is still clueless
12:36bendlasa
12:38manutterI keep getting stuck on little things like how to turn (first coll) into a seq
12:38manutter,(cons (first [1 2 3]) nil)
12:38clojurebot(1)
12:38manuttermeh, that works, but it doesn't look right
12:38manuttermaybe I need to go back to my crayolas
12:38Raynes&(list (first [1 2 3]))
12:38sexpbot⟹ (1)
12:38Jeffrey04,(seq (first [1 2 3]))
12:38clojurebotjava.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Integer
12:39manutterAh, list
12:39Jeffrey04oops
12:39manutterSee, I knew there was some trivially simple keyword I was overlooking
12:39Jeffrey04,(list (first [1 2 3]))
12:39clojurebot(1)
12:40Jeffrey04lol
12:40Jeffrey04so there are 2 bots here
12:40manutterI blame PHP (my day job) for rotting my brain
12:40Jeffrey04@manutter i was a php programmer before I started my postgrad too
12:41manutterYeah, it pays the bills
12:41Jeffrey04lol
12:42Jeffrey04my supervisor reaction after knowing I am learning clojure: don't learn strange (weird?) language~
12:42Jeffrey04lol
12:42gfrlogthey only lead to helping you think better
12:44manutterIf God had meant for us to program in clojure, He would have given us brains.
12:47imadecan anyone review my solution for the problem? I would like to get some feedback, whether it's idiomatic way to solve or what could I do better. Link https://github.com/imade/clojure-99/blob/master/src/clojure_99/problem26.clj and unit test https://github.com/imade/clojure-99/blob/master/test/clojure_99/test/problem26.clj
12:48StayInSkoolhi everyone
12:48StayInSkoolI know a bit of Scheme and ML and am a bit puzzled by Clojure specific syntax
12:49StayInSkoolfor instance, why are keywords important? what's wrong with just using strings for keys in maps?
12:50vinzent_StayInSkool, keywords are faster and idiomatic
12:50pjstadigkeywords also implement IFn
12:50technomancyStayInSkool: keywords communicate intent better, though strings could do the same job in many cases.
12:50pjstadigso you can access map values with them
12:51pjstadig,(map :foo {:foo "bar"})
12:51clojurebot(nil)
12:51pjstadig,(map :foo [{:foo "bar"}])
12:51pjstadig
12:51clojurebot("bar")
12:52StayInSkoolstarting with a comma evaluates syntax using clojurebot im assuming? heh
12:57StayInSkoolpjstadig: I don't understand your example. it's a vector, with a single entry that's a map, with :foo as a key of the first key-value pair?
12:58StayInSkoolbut, a keyword is also a function?..
12:58StayInSkoolsince you map it to the vector?
12:58pjstadigi mapped the function across the contents of the vector
12:58pjstadigin this case there was just one hashmap
12:58StayInSkoolso a keyword is a function?
12:58pjstadigmap called the "function" :foo with the argument being the hashmap
12:59StayInSkooli get that part. i just dont see how or why :foo is a function also
12:59pjstadigthe result of calling a keyword like a function with a hashmap as an argument is to lookup the keyword in the hashmap and return thevalue
12:59pjstadig,(:foo {:foo "bar"})
12:59clojurebot"bar"
12:59StayInSkoolright. i saw that in a few places. the syntax confuses me hah
12:59StayInSkoolimperative language baggage? hmm
13:00dnolen,(:foo nil)
13:00clojurebotnil
13:00dnolen,(nil :foo)
13:00clojurebotjava.lang.IllegalArgumentException: Can't call nil
13:00StayInSkoolnormally i'd do things to a collection, but here it seems like i start off with what i wanna find and then proceed to where it's to be found
13:00pjstadig,("foo" {"foo" "bar"})
13:00clojurebotjava.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn
13:01pjstadigit's convenient to be able to use the keyword like a function in certain contexts as a shorthand for looking up a value in a map
13:01pjstadigyou can't do the same with strings
13:01gfrlogif strings were functions....
13:02pjstadiggfrlog: just wait for C-in-C
13:02StayInSkoolI see pjstadig. thanks
13:03StayInSkoolwhat's the sense in having the value as a keyword too?
13:03vinzent_but you can also treat maps like a functions
13:04StayInSkool{:hello :bye}
13:04vinzent_,({"foo" "bar"} "foo")
13:04clojurebot"bar"
13:05gfrlogpjstadig: so rhickey wouldn't mind strings as IFn but didn't want it badly enough to wrap them?
13:05pjstadigi dunno
13:05pjstadighe wanted strings to be java strings
13:05pjstadigi don't know his feelings about strings implementing IFn
13:05StayInSkoolvinzent_: how on earth does That work?
13:05gfrlogI assumed strings as IFn would be considered ambiguous perhaps
13:06StayInSkooloh i see. that is confusing to read though heh
13:06gfrlogdunno. If passed map, lookup self. If passed regex, call (re-matches); if passed string, call substring?... could be fun and multipurpose
13:06pjstadiggfrlog: but if clojure's abstractions were written in clojure, then you could extend the IFn protocol to whatever you wanted...and you don't even have to ask Rich!!!!
13:07technomancyI asked Rich about making more types implement IFn via prototypes (regexes specifically), but you really lose fast-path inlining that hotspot can do, so he pretty much shot it down.
13:08gfrlogpjstadig: ah hah, good point.
13:08pjstadigwell is that any different with invokedynamic?
13:09technomancypjstadig: I don't know if he was considering that; he probably doesn't want to have to maintain a separate jdk7 codebase
13:09gfrlogclojure's doing this dance between dynamic and performant...
13:09technomancyif it is possible
13:09pjstadigdeprecate java 6...problem solved! :)
13:09vinzent_StayInSkool, well, as i see it, keyword-first syntax primarily used to access fields of some object, so (:foo qux) is equivalent for Qux.getFoo in Java
13:10technomancypjstadig: I'm all for it
13:10gfrlogpass it a positive integer and it returns .charAt
13:11vinzent_btw, why map-like functions accepts the fn, not the coll as the first arg? (like assoc and others)
13:12vinzent_so i can't do smth like (-> [1 2 3] (map inc) (assoc 0 :x))
13:13bendlasvinzent_: b/c it's called "to map a function over a sequence"
13:13arunknvinzent: I think it is because map actually can take multiple sequences as argument
13:13bendlasvinzent_: that's what ->> is for
13:13technomancyextending IFn was like the main thing I was excited about protocols for =\
13:13vinzent_,(->> [1 2 3] (map inc) (assoc 0 :x))
13:13clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.Associative
13:13gfrlogmaybe we need to write a ->< macro
13:14StayInSkoolor a >.< macro
13:14arunkngfrlog: lol
13:14vinzent_arunkn, i think it's not a problem - last arg can be fn
13:14arunknvinzent, I mean it would be easy to club variable args towads the end
13:15gfrlogvinzent_: when it comes down to it, different ways of composing the functions will result in different patterns that may or may not be compatible with -> or ->>; I don't think you can account for all cases no matter how you arrange the args
13:15arunknand as you said it is also semantically consistent
13:17vinzent_gfrlog, it's just strange for me that map-like fns have one agreement for args' order, and assoc-like have other one, and both groups are operating on the same datastructures
13:18arunkn -> and ->> forms also take ,,, to visually mark the (first/last) position where the result of the previous form goes right. Why isn't there a macro
13:19arunknwhich uses this?
13:19hiredmanarunkn: huh?
13:19Chousukearunkn: they don't "take" ,,,
13:19Chousukearunkn: ,,, is whitespace
13:20dnolenvinzent_: things which can work with assoc won't necessarily work with map.
13:21arunknChousuke: I din't know that the reader discarded ,,, as whitespace
13:21Chousukearunkn: it's pretty useful sometimes
13:21manutter,(let [x ,,,,,,, 1] x)
13:21clojurebot1
13:22manutter:)
13:22Chousukearunkn: to be specific, all commas are whitespace
13:22arunkndude, that's a loooot of commas
13:23vinzent_dnolen, but vectors and maps work. I'm just can't see the rationale behind this decision.
13:23arunknChousuke: I dint know that one either :)
13:24dnolenvinzent_: maps and vectors are only two data structures of many possible data structures, there are many others. Some may work with assoc and some may work with map.
13:25dnolenand some may work with both.
13:26vinzent_dnolen, ofcourse, but it didn't actually answer my question
13:27dnolenvinzent_: what more do you need to know?
13:29dnolen,(map vector [1 2] [3 4])
13:29clojurebot([1 3] [2 4])
13:29dnolenis another reason.
13:32manutter,(map [1 2 3 4] [5 6 7 8])
13:32clojurebotjava.lang.IndexOutOfBoundsException
13:32manutteroops
13:33vinzent_(map [1 2] [3 4] vector) can work fine too
13:33manutter,(map [0 1 2 3] [4 5 6 7])
13:33clojurebotjava.lang.IndexOutOfBoundsException
13:33manutteruser.stupid.ReadingComprehensionError
13:34manutter,(map vector [1 2 3 4] [5 6 7 8])
13:34clojurebot([1 5] [2 6] [3 7] [4 8])
13:34manutterls
13:35manutteroops, wrong window...
13:35arunkn:)
13:35bendlaslol
13:37manutterMySQL particularly resents it when I do that...
13:44amalloy(map [1 2] [3 4] vector) would be awkward to work with, from the POV of the guy implementing map. you can't just say (defn map [f & colls] ...), it has to be some nonsense like (defn map [& args] (let [f colls] ((juxt last butlast) args) ...))
13:44opqdonut_it's kind of a given that varargs come at the end
13:45opqdonut_thus (map fn colls...) and (assoc a-map key val key val ...)
13:47vinzent_apply is the single exception
13:47opqdonut_the argument order of apply corresponds to the argument order of the call it induces
13:47amalloyvinzent_: exception to what?
13:48opqdonut_amalloy: varargs in the middle
13:48manutterI didn't think apply took variable arguments
13:48amalloymmmm. i guess? you're thinking of it like (apply function arg arg more-args)?
13:48vinzent_yep, different args order would be confusing there
13:49manutter,(doc apply)
13:49clojurebot"([f args* argseq]); Applies fn f to the argument list formed by prepending args to argseq."
13:49manutteroh, I see
13:49manutterwow, that's pretty wild
13:52amalloyi always thought of apply as (apply f arg*), where the last "args" gets expanded in place; from that point of view the varargs aren't really in the middle
13:52amalloybut i think that's a silly point of view to have
13:53manutter,(apply + 1 2 3 [4 5 6])
13:53clojurebot21
14:25iceyis compojure still the standard web framework that people use with clojure?
14:26bsteubericey: now ring is the framework and compojure a set of ring-plugins
14:27iceybsteuber: ah right... they did that like a year ago, no?
14:28bsteuberI think so, yes
14:28iceybsteuber: either way, thanks :)
14:35iceywow, bringing up a working environment is so much easier than it used to be
14:37manuttericey: what did you use to start it?
14:37iceymanutter: i used lein for everything
14:37manutterOk, that's what I thought
14:38manutterJust wanted to be sure I wasn't missing anything new :)
14:38iceymanutter: i think the last time i seriously played with clojure was < 1.0; everything has matured pretty significantly since then
14:39manutteryeah, it's coming along nicely
14:58dnolenooooh, Dan Freidman & Co are working on extending miniKanren to CLP(FD) !
15:02MoominpapaI know this is a really stupid question, but how do you provide proxy settings to leiningen?
15:02MoominpapaI assumed you'd just export HTTP_PROXY like normal, but it appears to be doing exactly nothing :(
15:04fliebeldnolen: oooh! What does CLP stand for again? I only remember the finite domain part.
15:05manutterMoominpapa: you mean for connecting to remote repositories to download dependencies and such?
15:05MoominpapaYes.
15:05MoominpapaI'm finally trying to do some clojure at work
15:05MoominpapaHome is easy :)
15:05dnolenfliebel: Constraint Logic Programming, yeah just got an email from Dan Friedman himself, seems like they're working hard on having something done by the end of summer.
15:05manutterWell, I don't have *much* of an answer, but what I have is "You don't set proxy for leiningen, you set proxy for maven"
15:06manutterand even that's just a guess
15:06MoominpapaI suspect it's a pretty good guess, thanks.
15:06manuttergood luck
15:06fliebeldnolen: Cool, so that means you don't have to invent a constraint solver yourself, right?
15:06MoominpapaOf course, since my work blocks IRC, it'll be tomorrow by the time I figure out if that does the trick :)
15:07dnolenfliebel: precisely.
15:07manutter:)
15:07fliebeldnolen: Awesome. I'm almost beginning to wonder if they have any plans for predicate dispatch :P
15:08dnolenfliebel: yeah, I'm very, very curious as to their approach for making it efficient.
15:09fliebeldnolen: Is constraint solving a special case of predicate dispatch yet?
15:10gtrak`cemerick, someone mentioned earlier you had a blog post for integrating spring security with clojure, but I can't find it, do you have a link?
15:10stuartsierraI said it, but I was wrong.
15:10cemerickgtrak`: I've not written such a thing. There's nothing special you need to do to use spring-security with Clojure, though.
15:11gtrak`ah I see
15:11dnolenfliebel: no constraint solving's all about making relational programming efficient for certain domains - integers for example (you can solve Sudoku)
15:11dnolenfliebel: but would also be useful for type inference I would think.
15:12markskil1eckWhy does (use '[penumbra opengl]) work but not (use '[penumbra]) ?
15:13markskil1eckThe latter gives me a "could not locate on classpath"
15:14stuartsierra`use` expects collections to be prefix-lists or vectors-with-keyword-options.
15:14stuartsierraThat is, (use '(penumbra opengl)) tries to load penumbra.opengl
15:15stuartsierraYou could also say (use '[penumbra.opengl :only (foo bar)])
15:15markskil1eckI see, I see.
15:15markskil1eckSo [a b c] becomes [a.b.c] ?
15:16stuartsierraNo, it becomes a.b and a.c.
15:16stuartsierraAnd it should be a list, not a vector.
15:16markskil1eckWhy is that?
15:16stuartsierraBecause that's what the docstring says.
15:16stuartsierraAnything else may not be supported in the future.
15:17markskil1eckAlright
15:17markskil1eckThanks, stuartsierra.
15:17stuartsierra'welcome
15:17markskil1eckYou mean '(welcome)
15:18stuartsierraheh
15:35TimMcArgh, my kingdom for (binding) in Java.
15:36stuartsierraWell, Var.pushThreadBindings works...
15:40scottjbetter name for this fn (or is this in core/contrib?) (defn assoc-swap [map key f & args] (assoc map key (apply f (get map key) args)))
15:44stuartsierrascottj: I think you want update-in
15:45scottjstuartsierra: oh yeah thanks
15:45stuartsierra'welcome
15:45scottjfor some reason I only think of update-in when I have more than one level of keys
15:46stuartsierraYeah, it's slightly odd that there's no single-key `update` but `update-in` works fine with a vector of one key.
15:49cemericknot sure if dropping a vector literal is worth having another core fn
15:49cemericker, you know what I mean. :-P
15:49stuartsierrathat's probably why it hasn't been seriously considered.
15:50TimMcstuartsierra: Whereas I was disappointed to discover that (update-in m [] v) fails to return v :-P
15:50technomancycemerick: do you know if maven has any existing conventions for handling libraries with native code?
15:50technomancymy googles were unable to turn up anything (in any JVM language, actually)
15:51stuartsierratechnomancy: people do it, I know that much.
15:54technomancystuartsierra: not enough to have settled on a convention for signaling "this jar has native components" I guess
15:54technomancy?
15:55stuartsierrahttp://docs.codehaus.org/display/MAVENUSER/Projects+With+JNI
15:55amalloyTimMc: you surely mean assoc-in for that example, or else "return (v m)"?
15:56stuartsierratechnomancy: I think native code often has a "classifier" part of its name in addition to group/artifact/version.
15:57stuartsierrahttp://www.sonatype.com/books/mvnref-book/reference/profiles-sect-tips-tricks.html#profiles-sect-platform-classifier
15:57technomancyinteresting; thanks.
15:58stuartsierra'welcome
16:01TimMcamalloy: I surely do.
16:07thorwilhmm, how do i get that :pattern past the reader? (html [:input {:type "text" :name "slug" :required "required" :pattern "[a-zäöüß0-9_\-]*"}])
16:07amalloythorwil: what is the backslash for?
16:08amalloyalso, those characters after "a-z" are all rendering as question marks. i know my client supports unicode, so i'm inclined to blame yours for mangling the character encoding
16:08thorwilamalloy: has beena while since i wrote and tested that, i think \ really does stand for \
16:08amalloy&"\-"
16:08sexpbotjava.lang.Exception: Unsupported escape character: \-
16:09amalloyunlikely
16:09amalloyif you wanted to allow literal backslashes you'd need "\\"
16:10cemericktechnomancy: The only native lib I've (knowingly) used in maven is swt; it's packaged as regular jars, no classifiers AFAICT. e.g. http://search.maven.org/#artifactdetails|org.eclipse.swt.gtk.linux|x86|3.3.0-v3346|jar
16:10amalloyand being inside a regex character class would probably mangle it further so that you need \\\\
16:12thorwilamalloy: \\ makes it appear as \ in the final html. thanks!
16:12cemericktechnomancy: I was confused by the discussion about special-casing native deps in lein — as far as I knew, they could be loaded from plain-jane jars.
16:12cemerickPerhaps the swt runtime was unpacking them for me and dynamically updating the library path? *shrug*
16:13thorwilamalloy: now i recall it's \- escaping the minus, as that would define a range, otherwise. duh
16:13amalloyno, it wouldn't
16:13amalloy- at the start or end of a character class can't define a range
16:14amalloya lot of people seem to escape them instead of putting them at the end because they don't know any better. i think that hurts readability, but whatever. it just struck me as weird that you'd put it at the end *and* apparently attempted to escape it
16:15thorwilwell, i probably could count the number of regexps that i wrote in life on 2 hands :)
16:16thorwilgotta run, good night! :)
16:22gfrlogI could probably indicate the set of hands that I've used it my life in one regex: #"(lef|righ)t"
16:22gfrlogs/it/in
16:22sexpbot<gfrlog> I could probably indicate the set of hands that I've used in my life in one regex: #"(lef|righ)t"
16:24TimMcamalloy: I always put the "-" at the end of the range, but I worry that I'll go to add another character...
16:25amalloyTimMc: i put it in the front, possibly for that reason
16:28TimMchah
16:28TimMcWhy didn't I think of that?
16:29gfrlogI think I once read somewhere that you HAVE to put it at the front, so I always did.
16:29gfrlogApparently that's not strictly true.
16:29amalloyi actually worry about escaping it because i never know if that will accidentally include a literal backslash in the class
16:29gfrlogat least in the same sense that you don't HAVE to close your HTML tags.
16:30amalloygfrlog: the difference is that you do have to close your (x)html tags, and you don't have to put the - at the front :P
16:30gfrlogI was talking about the difference between strict specification and actual outcome
16:31gfrlogif the browser does what you wanted it to, that could be "good enough", but there's no guarantee it'll work in the next version of the browser
16:36amalloygfrlog: right. and regexes *do* specify that you don't have to put it in front
16:37scottjwith ring/compojure is there a wrapper/middleware to turn form-params that are "false" or "true" to true and false?
16:37gfrlogThat was th possibility I was leaving open when I said "at least"
16:41edwHas anyone else had problems with SLIME exploding when Clojure returns a Unicode string. (Using CLOJURE-JACK-IN, that is...)
16:41raekedw: yes. either SLIME or swank-clojure is configured for the wrong version
16:42raekedw: try customizing the slime-net-coding-system variable
16:42edwraek: What should it be? UTF8?
16:42raek*version -> encoding
16:42raekedw: yes, UTF-8
16:42amalloyholy cow. edw, lisp channels are only allowed a couple dozen capital letters per day. i think you just used them all up
16:43edwSorry about that; it's the case-insensitive Schemer in me.
16:43edwShould I give 1.7 a try? That looks new...
16:44raekedw: sorry, I meant encoding, not version
16:45edwSo: slime-net-encoding-system?
16:45raekedw: did you manage to customize the slime-net-coding-system variable (mine has the value utf-8-unix)
16:45raekyes
16:46raekor was it already set to utf-8-unix?
16:46edwDurn. Yeah. It's set to iso-latin for some reason. Odd.
16:46raekyeah, Slime defaults...
16:47edwI'm wondering what the deal is, as I don't believe SLIME was pooping the bed on Unicode previously.
16:47raekedw: try reconnecting and evaluating the expression (seq "åäö"), it should yield (\å \ä \ö)
16:47fliebelWhat's that Clojure deployment thing called? Thought it was based on Crane or Pallet or whatever.
16:48edwWill (whispers)SLIME stomp on the slime-net-coding-system in my .emacs which clojure-mode loads?
16:49cemerickfliebel: Both crane and pallet are used for deployment automation, with different approaches.
16:49edwShould I add a hook or something?
16:50cemerickfliebel: http://pallet.github.com/pallet/
16:50cemerickmy preference, for whatever that's worth
16:53edwAh, so much better! Thanks amalloy and raek!
16:53amalloyhaha, i get credit? all i did was complain about upper-case
16:54edwHey, every little bit counts.
16:56edwI have a grad student project: build a text classifier that rates input text from 0 (the Dude in the bathtub pre-ferret) to 9 (the Dude, squealing ferret in the tub).
17:21scottjI seem to remember there being a new webmachine inspired framework for clojure other than clothesline, anyone know the name? google fail
17:27edwIs `sort' stable?
17:28edwGoogle says: Yes, it is.
17:29amalloyedw: yeah
17:29stuartsierraYes, it uses java.util.Collections.sort
17:34scottjhttps://github.com/malcolmsparks/plugboard is what I was looking for
17:34raekspeaking of clothesline, anyone know there it lives nowaday? I was going to read about it, but got 404...
17:34raekscottj: ah, will check that out...
17:35scottjraek: kirindave/clothesline was updatd yesterday
17:36amalloyhas anyone used java's piped input/output streams? i would expect that if i .close the output stream that would cause the input stream to still be readable until it gets to the end of data, but i'm not sure that's what's happening
17:38hiredmaneverytime I start using piped i/o it eventually vanishes
17:38technomancycemerick: yeah, I was wondering how it knows to do the unpacking and setting java.library.path, but if the swt runtime is handling that then it can't be generalized for other native libraries.
17:39amalloyand i can't find docs saying what happens when you close them
17:40amalloyhm. but the docs for .read say that it throws an exception if the pipe is broken. so i can't figure out how to signal end of stream
17:42hiredmanamalloy: if you write an EOF, it will be read
17:45amalloyhiredman: so (write-actual-data) (.write out -1) (.flush out), and let the guy with the input end close it himself?
17:45hiredmanamalloy: yes
17:48raekhrm, why doesn't the javadoc for OutputStream mention that passing -1 to .write signals end of file?
17:49raek(InputStream.read mentions -1 though)
17:49amalloyraek: i don't think it's true
17:50amalloyif i write -1 to a ByteArrayOutputStream, it writes a 255 byte
17:51amalloyas seen at https://gist.github.com/1001356
18:01chewbrancatechnomancy: ping
18:04technomancychewbranca: hallo
18:08amalloyfwiw i think there must be something wrong aside from my use of pipes. if i write a million 0 bytes to a POS then .close it, then my PIS reads a million 0s followed by a -1, no exception
18:17technomancyhttp://news.ycombinator.net/item?id=2604558 <= clojure on heroku
18:18chewbrancatechnomancy: hey
18:18chewbrancatechnomancy: hahaha yeah was just going to ask if you saw that yet
18:20technomancyI actually helped them test it =)
18:20technomancybut now I can talk about it
18:21chewbrancajust replied in that hn thread
18:21chewbrancaoh cool
18:22chewbrancagetting charged for the heroku app
18:24chewbrancaor at least a worker associated with it
18:45chewbrancaheh... never mind, heroku changed their billing so you don't get a free dyno per app, but basically get one free dyno worker overall
18:46chewbrancagotta love this quote: "On June 1, 2011, Heroku switched from billing for “dynos” to billing for “dyno-hours”, which is more clear. "
18:46chewbrancatalking about changes to be made tomorrow in the past tense
18:49amalloychewbranca: happen to know what time it is in japan?
18:51chewbrancaamalloy: most likely june 1st, but heroku is an american company running on american servers (primarily speaking, I'm sure they have expanded out past america)
18:51technomancychewbranca: you coming on thurs?
18:51chewbrancatechnomancy: yeah definitely
18:52amalloychewbranca: that's fine, but it seems parochial to tease them for calling june 1st "the future" when they presumably have clients in japan, who are even now being billed in this new way
18:52technomancycool; maybe we can throw together a web app.
18:52amalloyerrr, that's worded badly but i think you see what i mean
18:52chewbrancaamalloy: not when my invoice says time used on may 31st
18:55__name__They should have specified the timezone.
18:56chewbrancaamalloy: I hear what you're saying, which is why I commended them on their progress, and I am rather excited by their support for other languages, especially clojure
18:56__name__And the time, for that matter.
18:56chewbranca__name__: exactly, or on a per user basis
18:56__name__But ‘1st of June’ is a completely vague statement.
18:57__name__I also hate how some use ‘month’ as a time-span.
18:57__name__A ‘month’ is everything from 28 to 31 days.
19:00chewbranca__name__: yeah I can't stand working with month intervals, currently have to break up a monthly rate down to amount per day for some billing stuff
19:00__name__chewbranca: Tell them that is impossible :D
19:01chewbrancaheh... kind of funny, I recently switched from hourly rate to monthly rate, and technically its far more costly for me to take a day off in february than it is in may
19:01chewbrancawell 'far more' is exagerating, but definitely more expensive
19:02__name__It's just insane.
19:03technomancyyup; about time we switched to metric time anyway
19:15technomancyugh; would it kill clojure.core/memoize to expose the cache atom in metadata?
19:31cemericktechnomancy: good idea; seems like something that could slip in without much fuss, too
19:46technomancyI thought it was intentional, but I guess it wasn't practical back in the day because functions couldn't have metadata when memoize was written.
19:48hiredman~help
19:48clojurebothttp://www.khanacademy.org/
20:56scottjwas there a project/library that made scala/jruby/clojure integrate better, like making it as easy to call each of them as it is to call java?
21:00technomancyscottj: I had a clojure-gem that allowed calling clojure data structures and STM from jruby, but it was one-way and stuck with clojure 1.0
21:35hiredmandnolen: you mentioned that core.logic does pattern matching, I guess for "does pattern matching" I would expect to see something like cond pattern expr, pattern expr, pattern expr
21:36hiredmanwhich I don't see an example of anywhere in core.logic
21:39Ownatik_k I'm just starting to take a look to clojure, starting with 4clojure. in the following expression: (= __ (conj '(2 3 4) 1) what does the ' mean
21:40gfrlogit means quote
21:40gfrlogit is equivalent to (quote (2 3 4))
21:41gfrlogwhich means that the list is unevaluated
21:41scottjOwnatik_: if you quote a list when it's evaluated it's just a list, otherwise a list is evaluated to a function call
21:41gfrlogI was trying to put just those words together but was having trouble
21:44Ownatik_ok I definately don't get functional programming yet
21:45Ownatik_my brain won't parse what you just said
21:45Ownatik_lol
21:45scottjOwnatik_: this isn't functional programming related
21:45scottjOwnatik_: most languages have separate syntaxes for lists and function calls, lisp doesn't
21:46scottjOwnatik_: so in other languages you could have foo(a,b) and (foo, a, b) perhaps. in lisp you just have (foo a b). if you want it to be a list it needs to be quoted, otherwise it will be a function call
21:47Ownatik_ok I understand now
21:47Ownatik_and got the solution
21:47Ownatik_thanks
21:47Ownatik_so the quote just mean it's a list
21:48tomoj&(list? (read-string "(+ 1 2)"))
21:48sexpbot⟹ true
21:48tomoj&(eval (read-string "(+ 1 2)"))
21:48sexpbotjava.lang.SecurityException: You tripped the alarm! eval is bad!
21:48tomojoh, duh
21:50scottjOwnatik_: not exactly, the quote means when evaluated give whatever is quoted. so 'a evaluated is a
21:50Ownatik_oh ok thanks for the clarification
21:51scottjOwnatik_: lcojure uses [a b c] for list like things more than '(a b c)
21:51amalloyOwnatik_: land of lisp has a good explanation, near the beginning iirc, of what ' really is
21:51scottjOwnatik_: note that if a = 1, [a] is evals to [1] and '(a) evals to (a)
21:53amalloyhm. not land of lisp. i seem to have meant http://lisperati.com/casting.html
21:53scottjeven better consideringit's freely available online
21:54amalloyyeah, http://www.lisperati.com/clojure-spels/syntax.html and the page after that talk about quoting
21:56amalloyOwnatik_: you might find the above a good resource for learning, as well as 4clojure
22:12netrealmHey, I have a question about ring; if this is the wrong channel, please let me know where a better place is. If I wanted to dynamically add/remove routes, how would I go about that?
22:13amalloynetrealm: that's actually a question about compojure (or moustache), not ring
22:14netrealmOh, okay.
22:14amalloyring just takes a request map, gives it to you, and receives a response map
22:14amalloycompojure has defroutes , which constructs a function (for giving to ring) that decides what to return based on the url
22:15hiredmandnolen: looks like there is a typo in binding-map'
22:15amalloyso really, i suspect the answer is "don't bother with compojure for the dynamic part of your routes"
22:16hiredmandnolen: when I fix the typo in binding-map' (binding-map' '{:foo ?foo} {:foo 5 :bar 5}) throws an exception
22:16hiredmandoes logic have jira issues yet?
22:17netrealmamalloy: and instead use...?
22:18amalloydefine a subtree of your application that you want to match "dynamically", like (GET "/dynamic/*" (do-runtime-whatever)). i don't know off the top of my head the compojure syntax for getting out the full request map
22:19amalloybut it's not that hard to work with a raw ring request map: see https://github.com/mmcgrana/ring/raw/master/SPEC for the spec
22:19scottj(GET "/dynamic/*" request (do-runtime-whatever))
22:19scottj(GET "/dynamic/*" request (do-runtime-whatever request))
22:20amalloythanks scottj
22:20netrealmah...I see...I missed the part where I could have a wildcard match
22:21amalloynetrealm: compojure does a fair bit of stuff that looks magical but isn't really very complicated. i recommend getting at least comfortable with the underlying ring stuff so you can fall back if you want
22:22Ownatik_scottj, amalloy: had to go afk, sorry for the lack of response and thanks for the tips.
22:23netrealmamalloy: cool, thanks. I'll working on digesting the ring docs.
22:23amalloy(i had basically no idea how the web frameworks worked like two months ago, and now i'm giving advice. you should (a) marvel at how cool the frameworks must be, and (b) take advice with caution)
22:24netrealmHaha, okay. I'm pretty new to clojure, so I'm still working on understanding how to read example code and reason about what it's doing.
22:38dnolenhiredman: thx for the report. was more than a couple of typos, a couple of bugs as well, fixed now, latest pushed to github and Clojars.
22:39dnolenhiredman: http://dev.clojure.org/jira/browse/LOGIC
22:45hugoddnolen: prelude/defnu has a typo - lgoic
22:46dnolenhugod: oof thx
22:47dnolenhugod: fixed.
22:48hugodthanks
22:53hiredmanhttp://clojars.org/core.logic is awesome
22:53hiredmananyway, what I just pulled from clojars seems to be the same as what I had ealier
22:54dnolenhiredman: yeah, that Clojars page is weird, not sure what the deal is.
22:55hiredmanI see the fix on github though
22:58dnolenhiredman: I repushed to Clojars, still not work?