#clojure logs

2011-04-18

02:06HavvyHow can you test "String can be converted into integer"?
02:15mec,(map #(try (bigint %) (catch NumberFormatException e :nope)) ["5" "5.0" "1/3" "high"]) ;p
02:15clojurebotmec: Pardon?
02:15amalloymec: catch is a no-no for bots
02:15mecaw
02:16HavvySo no other choice than using try/catch... :(
02:17mecI suck at regex but something like #"^-?[0-9]*" should do
02:17HavvyOh, duh...
02:23mec,(map #(re-seq #"^\-?[0-9]*$" %) ["5" "5.0" "1/3" "high"])
02:23clojurebot(("5") nil nil nil)
02:43markomanis there some general function to check if some value is "empty" ?
02:43markoman"" [] {} {{}{}} nil for example
02:44shachafmarkoman: {{}{}} isn't empty.
02:46markomanshachaf: by which function call you can check it?
02:47shachafNo idea. Seems like an odd operation.
02:49amalloyif you give up on identifying {{}{}} as empty, you can use empty?
02:49amalloy&(map empty? ["" [] {} {{}{}} nil])
02:49sexpbot⟹ (true true true false true)
02:49shachafAh, there you go.
02:49amalloyempty? is basically (complement seq)
02:52markomani see, i though empty? is just for strings. if i want to check {{}{}} i need to make nested check. is there some way to use map for nested things like {{}{}} or [[][]]
02:52amalloymarkoman: it is a terrible idea
02:52mec&(map (comp empty? flatten) ["" [] {} {{}{}} nil])
02:52sexpbot⟹ (true true true true true)
02:53amalloymec: when someone walks into your store crying, asking for a pistol, don't sell them one. what people think they want is often pretty far off from what is good for them
02:54mecbut those are the people willing to pay extra :D
02:54amalloyalso that doesn't really work: ##((comp empty? flatten) [""])
02:54sexpbot⟹ false
02:55mecanywho, I added a findarg to sexpbot but I have no idea how to test the whole thing to see if it works
02:55amalloymec: where's your fork?
02:56mechttps://github.com/mecdemort/sexpbot
02:57markomanso I think I need to make sure data structure doesnt contain empty nested maps. this is good for now
02:57amalloymec: doesn't compile
02:57amalloyi'll have a look
02:57mecbah, the find-arg works fine on its own, I just kind of shoved it in there tho
02:59amalloymec: kinda-sorta works with a little tweak. needs better syntax
02:59amalloy:findarg map '% [1 2 3] [2 3 4]
03:00buttered-toast[clojure.core/unchecked-inc clojure.core/inc]
03:00amalloyvery neat though
03:00mecwhat was the tweak needed?
03:00amalloyyou just used the wrong name
03:00amalloyfor a symbol
03:00amalloythe tweak i think it still needs is some way to not need to quote %
03:01mecooo right, forgot to rename that
03:01amalloy:part #clojure
03:01buttered-toastBai!
03:01amalloyman. that part message needs to die
03:02mecI was having the same problem with findfn, but if you make it a macro so you dont have to quote, then other things break
03:07amalloymec: fixed
03:08amalloyas long as nobody wants to use % for something else :P
03:09mecsince its the normal aphorism for #() i dont think its too common to use it elsewhere
03:09mecr/aphorism/anaphora/
03:10amalloy$findfn #(inc %) [1] [2]
03:10sexpbot[clojure.core/map clojure.core/pmap clojure.core/keep]
03:10amalloyi think my fix breaks that behavior
03:11amalloywow, it doesn't. three cheers for clojure's reader
03:13amalloymec: anyway, thanks. that'll be added next time sexpbot gets reloaded
03:13meccool
03:42Derander$findfn 1 2
03:42sexpbot[clojure.core/unchecked-inc clojure.core/inc]
03:42Deranderbad ass
03:42Derander$findfn [1 2 3 4] [[1 2] [3 4]]
03:42sexpbot[]
03:43Derander$findfn 2 2 [1 2 3 4] ((1 2]) (3 4))
03:43sexpbot[]
03:43Derander$findfn 2 1 [1 2 3 4] ((1 2]) (3 4))
03:43sexpbot[]
03:43Derander$findfn 2 2 [1 2 3 4] ((1 2)) (3 4))
03:43sexpbotjava.security.PrivilegedActionException: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)
03:43amalloy:findarg 2 [1 2 3 4] [[1 2] [3 4]]
03:43buttered-toast[]
03:43amalloygr
03:43Derander$findfn 2 2 [1 2 3 4] ((1 2) (3 4))
03:43sexpbotjava.security.PrivilegedActionException: java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn (NO_SOURCE_FILE:0)
03:43DeranderI fail
03:43Derandergiving up now
03:44amalloy$findfn 2 [1 2 3 4] [[1 2] [3 4]]
03:44sexpbot[clojure.core/split-at clojure.core/partition-all clojure.core/partition]
03:44amalloyDerander: ^
03:45Deranderdoesn't partition take two integer args optionally?
03:46amalloyDerander: yes. but you never gave it a wellformed thing to test against :P
03:46Derandernooooooo
03:46amalloy$findfn 2 2 [1 2 3 4] [[1 2] [3 4]]
03:46sexpbot[clojure.core/partition-all clojure.core/partition]
03:46Deranderhahahahahah
03:46Derandergod damnit.
03:46DeranderI need paredit for irc
03:46amalloyDerander: funny you should mention that!
03:46amalloy&(let [x 1) (inc x))
03:46sexpbot⟹ 2 ; Adjusted to (let [x 1] (inc x))
03:47DeranderI do not understand
03:47Deranderoh
03:47Deranderimpressive
03:48amalloyit only works in contexts where he knows the rest of the line is an input. eg, ##(let [x 1) (inc x)) won't work, because he tries to (read) what comes after ## to see if it's a command
03:48Deranderunderstand
03:48Deranderunderstood*
03:48Deranderdamn, writing ability goes way down after midnight apparently
03:48Deranderstrangely though I'm dominating at words for friends
04:32markomanhmh.. i have a function that returns a sequence, but I'd like return value be a map
04:32ejacksonmarkoman: try (into {} )
04:32ejacksonyou'll have to get the key/val orders correct
04:34amalloy&(into {} (map vec (partition 2 (range 10))))
04:34sexpbot⟹ {0 1, 2 3, 4 5, 6 7, 8 9}
04:34ejackson,(into {} [[:a 1] [:b 2] [:c 3]])
04:34clojurebot{:a 1, :b 2, :c 3}
04:36markomanits a deep nested map inside, but basically goes like: ({:key "val"} {:key "val"}) -> [{:key "val"} {:key "val"}]
04:36markomanand sorry, its not a map on return but a list
04:37ejacksonmarkoman: try merge in that case
04:38markomanim giving this to the function: [{:key "val"} {:key "val"}] and expect [{:key "val2"} {:key "val2"}] but instead getting ({:key "val2"} {:key "val2"})
04:38ejackson,(apply merge [{:a 1} {:b 2} {:c 3}])
04:38clojurebot{:c 3, :b 2, :a 1}
04:39ejacksonso you want a vector, but its giving you a list ?
04:39ejackson,(into [] '({:k1 :v1} {:k2 :v2}))
04:39clojurebot[{:k1 :v1} {:k2 :v2}]
04:40markomanim still bad with terms, but id say i want [] but get sequence () probably because of for loop i have there inside the function
04:40markomanok, i think i need to try into
04:41amalloymarkoman, ejackson: (vec foo) is better than (into [] foo) most of the time
04:41ejacksonmarkoman: by design everything accepts and returns seqs, and you then plonk that into whatever concrete structure you want after processing.
04:41ejacksonamalloy: why's that ?
04:42amalloyejackson: it's clearer in intent, i think. and shorter, not that that matters much
04:43ejacksonOK. I always use into when 'casting' as its clearer to me that way. Funny.
04:44amalloyejackson: well, into is overloaded a bit
04:44amalloy&(into [1 2 3] [4 5])
04:44sexpbot⟹ [1 2 3 4 5]
04:44amalloyie, it's not always for putting something into an empty collection
04:45ejacksonthat's true, its got a bit conj hustle going on as well.
04:45ejacksoni see you point amalloy
04:45amalloybut (into {}) is super-useful
04:45amalloyvec is probably faster too, since it gets you into java-land
04:46amalloy&(time (dotimes [_ 1e4] (vec (range 1000))))
04:46sexpbot⟹ "Elapsed time: 4604.595346 msecs" nil
04:46amalloy&(time (dotimes [_ 1e4] (into [] (range 1000))))
04:46sexpbot⟹ "Elapsed time: 3153.579926 msecs" nil
04:46amalloyhaha
04:46ejackson:D
04:46amalloyejackson: you win this round, but i'll be back!
04:46ejackson,botstnack
04:46clojurebotjava.lang.Exception: Unable to resolve symbol: botstnack in this context
04:46ejackson,botsnack
04:46clojurebotjava.lang.Exception: Unable to resolve symbol: botsnack in this context
04:47ejacksonhehehe, i hate it when that happens
04:47amalloy$botsnack
04:47sexpbotamalloy: Thanks! Om nom nom!!
04:47amalloy(since i was using sexpbot anyway)
04:47ejacksonoh yeah, you're using sexpbot.
04:47amalloy~botsnack
04:47clojurebotthanks; that was delicious. (nom nom nom)
04:47amalloyto talk to clojurebot
04:47ejacksonits like perl in here with these bots...
04:48amalloy> 1
04:48hsbot 1
04:48ejacksonthanks amalloy, i'll try to remember (again)
04:48ejacksonhsbot !
04:48ejacksonwho's that ?
04:48amalloyi know, i noticed him yesterday
04:48amalloyhe's someone's haskell bot
04:48amalloy> [1,4..15]
04:48hsbot [1,4,7,10,13]
04:48ejacksonhmmmmm
05:01markomanso its into :)
05:08ejacksonalrighty.
06:34fliebelWhere would I look for creating cool interfaces on Mac? Like ones that really go swoosh and poof, and not simply look like Mac widgets.
06:37ejacksonfliebel: tried apache pivot ?
06:38ejacksondunno about its coefficient of poof, however.
06:39fliebelejackson: No I did not. Googling now.
06:39ejacksoni always end up using Swing though
06:40fliebelejackson: Can you make Swing apps that look and feel good on Mac?
06:40ejacksongood enough for me...
06:41ejacksonperhaps there's some grating nastiness that I'm not sensitive enough to notice
06:41mrBliss``fliebel: http://code.google.com/p/macwidgets/
06:41fliebelmrBliss``: Is that with wx?
06:42mrBliss``fliebel: nope, just swing but requires some jars
06:42fliebellooks nice...
06:43mrBliss``fliebel: http://www.devdaily.com/apple/mac/java-mac-native-look/java-on-mac.shtml
06:43ejacksonmrBliss``: cool
06:47fliebelexit pivot. Even worse than Swing so far.
07:52markomanim still struggling with changing sequence to list/vector
07:57markomantwo for loops iterates and returns ( ( {'a 'b} ) ( {'c 'd} ) ) but what i want is simpler form [{'a 'b} {'c 'd}]
08:14kephale, (apply vector '(1 2 3))
08:14clojurebot[1 2 3]
08:14kephale, (apply vector (flatten (list '( 1 2 3) (3 4 5)))
08:14clojurebotEOF while reading
08:14kephaleerr
08:15kephale, (apply vector (flatten (list '( 1 2 3) (3 4 5))))
08:15clojurebotjava.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn
08:15kephalegagh
08:15kephaleoh
08:15kephale(apply vector (flatten (list '( 1 2 3) '(3 4 5))))
08:15kephale, (apply vector (flatten (list '( 1 2 3) '(3 4 5))))
08:15clojurebot[1 2 3 3 4 5]
08:15kephaledunno if you need the flatten though
08:16markomani need to test
08:16kephaleit looks like you might though
08:18markomanits also in recursive loop. im using into [] at the moment, but problem is, i get too many nests, it may well be, that flatten works when wrapped over for loops
08:19opqdonut_markoman: are you aware that you can do (for [thing some-things element-of-thing thing] ...) ?
08:20opqdonut_,(let [vs [[1 2 3] [4 5 6]]] (for [v vs el v] {:a el}))
08:20clojurebot({:a 1} {:a 2} {:a 3} {:a 4} {:a 5} {:a 6})
08:24markomanhmh... probably not useful in this case, but good to know. it looks similar to let [a b c (d a)]
08:24opqdonut_yeah but you kinda get the flatten for free
08:30markomanoh yes. well the problem is two for loops returns sequence, which i want to be a vector, its kinda backward
08:32markomanlet me test, if its still confusing, i need to put a pastebin
08:32kephalemmm, yeah, i'm not sure why a concat wont work
09:53scottjmoving webapp from just jetty to jetty in dev and tomcat in production, I was using an environment variable to tell app whether it's test/dev/production, any recommendations for how best to do that with wars? set an environment variable on tomcat itself?
10:00joegallojndi works well for that sort of thing
11:54amalloykephale: flatten is dreadful for "general use". it will always mash every level of nesting all the way down; usually you want something that mashes a predefined level of nesting
11:54KirinDavePlease to enjoy being confused by this: https://github.com/ryan-allen/lispy
11:54KirinDaveCompletely inscrutable.
11:55KirinDaveIt's like, 'Yes, smalltalkers did indeed do this. Not sure where lisp comes in."
11:55amalloyeg here he probly wants (into [] (mapcat whatever-function-you-were-using-map-with the-collection))
13:04ilyakhi *
13:05ilyakWhat's the best way to express the following idiom in Clojure: reading file by one line and being able to read "current" line and advance to the next one
13:05ilyakWe should forget "current" line when we advanced, but we would need to read the "current" line multiple times
13:06manutterAre you familiar with line-seq?
13:07pjstadig,(doc line-seq)
13:07clojurebot"([rdr]); Returns the lines of text from rdr as a lazy sequence of strings. rdr must implement java.io.BufferedReader."
13:07ilyakSo the first operation would be (first) and the second operation would be (rest)?
13:07pjstadigmost often used inside of a with-open, but you just have to make sure the lazy seq doesn't escape the with-open, or bad things will happen
13:08ilyakWould it handle calling (first) more than once and would it properly discard old lines when (rest) is called?
13:09pjstadigyou could do (with-open [f (reader "somefile")] (doseq [current (line-seq f)] do-something))
13:09pyrwhat about read-lines ?
13:09pyr(doseq [line (read-lines "/some/file")] (do-something-with line))
13:09manutterWhy do you need to read the first line more than once? Could you just put the current line into a variable and re-use that as needed?
13:10technomancyread-lines is deprecated as it was a common source of resource leaks
13:10technomancybecause it doesn't work with with-open
13:13raekilyak: when you use a lazy sequence like line-seq, you can hold on to a certain subsequence, go forward in the sequence, discover that you need to try someting in another way and jump back to the old subsequence
13:13raekilyak: calling first multiple times on the same object will yield the same value
13:13ilyakraek: okay, it's cool
13:17ilyakIf I (map ... lazy-seq), would I get another lazy-seq with those magical properties?
13:17raekilyak: yes, you would :)
13:18amalloyheh, magic. funny because it's true
13:20raekilyak: you can also use reader from the clojure.java.io namespace to get a suitable object to pass to line-seq
13:29TimMcOK, I just want to map across the vals of a map. Anything better than (fn [[k v]] ...) ?
13:29TimMc(more terse)
13:29ataggart(map f (vals m))
13:30TimMcYeah, but I want the whole map back. :-(
13:30TimMcLike, (map-vals inc {:a 0, :b 1}) -> {:a 1, :b 2}
13:31TimMc$findfn inc {:a 0, :b 1} {:a 1, :b 2}
13:31sexpbot[]
13:31ataggartseems like there should be, but I can't think of one
13:31fliebelTimMc: fmap in generic.functor or whatever.
13:32fliebelTimMc: Not that keys and vals for the same map are guaranteed to have the same order, so you can map over vals and reunite them.
13:32fliebel*note
13:32raek(into {} (for [[k v] m] [(f k) (g v)])) is one option
13:32ataggart(reduce (fn [[k v]] [k (f v)]) m) is about it for core
13:33ataggartthrow a {} in the above
13:33fliebelhttp://clojuredocs.org/clojure_contrib/clojure.contrib.generic.functor/fmap
13:33raek(zipmap (map f (keys m)) (map g (vals m))) is another
13:33ataggartskinning cats is fun
13:35TimMcraek: Yeah, zipmap is probably what I'll go with -- the map already has a name, so it's easy to refer to it twice.
13:48TimMc(apply zipmap (juxt keys (comp (partial map boolean) vals)))
13:51bultersgday all
13:52bultersanyone here familiar with efforts of "interfacing" with git from clojure?
13:53hiredmanhttp://eclipse.org/jgit/
13:54bulters*facepalm*
13:54bulters(stuck in ruby mindset of looking for gems)
13:56amalloywebar7: probably. a lot of the grosser java "wiring-together" has been replaced with clojure-specific wiring for many projects, though, so you might not see as much of that as you'd like
13:57webar7oh hmmm i'm from python/zope/fabric/django beackground as far as any coding goes ... those are all very different of course so even though "in python" ... hmm
13:57webar7amalloy, ok I grok
13:58webar7then I get levels of abstraction via leinegen (sp?) etc etc
13:58amalloyleiningen
13:59webar7amalloy, thanks ... I will fiddle a bit with it and see what I learn
13:59amalloywebar7: check out Ring - it's clojure's super-simple modular web server
14:00webar7ok ... I think it got installed in the project by adding it to the project.clj and running leiningen ... anyway it's fun to do lisp in a web environment but the error messages from the JVM are freaky!!
14:00bultersamalloy: only thing left is the deployment on a server...
14:00bultersamalloy: luckily I'm not there yet ;-)
14:02webar7I think what I want now is to wire things up with routes etc. and then have some pages just be handled statically but with clojure code execed before rendering
14:02webar7so I will look at ring and related tools
14:04webar7by the time I know what i'm doing maybe appengine will support clojure :) ?
14:04webar7oh wait ...
14:04midswebar7: check out 'appengine-magic'
14:04webar7woah
14:05webar7ok then maybe by the time I know what I'm doing google will have bought java from Oracle and relicensed it :)
14:05amalloywebar7: appengine doesn't have to support clojure. it supports java, which is kinda the point :)
14:09webar7amalloy, :)
14:11webar7amalloy, I've been working with BSD based systems mostly (usually very small or for dedicated stuff like email or proxying) so have avoided java ... if only to avoid the hassle of installing it :-\
14:13webar7maybe Oracle trying too/so hard monetize as much as possible and ASAP means they really think java has "jumped the shark" :)
14:14webar7does clojure run on dalvik :)
14:15amalloywebar7: slowly
14:15webar7WOW!
14:15webar7impressed by the fact it runs at all
14:15webar7nice
14:15amalloyit's all "just java" underneath
14:16webar7gotta love LISP ... invented before computers ... in use "after" computers ;-)
14:16amalloyheh. no doubt PCs were viewed as "after" computers back in the mainframe days
14:17webar7so clojure could run on other "open" jvm's or stack/register vm's that can "pretend" to be java
14:18TimMcwebar7: Clojure can be run anywhere JVM bytecode can be run.
14:18webar7hmm that's very broad :)
14:20webar7it seems like one could write something using lisp that simultaneously creates a dedicated "client" to run with a java "GUI" and web based UI (CSS etc)
14:21amalloythat such tasks are possible does not make them easy
14:23bultersif every small task whas easy, then large tasks are easy as well
14:23bulterswhere** (damn)
14:23bulters*DAMNIT*
14:23bultersyou get the point
14:25fmwI'm trying to send a form submission using clj-http, but there seems to be something wrong with the request: http://paste.pocoo.org/show/374016/ (screenshot of a tshark capture of the request/response: http://vix.io/post_request_capture.png)
14:25fmwdoes anyone know what I'm doing wrong?
14:25fmwI've compared my post requests with post requests made by curl/chrome and my request looks OK
14:26amalloyfmw: your boundary has ---- once, and ----- once
14:27fmwamalloy: I copied that from Chrome
14:27fmwafaik its correct?
14:28amalloy*shrug* maybe so. seems a bit loony to copy a bunch of output from chrome instead of just posting edit_week=test or whatever
14:28amalloyi mean, i'm not an expert at form encoding, but chrome looks like it's including a lot of overhead just in case it wants to do multi-part mime-encoded forms, when the minimal data needed to POST something is much simpler
14:29raekfor it to work you should have boundary=<some string> in the content type and then delimit the sections with --<some string> .... --<some string> .... --<some string--
14:30raekfmw: it looks like you are one - short in the two form-data lines
14:30raekoh sorry, you're not
14:31raekI made a mistake when I counted them.... :)
14:31fmwraek: aye, I had that wrong a few times, myself, but at least that part seems fixed now
14:33fmwamalloy: I agree with you there, but for now the Chrome version is known to work, so felt safer to just copy & paste
14:33clizzinis lein-javac still useful, or has leiningen swallowed up that functionality with one of its options? if so, which option?
14:35raekclizzin: it is in leiningen now.
14:36fmwraek: any chance the request is correct but PHP expects some additional headers to be present to process it?
14:36clizzinraek: what option is it equivalent to? just set :java-source-path, and it just works?
14:37raekyou might be able to just put the java source files in src/ too, but you can use :java-source-path like this: https://github.com/raek/map-exception/blob/master/project.clj
14:37NikelandjeloIs there standard function for comparing 2 collections (nested collections too). E.g. compare [[1 2] [3 4]] '((1 2) (3 4)) are equal
14:37clizzinraek: excellent, thank you!
14:37hiredman,(= [[1 2] [3 4]] '((1 2) (3 4)))
14:37clojurebottrue
14:37raekclizzin: I think so
14:38Nikelandjelohiredman: Oh :) Thanks. I am ashamed
14:39amalloyit's okay, you're used to languages that enjoy making things hard. you'll get the hang of clojure's ease-of-use
14:40clizzinhahaha
14:40fmwamalloy, raek: thanks, I've got it working. dropped multipart/form-data and went with appplication/x-www-form-urlencoded instead, using a simple foo=bar string as a body
14:41amalloyhooray
14:47fmwbtw, is it worth it switching from vim to emacs for because of Clojure? I've been drewling at all the nice Emacs goodness for Lisp since I picked up Clojure, but although I used it as my first editor over 10 years ago I hardly remember how emacs works
14:47fmwalso, I quite like Vim and have invested a lot of time into learning it over the last couple of years
14:47amalloyfmw: there are vim users who write clojure. some of them are even smart people, so there must be something to it
14:48technomancyfmw: we make people use Emacs at work. we have hired 3 vim users, and 1 of them still uses vim outside work.
14:48technomancyas a data point.
14:48fmwamalloy: aye, I remember that Paul Graham is using vim too
14:49fmwtechnomancy: you *make* people use emacs? because of some in-house emacs plugins or something?
14:49technomancyfmw: for pair programming.
14:49amalloyfmw: because emacs is the best
14:49fmwtechnomancy: hmm, valid point
14:50rak85hi, guys!
14:50fmwI might just dive into emacs again, soon
14:50fmworg-mode and the email client seem nice benefits too
14:51amalloyfmw: after a couple weeks of pain you'll be as productive as you were with vim, and then it keeps going upwards
14:51rak85i have a list and want to iterate over its items in order to make side effects; actually save in a database...what's the best approach you would consider for this?
14:51amalloydoseq
14:51technomancyin my book the best part is having paredit available for IRC
14:51fmwright now I'm using mutt with vim as an external editor, but the integration could be better
14:51amalloy&(doseq [x (range 5)] (prn x))
14:51sexpbot⟹ 0 1 2 3 4 nil
14:51fmwoh yes, I forgot that emacs is an OS ;)
14:51fmwIRC client too! :)
14:52rak85&(println "teste")
14:52sexpbot⟹ teste nil
14:52fmwamalloy: why do you think I'll be more productive writing Clojure in Emacs?
14:52amalloyfmw: and shell! web browser! chess board! do whatever you want without ever closing emacs :P
14:52amalloyparedit. slime
14:52rak85ammaloy: thanks!
14:52amalloyalso the massive customizability of .emacs
14:53scottjfmw: if you're super good at vim I don't think switching makes sense
14:53fmwand as an editor? it seems nice as an OS, but I'm still quite fond of modal editing etc
14:54fmwscottj: I would say I'm super good at it, but quite experienced at least
14:54fmws/would/wouldn't
14:54sexpbot<fmw> scottj: I wouldn't say I'm super good at it, but quite experienced at least
14:54amalloyfmw: you could try...what is it, viper, for making emacs keybindings more like the vim ones?
14:55amalloyor vimpulse? i think i've heard of both of those things
14:55fmwamalloy: aye, I've read about that plugin
14:55fmwvimpulse yes
14:56amalloybut i dunno. i fumbled along with vim for years, never really attained proficiency, and then tried emacs when i started common lisp
14:56fmwoth, when I'll lose modal editing I guess I can just as well bite the bullet and grow that extra finger so I can press control all the time
14:56amalloyso i'm not really an ideal "switch from vim to emacs" consultant
14:56scottjfmw: emacs is good, but I think an advanced vim user would find things lacking that they'd have to add and might find the keybindings not quite as nice
14:57amalloyfmw: heh, so true. map caps-lock to an extra ctl key if you do; hugely more comfortable
14:57leifw+1 amalloy
14:57scottjfmw: for example, emacs doesn't have two move forward/backward by beginning/end of word.
14:57fmwhmm
14:57technomancyfmw: foot pedal
14:57pjstadigtechnomancy: hooooly crap i want one!
14:57amalloytechnomancy: that sounds hardcore and awesome
14:58dnolentechnomancy: I had one.
14:58fmwheh, might be a good investment :)
14:58amalloyneed one for meta too though
14:58leifwtechnomancy: I always wanted a foot pedal
14:58technomancywell it doesn't work with a standing desk unfortunately =\
14:58pjstadigi play the drums, so a couple of foot pedals would be nice
14:58lancepantzna, the kinesis gives you 6 buttons per thumb, they might as well brand it as an emacs keyboard
14:58amalloytechnomancy: pressure sensitive. lean forward if you want meta
14:59scottjlike dance dance emacs?
14:59amalloyscottj: or that
15:00leifwlancepantz: <3 kinesis
15:00lancepantz:D
15:00lancepantzit's also fantastic for rsi
15:00pjstadiglancepantz: as in causing it or curing it?
15:00lancepantzcuring :)
15:00lancepantzi used to have to wear wrist braces at night
15:00leifwhaha emacs is fantastic for causing it :-P
15:01lancepantznow i don't even think about it
15:01technomancyman... I really do not buy the "use doall+map-indexed instead of doseq+indexed" argument at all.
15:01lancepantzto be fair thats when i was a vim user!
15:01technomancydoall is ugly; sometimes you're i/o bound and don't care about the extra consing. =\
15:02technomancyindexed is way more composable
15:02amalloytechnomancy: dorun+map-indexed?
15:02amalloy$source indexed
15:02sexpbotSource not found.
15:02amalloywhere is this indexed nonsense
15:03leifw$source map-indexed
15:03sexpbotmap-indexed is http://is.gd/VNs4dX
15:03technomancyamalloy: indexed didn't get promoted from c.c.seq because it's a lot slower than map-indexed
15:03technomancybut sometimes you just want a seq without mapping and you're not penny-pinching GC cycles. =\
15:04technomancyhttp://groups.google.com/group/clojure-dev/msg/d8e342f54ea3db3b
15:06amalloytechnomancy: i don't understand what you would use indexed for. just (map-indexed vector my-coll) if that's what you want, no?
15:06technomancyyeah, I was about to say (def indexed (partial map-indexed list))
15:06technomancyI just prefer the more composable version over the faster one.
15:09technomancyplus there are times when for is clearer than map
15:10amalloytechnomancy: indeed there are a lot of such times
15:11fliebelI am with technomancy on this one. I frequently do (map-indexed vector some-list) to use it for something else.
15:12fliebelNow we have map-indexed, reduce-indexed, but not filter-indexed, reductions-indexed, etc. (I'm not saying we should!)
15:12technomancywell, there is keep-indexed
15:13webar7wow ... clojure REPL emacs eshell and SLIME
15:13webar7nice :-P
15:16webar7there must be a few different approaches to writing "Active Clojure Pages" (hehe) i.e. html-ish pages that I can keep in ./resources/public/ or ./resources/clojure_pages and which get eval'ed (?) with stuff added by the client and my app's main handler ...
15:16webar7but what are they called ?
15:16webar7there's been a clojure explojion in my brain ... I feel like someone who has been using perl for 20 years but just discovered CPAN or something
15:17pjstadigand ugh for using dorun+map for side effects seems like doseq+indexed would be a better use
15:17midstake a look at hiccup and enlive
15:18RaynesI don't think there is anything precisely like rhtml in Clojure.
15:18RaynesEnlive is probably the closest.
15:19webar7hmm ok ... I'm thinking functional web programming a very different thing
15:19webar7I will loook at those
15:19redingerEnlive is pretty awesome
15:20ataggartenlive is pretty slick, see this tutorial: https://github.com/swannodette/enlive-tutorial
15:20webar7but I will first observe my own patterns of use for a few more days ... I just noticed I am thinking differently about HTTP :) this is very nice brain tickling
15:20webar7cool thanks
15:20ataggartI'm just hoping someone comes up with a more REST-y lib for ring so I don't have to write one.
15:21fliebelDoes anyone have experience using JNA from Clojure?
15:21webar7ataggart, I love REST
15:22KirinDaveEnlive is like... visionary.
15:22KirinDaveI dunno what prior art exists for it
15:23ataggartfliebel: iirc someone wrote something to work with JNI. Not the same, but might point in the right direction.
15:23KirinDaveBut it's pretty much the only sensible way to develop software that is going to have nontrivial templating.
15:23ataggartKirinDave: after living through two years of an XSL-based website, I agree.
15:24webar7ataggart, and rest too for that matter ... :)
15:24fliebelataggart: JNI still requires C code. JNA works in pure Java using interfaces, so I was thinking… defprotocol.
15:24KirinDaveataggart: Every time I see someone use sexps to generate nontrivial html, I get very very irritated.
15:24KirinDaveIt's like, "Yes. Toys exist. Stop playing with them when we're talking about grownup stuff."
15:25ataggartfliebel: if you get something together, I'd be interested. right now I'm punting on some pgp work by just making shell calls.
15:25webar7crikey! in a parallel universe connected by my own personal wormhole I just discovered fossil can pull and push and do git-ful things so I can use repos of clojure stuff pulled from git or various googlecode sorts of repos in my project which I then control my own parts of with fossil-scm
15:25opqdonut_KirinDave: /me worked on a project that generated everything using cl-who
15:25fliebelKirinDave: The difference between man and boy is the price of their toys. But then, this is all opens ource. Time for a new theory…
15:25webar7is that the "normal" way or does one use a clojure specific tool that updates the project classes one is using?
15:26technomancyKirinDave: the problem is it's so obvious and easy to implement that people are going to do it no matter what. ("wait a minute; these are trees, and these are trees... what happens if we...!!!")
15:26KirinDavetechnomancy: I try hard to be nice.
15:26KirinDavetechnomancy: But I am sort of tired of people who are just getting the basic idea now.
15:27KirinDavePart of that anger is directed at schools whos teaching is easily 20 years out of date now, in many cases.
15:27KirinDavetechnomancy: For example, my cousin is going to college right now. They're using Python to teach him.
15:27KirinDaveGood start, I guess
15:27ataggartNow that MIT has bailed on it, does any school still teach using a lisp?
15:28fliebelWait a moment… Why can't interfaces in Clojure extend another interface?
15:28ataggartfliebel: interfaces can, protocols can't
15:28KirinDavetechnomancy: He writes to me that he's angry he didn't get an A for this: http://pastebin.com/t7NtXnut
15:28fliebel$doc definterface
15:28amalloyataggart: iirc there's no syntax *in clojure* to define an interface that extends another
15:28ataggartamalloy: ah fair enough
15:29amalloyataggart: berkley uses scheme, i think
15:29KirinDavetechnomancy: Now I get he's a 1st year student and that code is common...
15:29fliebelamalloy: Oh, there goes all hope to implement JNA cleanly.
15:29KirinDavetechnomancy: But shiiit. I'd be hesitant to give that code a C outside of an introductory class.
15:30ataggartamalloy: I guess the argument now that we have protocols would be: "don't do that"
15:30fliebelHow would I write this example in Clojure? http://en.wikipedia.org/wiki/Java_Native_Access
15:31KirinDavetechnomancy: When he was asking me to do his work for him I kinda replied in true bastard fashion: https://gist.github.com/10c6c81fbb98536fd8d8
15:31webar7If I do "lein new blahblahproject" ... then describe stuff in project file can I then run lein <something> to pull required jars into ./lib ? python/ruby have tools for this but since I know no java and the lisp is "higher up" not sure if I should use dvcs or some java tool?
15:32webar7ataggart, MIT seems to have no sense of history :) kerberos X lisp why bail?
15:32raekwebar7: "lein deps" will pull the required jars into lib/
15:33technomancyKirinDave: heh. "Problem?"
15:33KirinDavetechnomancy: He was pretty unhappy with me.
15:34webar7raek, thanks
15:35KirinDavetechnomancy: And yet, why couldn't a first year student be using haskell? Is there really anything THAT complex? It's just alien. Same with clojure.
15:35webar7I just discover lein deps 10 seconds later :) but ... can't figure out how it works (I guess I need a bit of java dev env for browsing around jars and seeing how they connect)
15:36technomancyKirinDave: depends on the school. for trade schools it just doesn't address the target market. and most schools are trade schools.
15:36webar7raek, is it pulling .jars and java libs from vcs'es all over the place or is there a java (errm I mean clojure) collection of all the required stuff ?
15:36KirinDavetechnomancy: Another sentiment I don't entirely understand, but that's a different conversation :)
15:36technomancyKirinDave: not condoning it, just making an observation.
15:37KirinDaveTo me, that kind of thinking would have graduated no automotive engineers because the horse and buggy market was target.
15:37webar7raek, it seems like lein dep does a CPAN like scan of dependencies but ... where? :)
15:37fliebelchouser: Oh, thanks for sorting out all the nasty details for me! https://github.com/Chouser/clojure-jna
15:37technomancywebar7: "lein help tutorial" ought to sort you out
15:37raekwebar7: it uses the maven dependency resolution system and some repos (clojars.org, the clojure build server, maven central, iirc)
15:38webar7technomancy, :)
15:38webar7raek, ahah! ok thanks just wanted to look around there without using lein
15:38webar7cheers
15:39digash,(map #(do [% %]) [1 2 3])
15:39clojurebot([1 1] [2 2] [3 3])
15:39digash,(System/exit 1)
15:39clojurebotjava.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.1)
15:40webar7ataggart, I think lisp is taught where ever AI is taught ... once upon a time it seemed compsci specific
15:40webar7ataggart, but now it seems more interesting to non compsci audience
15:42jlfataggart: http://webcast.berkeley.edu/course_details_new.php?seriesid=2011-B-26281&amp;semesterid=2011-B
15:43webar7but I guess people doing stuff like writing "lisp interpreters" in ruby are compsci majors :)
15:46rak85(println "teste")
15:46rak85,(println "teste")
15:46clojurebotteste
15:47rak85-(println "teste")
15:47rak85why & and , ?
15:49TimMcrak85: & and , are just bot-specific triggers
15:49webar7PhilG's 10th rule hmm
15:50webar7what is that
15:50webar7oh ... "Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp."
15:50webar7hehe
15:50webar7thanks for pointers
15:53rak85thanks TimMc
16:01fliebel$mail chouser Thanks for clojure-jna. I think it could use some Maven love though. Is there a reason it doesn't have a pom.xml or project.clj?
16:01sexpbotMessage saved.
16:07lancepantzAny sufficiently complicated irc bot contains an ad hoc, informally-specified, bug-ridden, slow implmentation of half of an operating system?
16:07KirinDaveHa
16:07lancepantzlance's corallary
16:11fliebellancepantz: But large applications already contain an ad hoc, informally-specified, bug-ridden, slow implementation of half Clojure, so you're already halfway there.
16:11lancepantzhehe
16:11lancepantzthe best was the nosql one technomancy tweeted
16:11fliebel?
16:12lancepantzAny sufficiently complicated NoSQL program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of SQL.
16:12fliebelYea, you can pretty much define a nosql db in one line of clojure: (ref {})
16:12lancepantzsource: http://twitter.com/#!/kellan/status/10504462699331584
16:13fliebellancepantz: But that would mean Clojure is a half ad hoc, informally-specified, bug-ridden, slow implementation of SQL.
16:15lancepantzbut is SQL a half ad hoc informally-specified, bug-ridden, slow implementation of Common Lisp?
16:17lancepantzi hope this channel log gets a high pagerank for "ad hoc informally-specified, bug-ridden, slow
16:17lancepantz implementation"
16:17fliebellancepantz: SQL is at least specified.
16:18lancepantzfliebel: very true
16:18fliebelThat would do Clojure no good, not at all being ad hoc informally-specified, bug-ridden and slow.
16:18lancepantzyep :)
16:47devnhmmm, this context.io thing is cool
17:05lancepantzdevn: link?
17:11TimMcI'm pretty sure Clojure is informally specified, though.
17:22devnlancepantz: http://context.io
17:22devnnow i just need to figure out how to use clj-oauth :X
17:24lancepantzthat is pretty sweet
17:25devnlancepantz: wanna help me figure out how the hell to use clj-oauth with it? :)
17:25lancepantznot right now, ninjudd would kill me :P
17:25devnhaha
17:38mecwhen/why can you use ^:static? its a hard thing to search about
17:39brehautmec: i might be waaay off track here, but i thought :static vars as an option was discarded in favour of :dynamic as an option
17:40mecno idea, im not very familiar with 1.3 changes
17:41dnolenmec: ^:static was a temporary idea on the way to the current state of 1.3
17:44mecits still looks pretty common in core.clj
17:44dnolenmec: it's a no-op now. doesn't do anything.
17:45dnolenmec: default is static, no need to specify ^:static anymore.
17:45mecah ok
17:47hiredmannot true
17:47hiredmanthe default is not :Static
17:47dnolenhiredman: ?
17:47hiredman:static
17:47hiredmanthe default is just less dynamic
17:48hiredmanI wish people would stop saying that
17:48dnolenhiredman: ^:static had other connotations yes, doesn't really matter much now anyhow.
17:48hiredmanI specificly asked rickhickey about it durring the q&a at the conj so he would say they are not the same in the hope that people would stop saying they were
17:51mecso what are they?
17:51dnolenhiredman: hmm, oh yeah ^:static was only about fns, dynamic is about vars.
17:51dnolenmec: really it's not worth thinking about too much, main point is ^:static is irrelevant.
17:51hiredman:static did away with indirection through vars completely
17:52dnolenmec: in general ^:static wasn't that cool, had issues w/ protocols and redefinition.
17:56seancorfielddnolen: are you saying that in 1.3.0-alpha6 you don't have to mark a fn ^:static in order for it to be compiled to a java static (and use primitive arguments)?
17:57seancorfieldor are you just saying it's irrelevant for vars?
17:57dnolenseancorfield: ^:static is just irrelevant now. fn's have direct support for primitive arg & return.
17:57hiredmanseancorfield: :static has nothing to do with java static
18:00devnis it just me or is there nothing already built to handle https?
18:02technomancy,(clojure.java.shell/sh "gnutls-cli" [...])
18:02clojurebotjava.lang.Exception: Unable to resolve symbol: ... in this context
18:02technomancybugger.
18:03hiredmandevn: it's you
18:05seancorfielddnolen: lots of clojure.core still has ^:static annotations... is that just leftover from when it mattered?
18:05dnolenseancorfield: yeah.
18:09dnolenseancorfield: some context here, http://clojure-log.n01se.net/date/2010-10-18.html
18:10dnolenseancorfield: context for the old way (^:static) here, http://clojure-log.n01se.net/date/2010-06-07.html
18:12devnhiredman: any pointers?
18:13seancorfieldthanx for the links dnolen - it's hard to keep up, sometimes!
18:17dnolendevn: seems to me like the good Clojure http clients have some sort of https support. clj-http, clj-apache-http
18:18pyr0/clear
18:22Raynesdevn: 'Course not! That'd be productive. Can't have that. ;)
18:23TimMcI've been experiencing a number of frustrating debugging sessions where I end up chasing down bad values that propagate through my function calls before triggering some irrelevant error message.
18:24TimMcWhat's the best way to add some early bogon detection to my code?
18:24technomancypreconditions?
18:24TimMc(I've had misnamed :keywords in maps, the wrong data structure being passed in, etc.)
18:26dnolenTimMc: I agree w/ technomancy, pre/postconditions are useful.
18:26TimMcPreconditions... those would be ugly if I'm checking the validity of maps.
18:26TimMcAre defrecords recommended for ensuring that all the right slots are filled in a data structure?
18:27dnolenTimMc: preconditions can be any old function. I usually define validators somewhere.
18:28aleloshey guys, whats my best bet for creating matrices and maybe doing some matrix operations? incanter?
18:28dnolenTimMc: defrecord generally need a ctor fn, that ctor will need to do some kind of validation.
18:28TimMcdnolen: And then check that each argument is the appropriate record type? (I guess type hints will help with that.)
18:29dnolenTimMc: type hints don't guarantee anything.
18:29dnolenTimMc: https://gist.github.com/926381 is something I've done before in my own code.
18:29TimMcI know. But they'll sure as hell throw the right kind of fuss when the cast goes wrong.
18:30technomancynot really
18:31TimMctechnomancy: Expand?
18:31technomancypretty sure if the type hint is wrong it will just fall back to reflection.
18:32TimMcI recall it throwing.
18:32brehautTimMc: i think you are being tricked by the interop
18:32brehaut,((fn [^String foo] foo) [1 2 3])
18:32clojurebot[1 2 3]
18:33brehaut,((fn [^String foo] (.replace foo "a" "b")) [1 2 3])
18:33clojurebotjava.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.String
18:33dnolenTimMc: type-hints are only about controlling reflection, not much else.
18:33brehautthe exception comes from .replace, not the type hint
18:33TimMcSure, but I would be calling .methods on these things anyway.
18:34TimMcAnywho, preconditions would work.
18:34TimMcThanks for the tips.
18:36hiredmanhttps://gist.github.com/26d6a42bde8944290501
18:42TimMc(It doesn't help that I keep getting my damn unit tests wrong.)
18:48TimMchiredman: Was that for me?
18:48dnolenhiredman: very interesting, tho quite a bit slower than just using destructuring + :pre at least for the kinds of examples you've shown.
18:50hiredmandnolen: I don't recall making any claims of performance
21:01mecAre there any other generators of chunked seqs besides range?
21:02brehautmec: vector
21:10mecwas there some way to temporarily disable chunks or am I remembering wrong?
21:11amalloymec: iirc the best way is currently to create a new manual lazy-seq around them
21:11amalloythere's an example of that in JoC
21:11mecYa I saw that, I just swear i remember something like *chunked-seqs* that could temporarily turn them off
21:50tufflaxWelcome to Critique my fn! http://pastebin.com/agxEYdVm :P It doesn't feel quite right to have ps grow like that, hm...
21:54mectufflax: if you just want primes one already exists, otherwise without looking in depth yet you should put lazy-seq elsewhere: https://gist.github.com/926654
21:56mecOtherwise it will find the next prime before you actually want it
21:57amalloymec: worse than that. i don't think it returns anything lazily: the cons is inside the lazy-seq
21:58amalloywell, i guess that's not true. feh
21:58mecya i think it'll just run until it hits the lazy-seq, doing the computation before hand
21:58amalloyi was thinking the recursive base case never gets hit, but lazy-seq does intervene
21:59amalloyit's just harder to visualize for me, when the cons is inside the lazy-seq
21:59tufflaxhmm, so you're saying it generates one more element than it needs to?
22:00mecno it just does the computation for the next element, so: 2 calc 3, 3 calc 4, 4 calc 5. instead of full lazy: 2, calc3 3, calc4 4, calc5 5
22:00tufflaxamalloy isn't the cons supposed to be inside? i don't understand
22:01amalloytufflax: if you're rolling your own, the general pattern is like (cons foo (lazy-seq ...))
22:01amalloythis gets you the element you've computed immediately, and attaches the remainder of the computation lazily
22:02amalloybut i think i'm oversimplifying in ways that make what i say unuseful
22:03tufflaxhm, well mec's is also inside https://gist.github.com/926654
22:03amalloytufflax: kinda-sorta. this is the simplification i referred to. it's *very deep* inside, so that it's very much like the cons is wrapping the lazy-seq generated by the *next* invocation of primes
22:04mecif you unroll mine the call to (primes [2] 3), the first statement is lazy-seq so you get: (cons 2 (lazy-seq ...))
22:05mectufflax: https://gist.github.com/926654
22:08tufflaxoh yeah... but mine just does one calc ahead ro
22:08tufflaxright
22:10mecactually you can simplify away the if-let + when, check the gist again
22:11tufflaxgot disced after your <mec> tufflax: https://gist.github.com/926654
22:12mecI just said you can simplify away the if-let + when
22:14tufflaxso as I was saying: mine just does one calc "too much" right?
22:14mecya if you (take 10 primes) it will calculate for 11
22:15mecalso, since you have to hold onto the head anyway, you can completely get rid of ps
22:16mectufflax: refresh the gist for that change
22:27tufflaxinteresting... :)
22:32tufflaxthanks mec, amalloy_ i knew i would learn something by asking for critique :)
22:33mectufflax: np, i love tweaking code ;p
22:35tufflaxclojure is so much more fun than java, i never wanna touch java again :p
23:01TimMc,(type (#()))
23:01clojurebotclojure.lang.PersistentList$EmptyList
23:01TimMcThat's amusing.
23:02mecthats weird
23:03TimMc(#()) -> ()
23:03mec,'#()
23:03clojurebot(fn* [] ())