#clojure logs

2010-11-06

00:02tomojhmm
00:13tomojdo I remember rightly that there was some maven plugin for generating mac style apps?
00:17tomojoh, it was the reference to building windows executables that I remembered from cemerick's post
01:09cemericktomoj: There are maven plugins for packaging mac apps as well as building windows installers
01:09cemerickThere may well be one for generating windows .exe's for java apps, I've just never used them.
01:11tomojcool
01:13cemericktomoj: http://www.google.com/search?q=maven+jsmooth+plugin *shrug*
01:13cemericknever used it, but seems promising
01:14ppppaulcoding guis makes me cry
01:41samxok.. finally after hours of pain, netbeans/enclojure debugging seems to be working :-)
01:53amalloysamx: what was the key?
01:56samxi was importing an existing project of mine, containing java an clojure.. and used the "java/java project with existing sources" project type, which uses netbeans project preferences generated ant build files.. I think something in how they were getting set up didn't work well with debugging.. so, after starting over again, and setting the project up as "java/java free-form project" (which just uses my hand coded ant build file), it just started
01:56samxworking
01:56Deranderis there a way to get clojure-mode to color known functions differently?
01:57Deranderlike classes vs local vars vs functions
01:57Deranderfuck. maybe that's a terrible idea
01:57samxone think i noticed was that the netbeans generated build was copying all the clojure files to the build directory, and for running, it had a path both for the build and the src directories, essentially having two paths containing the clojure files.. that might have been the problem, but not sure
01:57cemericksamx: I always found NetBeans' project management stuff somewhat broken, especially their crazy generated ant buildfiles.
01:58cemerickfoolishly generating foolish code is foolish, etc.
02:10amalloyDerander: so many things are callable as functions that that becomes pretty hard
02:10Deranderamalloy: yeah, that struck me
02:10DeranderI realized, "wait... almost everything is a function..."
02:11amalloyeg: (fn [x y] (x y))...gonna be a tricky one :)
02:11Deranderhighlighting the "word" in each form might be useful
02:11Deranderor boldingi t
02:11amalloyyou mean the function being called?
02:11Deranderyes
02:12amalloyyou don't need emacs to tell you where all the (s are...:P
02:13Deranderamalloy: that is true
02:13DeranderI'm going to see what it looks like nonetheless
02:13amalloyhaha k
02:13Derander:P
02:14amalloywhat *might* be useful is to locate anything called as a function, and highlight it throughout the current scope
02:14ppppaulcolor every word differently
02:14ppppaulrainbow code
02:14Deranderamalloy: I'm not sure what that would accomplish
02:14Deranderamalloy: could you explain more?
02:14ppppaulanyone know of a tutorial/cheatsheet for programming lisp in emacs?
02:15amalloyDerander: suppose you're defining reduce
02:15Derandersure
02:16amalloy(defn reduce [combiner list] (loop [[x & xs] list] (whatever...(combiner x))))
02:16amalloybeing able to have *combiner* highlighted in the function param list might be useful
02:16Deranderah, yes
02:16Deranderthat would be really handy
02:17amalloymaybe. i agree it *sounds* handy, but it seems to me like if it were handy emacs would already have it
02:17amalloybut if you want to get into some elisp it sounds like an interesting project
02:17DeranderI don't believe that :-)
02:18amalloyhave ye no faith, brother, in the prophets of lisp who came before us?
02:18Derandernone
02:19amalloygood. we need people to innovate even if the ideas turn out to be rubbish
02:19Deranderit feels like it'd be a slow operation
02:19Deranderto do that kind of highlighting
02:19cemerickHrm. The prophets of lisp left us elisp and CL…
02:19amalloyDerander: emacs does some pretty intense stuff already
02:20DeranderI am going to try to get it to show function args as font-lock-variable-name-face
02:20amalloyand technomancy has some kind of backtracking syntax highlighter that is (i think) in super-ultra-pre-alpha
02:20amalloyin swank-clojure.el
02:21amalloyor i guess it's a backtracking indent. whatever
02:21Deranderamalloy: so it indents previous lines of code?
02:21amalloyno, i think it goes back to previous lines of code to decide how to indent this one
02:21amalloybut it might have useful ideas for you
02:22amalloytbh elisp hurts my eyes; i gave up on my tiny improvement after an hour
02:22hiredmanbacktracking indent is great, and not alpha, everyone should turn it on
02:22Deranderhiredman: how?
02:22amalloyhiredman: really? what's it do?
02:22hiredmanhow?
02:22clojurebotwith style and grace
02:23hiredmanamalloy: it properly indents protocols and reify etc
02:23hiredmanand letfns
02:24Deranderhiredman: I don't see anything about it in the github page
02:24hiredman(setq clojure-mode-use-backtracking-indent t)
02:30kzarIs there a way to take a range with a varying step amount? Say the range of 1000 to 10,000 with the step increasing by 2 every 250
02:40amalloykzar: your super-range sounds like a combination of iterate and take-while
02:43amalloykzar: &|(take-while #(< % 10000) (map first (iterate (fn [[n step]] [(+ n (inc (quot step 20))) (inc step)]) [1000 1])))|&
02:43sexpbot⟹ (1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1021 1023 1025 1027 1029 1031 1033 1035 1037 1039 1041 1043 1045 1047 1049 1051 1053 1055 1057 1059 1062 1065 1068 1071 1074 1077 1080 1083 1086 1089 1092 1095 1098 1101 1104 1107 1110 1113 1116 1119... http://gist.github.com/665247
02:44amalloy(slight modification if you want it changing steps every time N passes a multiple of 20 instead of every 20 elements)
02:49kzaramalloy: How come there are two square brackets around [[n step]]?
02:50amalloykzar: destructuring: &|(let [[x y] (range)] y)|&
02:50sexpbot⟹ 1
02:50kzaroo gotya
02:50amalloyi'm iterating over a [data, step] pair
02:51kzaryea that's really clever, thanks for showing me that
02:51kzarI'm kinda bamboozled but I'm going to play with it for a while and understand it properly heh
02:51amalloyit's useful surprisingly often. have you seen the rosettacode fibonacci?
02:51kzaramalloy: No I don't think I ahve
02:52amalloyi added a walkthrough that i think helps understand this stuff
02:52amalloykzar: http://rosettacode.org/wiki/Fibonacci_sequence#Clojure
02:52kzarwicked thanks
02:53ppppauli support super-range
02:56kzaramalloy: Yea I understand it now
02:56amalloycool. now you can create your own hideous monsters just like it :)
02:57kzaramalloy: heh yea, trust me I can do worse
03:08kzaramalloy: Heh I'm using it to make a lazer sound, it's coming out more like a broken fan but it's progress heh
03:09amalloyoh that's right, you're doing all the synth stuff
03:09amalloyis it on github yet?
03:09kzaramalloy: heh no it's a big mess, I couldn't sleep and I've just been fecking around
03:12kzarwo that sounded like a teleporter
03:16amalloyoh, i see. you want a sound that's gradually changing frequency. cute
03:19ppppaul&(take 5(map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))
03:19sexpbot⟹ (0 1 1 2 3)
03:19ppppaul&(take 50(map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))
03:19sexpbot⟹ (0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393 196418 317811 514229 832040 1346269 2178309 3524578 5702887 9227465 14930352 24157817 39088169 63245986 102334155 165580141 267914296 433494437 701408733 1134903170 1836311903 2971215073 480752... http://gist.github.com/665256
03:21amalloyppppaul: believe it's fibonacci now? :P
03:21ppppauli'm memorizing it
03:21ppppaultoo much competition for pi
03:22ppppaulthat fib function has no recursion at all, right?
03:22ppppaulit looks really sexy
03:22amalloyppppaul: it's all recursion, just like everything in clojure
03:22ppppauloh
03:22amalloybut it's lazy recursion
03:22amalloyso it doesn't re-compute previous numbers and it doesn't blow the stack
03:22Deranderow my brain
03:22Deranderfucking emacs regexp syntax
03:22ppppaullol
03:23ppppaulit's weird eh
03:23amalloyDerander: if you get it figured out let me know
03:23ppppaul////////////
03:23ppppauli know a little
03:23Deranderfor some reason adding a capture group breaks the regexp
03:23amalloycause i love regexes and i can't get emacs to match anything to save my life
03:23ppppaulthe regex-builder is so helpful
03:23Deranderppppaul: I'm convinced that it lies
03:23ppppaullol
03:23ppppaulmaybe it has bugs
03:23Derander"(defn .* \[\([A-Za-z0-9 ]+\)\]" <-- this should match (defn the-function [arg1 arg2], right?
03:23ppppaulmaybe there is a way to use perl regex syntax with emacs?
03:24Deranderand capture arg1 and arg2
03:24Deranderif I take out the \( and \) it works
03:24Deranderbut doesn't capture
03:24ppppauluse more '\'s
03:24amalloyDerander: i think he's actually right :(
03:24ppppaul\\[\\(
03:24Deranderwow.
03:25Deranderthat worked.
03:25Deranderwtf?
03:25ppppaulsecy
03:25Deranderis there some reason for that?
03:25amalloyDerander: of course
03:25ppppaulcus it's in lisp
03:25ppppauli dono
03:25amalloylol no
03:25ppppaulemacs likes it's slashes
03:25amalloy"\(" tells emacs to escape the (
03:25Deranderright
03:25amalloy"\\(" escapes the \, and passes \( to the regex engine
03:26Deranderoh god
03:26ppppaulowe my head
03:26Derandersometimes "syntax" is a good idea
03:26amalloyDerander: you've never written regexps in java or bash?
03:26amalloythis shit happens all the time
03:26Deranderamalloy: perl & ruby only :P
03:26amalloylucky man
03:26Deranderslash delimeters ftw
03:26amalloylanguages that don't have regexps as first-class literals make it really painful to escape anything
03:27amalloyfortunately clojure's #"regex" syntax passes every character on as a literal to the regex engine
03:28Derander"(defn .* \\[\\([A-Za-z0-9]+ ?\\)+\\]" <-- this captures only the /last/ arg.
03:28amalloyDerander: .* is greedy
03:29Deranderoh
03:29Deranderright
03:29Deranderfuck
03:29ppppauli love regex
03:29amalloydoes emacs support .*?
03:29Derander? should make it not greedy, right?
03:29amalloyif emacs supports that, yes :P
03:29Deranderdoesn't seem to work
03:29Deranderhttp://www.gnu.org/software/emacs/manual/html_node/elisp/Regexp-Special.html#Regexp-Special <-- this says it should
03:29amalloya ) is never legal in defn params, right?
03:30Deranderdon't think so
03:30amalloyoh but damn, there isn't one after tha params either
03:30amalloyso you can't match on that
03:30Derander"(defn .*? \\[\\([A-Za-z0-9]+ ?\\)+\\]" <-- currently still capturing only last arg
03:31amalloyhmmmm
03:31amalloy.* shouldn't actually matter now that i think about it
03:31DeranderI think I'm feeling a solution
03:31Deranderif it wasn't 12:33AM this would be easier
03:32amalloywhat's the decl you're parsing?
03:32Derander(defn the-function [arg1 arg2 arg3 arg 4 arg5] foo bar
03:32Derandermatches to ], captures arg5
03:33ppppaulshould ask people on #emacs
03:33amalloyman, that doesn't make sense
03:33ppppaul#regex
03:34ppppauloh, your regex wont match all legal arg strings
03:34ppppaulmy+arg wont match
03:34amalloyoh durr
03:34DeranderI will tomorrow
03:34Deranderamalloy: brilliant breakthrough?
03:34amalloyDerander: you need a paren group that ends after the +, not before it
03:35amalloywhich would capture all the args
03:35amalloyyou can't capture them individually b/c each capturing group only tracks the last thing it matches
03:35ppppaulooooooh
03:35ppppaulso me a solution
03:35amalloyso match them all and pull it apart with another re-seq, or (.split string regex)
03:35ppppauli had a similar problem
03:35Deranderoh, that's trivial then
03:36amalloyindeed
03:36ppppaulinteresting
03:36amalloyoh haha i forgot this isn't clojure. "another re-seq or .split". it would be easy in anything but elisp
03:36Derander"(defn .*? \\[\\([A-Za-z0-9 ]+\\)+\\]"
03:36Deranderyeah, see I'm trying to figure out a way to wrangle this into font-lock
03:37Deranderso I'm not sure I'm allowed to do more than one regexp
03:37Deranderfont-lock's documentation is opaque as fuck
03:37amalloyhm. i haven't looked into font-lock
03:37amalloybut if you don't want to color them all differently, then just matching the whole thing should be fine
03:37DeranderI'm trying to pull out the individual words to color them in the function body itself
03:38amalloyah
03:38ppppaulcool
03:38amalloyalso, don't forget there are more valid symbol characters
03:38Derander(defn myfunc [arg] (println arg)) should color both instances of arg
03:38Deranderyes, that's easy to add later though
03:38amalloyyeah. just making sure
03:38Deranderjust trying to get *something* working
03:38Deranderbut yeah.. I'll ask tomorrow in #emacs
03:39Deranderprobably not many font lock experts on in the middle of the knight
03:39Derandernight
03:39Deranderhah
03:39amalloyi like to stay on the edges of the knight. the middle is too squishy
03:39Derander:-)
03:39DeranderI tried writing my own fontifier thingy
03:39Deranderand I had reasonable success
03:40Deranderthe problem is that font-lock overwrites *every* font property you set on every change in the buffer
03:40Deranderif font-lock just had a fucking hook life would be good
03:40Deranderthis is a lot easier to solve w/ regular elisp logic
03:40amalloyDerander: sorry, my ears must be going bad. did you say "elisp logic"?
03:40amalloy*cue laughtrack*
03:40Derander:-)
03:41Deranderif I manage to get this working, I'll write a version of it for let bindings too
03:41Deranderjust for fun
03:42amalloyDerander: you'll have a hard time with any destructuring in either case
03:42Deranderah, true
03:42Deranderwell, nothing is perfect
03:42amalloy(defn do-stuff [[f & fs]] ...)
03:43Deranderif the failure mode is "no color" then it's not that bad
03:43amalloyheh
03:43Deranderso long as it doesn't go rampant and fuck everything up I don't mind a few flaws
03:43amalloyDerander: you should include both modes just in case
03:44Deranderjust in case somebody wants their colors ruined?
03:44amalloyyeah. you never know
03:45ppppaulsometimes i know
03:45amalloyppppaul: i wasn't talking about you
03:46ppppaul^_~
03:46DeranderI am going to go to bed now
03:46Deranderso that I can wake up in time to get a sandwich
03:47Derandergood night gentle(wo)men
03:48ppppaul&(map first (iterate (fn [[a b]] [b (+ a b)]) [0 1])))
03:48sexpbotjava.lang.OutOfMemoryError: Java heap space
03:49ppppaul&(doc doc)
03:49sexpbot⟹ "Macro ([name]); Prints documentation for a var or special form given its name"
03:52Raynesamalloy: You're still awake?
03:52amalloyRaynes: dude it's not 3am here
03:52RaynesThat's beside the point.
03:52RaynesI still find it odd that I can go to sleep before you and wake up before you. I wonder how much you actually do sleep.
03:52amalloyi'm a night owl by preference; i mostly go to bed before midnight because i work in the morning
03:53amalloyyou mean wake up after me?
03:53RaynesYeah.
03:53amalloyanswer: not enough. insomnia has been a problem for me
03:54amalloyRaynes: i'm thinking of starting a sub-branch off of tidy just for all the times you use (apply str (interpose foo bar)) instead of (join foo bar) :)
03:55RaynesPlease don't. :\
03:55amalloyyeah, that would be kinda disgusting
03:56RaynesI'm aware of join, I just don't use it because it feels redundant to bring it in every time I need that behavior. I can understand in places where I could use it several times, but once or twice is okay.
03:57RaynesThere are likely plenty of legitimate places where I didn't use it because I didn't think I'd need it more than once, but ended up needing it many times.
03:57amalloyreally? i think join is just so well-known that it's more expressive. and so far every instance i've seen, you defined your own join function and then called that N times
03:58RaynesWhere?
03:58clojurebotwhere is log
03:58ppppaulwhere?
03:58clojurebotwhere is log
03:58amalloyeg sed.clj
03:58ppppaullog
03:59amalloyand github.clj
03:59ppppaulzzz
03:59Raynesamalloy: I didn't write sed, and I don't think what I wrote in github.clj was exactly join.
04:01amalloy(identical filter-false-str #(join "" %))
04:01amalloyjoin drops the nils for you
04:02RaynesFair enough. One instance? Forgive my tired soul.
04:02amalloyhahaha
04:02RaynesI've done wrong, and I shall pay in the next life.
04:02RaynesI'm going to go whip myself with a cat of nine tails now.
04:02Raynes;)
04:02amalloylet me be. sometimes i need to fix things
04:03RaynesI'm fixing source.
04:03RaynesAs we speak.
04:03amalloyneato
04:03amalloywho did write sed? git log is hard
04:03RaynesErik.
04:04amalloythat explains why there's a regex in it. i was gonna poke fun at you for having any
04:04RaynesRight. I avoid regexy things like the plague. For now, anyway. I have people to write them for me. :>
04:04amalloy*chuckle*
04:04amalloyi'm at the "admitting i have a problem" phase
04:05amalloynot yet at the "trying to stop doing them" phase
04:08amalloyoh neat. working through sed is exposing me to functionality i didn't know he had
04:09amalloy-Raynes s/neat/awesome/
04:09amalloydamn
04:09amalloywell, it's in there somewhere
04:10Raynes$sed -amalloy s/well/clojure/
04:10sexpbot<amalloy> clojure, it's in there somewhere
04:10amalloyah
04:10RaynesThere is some weird option stuff going on there.
04:10RaynesI never asked, he never told.
04:11amalloygod this is going to me so much more legible when i'm done
04:11amalloywith luck it will even still work
04:11RaynesWhat are you doing?
04:12RaynesMutilating sed? :p
04:12amalloyyeh
04:12RaynesCute.
04:12RaynesTake pity on him though. That was some of his first Clojure code.
04:12amalloysure
04:13amalloyi don't judge
04:13amalloyi just enjoy the fixin'
04:13RaynesI wish I enjoyed tidying stuff up as much as you.
04:24Raynesamalloy
04:24Raynes$source clojure.contrib.json/pprint-json
04:24sexpbotclojure.contrib.json/pprint-json is http://is.gd/gLXiF
04:25amalloyRaynes: weren't you going to make it say "Raynes: blah is..."
04:25RaynesYes, but this looks better imo.
04:25amalloywell done getting the :line meta for json though
04:25Raynes&(meta #'clojure.contrib.json/pprint-json)
04:25sexpbot⟹ {:ns #<Namespace clojure.contrib.json>, :name pprint-json, :file "clojure/contrib/json.clj", :line 338, :arglists ([x]), :doc "Pretty-prints JSON representation of x to *out*"}
04:26RaynesYeah, I was trying to get it off of the actual function earlier. Don't know what I was thinking.
04:26amalloyoh hah
04:26amalloyi didn't catch it either
04:29amalloydamn it. i'm trying to make the trailing / optional, but because regexes are confusing it's not working
04:34amalloyah. the same regex was in three different places and i missed one of them :P
04:53Raynes&(= (sort "eleven plus two") (sort "twelve plus one"))
04:53sexpbot⟹ true
04:54amalloyhaha
04:54amalloywho knew sorting was the same as math
05:03Raynesamalloy: I've run out of things to do.
05:03amalloyRaynes: got it working, gonna push it to tidy and head to bed
05:03RaynesCool stuff. I'm going to eat my burrito and head to bed.
05:03RaynesNight buddy. <3
05:04amalloyRaynes: honestly not sure which of us is sabotaging our chances of sleeping more
05:04RaynesMe.
09:38bartjIs there a better way to do this: http://pastie.org/1277059
09:40bartjessentially, trying to select keys from a multiple maps; the values of each key is the combination of all the individual values of the maps
09:41mrBliss&(into {} (filter (comp #{:a :b} first) (merge-with list {:a 1 :b 2 :c 3} {:a 2 :b 3 :c 4})))
09:42mrBliss,(into {} (filter (comp #{:a :b} first) (merge-with list {:a 1 :b 2 :c 3} {:a 2 :b 3 :c 4})))
09:42clojurebot{:a (1 2), :b (2 3)}
09:42hoeck,(select-keys (merge-with list {:a 1 :b 2 :c 3} {:a 2 :b 3 :c 4}) [:a :b])
09:42clojurebot{:b (2 3), :a (1 2)}
09:42sexpbot⟹ {:b (2 3), :a (1 2)}
09:44bartjhoeck, that is beautiful!
09:44bartjmrBliss, thanks!
09:44hoeckbartj: it's just clojure! :)
09:45bartjhoeck, I mean my version is ugly :)
09:46hoeckbartj: but the merge-with differs from your solution when a key is only present in one map
09:47hoeck,(merge-with list {:a 1 :b 2} {:b 3})
09:47clojurebot{:a 1, :b (2 3)}
09:47bartjhoeck, hmm...
09:47hoeckwheras yours returns {:a (1 nil) :b (2 3)} in this case
09:52bartjI thought it would always coerce the value to a list...
09:54hoeckbartj: no, merge with only uses the given function if a key appears in more than one hashmap
09:56hoeckbartj: http://pastie.org/1277092 <- using reduce, longer than yours and not as clean as the merge-with solution
10:00bartjhoeck, hmmm
10:00bartjhoeck, that doesn't look good for multiple maps?
10:04bartjis there a clojure function which does "a thing" on all the values of the map and returns a map?
10:05bartjmy current procedure is to use (zipmap (keys m) (map #(do-something) (vals m))) ;where m is a map
10:07Chousukethere's fmap in contrib
10:07Chousukeyou can also do (into {} (map (fn [[k v]] [k (f v)]) somemap))
10:08AWizzArdalternatively: reduce
10:09AWizzArd,(reduce (fn [m [k v]] (assoc m (+ k 5) (+ v 100))) {} {1 2, 3 4, 5 6})
10:09clojurebot{10 106, 8 104, 6 102}
10:09hoeckbartj: https://gist.github.com/665449
10:14fliebelmorning
10:16AWizzArdMoin flieb
10:20mfexhi fliebel
10:21SenseScalpshi all
10:21fliebelHi SenseScalps, found any goos starting space for Clojure the other day?
10:21mfexfliebel: I ran you minecraft project and for some reason it prints some of the bytes to the screen while reading the files. does this happen for you as well?
10:22fliebelmfex: Yea, I'm afraid this is a showcase of the quality of coding delivered by the avarage Minecraft player. It's comming the the NBT lib.
10:23mfexfliebel: glad to see I'm not going crazy :)
10:23fliebelmfex: Same with the Python thing, I had to jump through a hoop to be able to close the files I opened.
10:23mfexfliebel: but I guess it does hinder performance quite a bit
10:24fliebelmfex: It might, but only the file reading part.
10:25mfexfliebel: my approach centers around getting the freqs per layer per file and hoping to pmap that
10:26fliebelmfex: per layer works well if you do it the array way, but per file for me only generated overheat ov having to consolidate the results of all the files.
10:27fliebeluhm, consolidate is not the right word.. I mean...
10:27fliebelunify?
10:28fliebelmfex: My version runs in 20-30s now.
10:29mfexfliebel: the slowest I got was 49s
10:30fliebelmfex: And the fastest?
10:30mfexfliebel: err that was the fastest :)
10:32fliebelmfex: Well, you came all the way from 160 to 50, so that's not bad. But I think it's time to stop this optimizing. We're still talking about tens of seconds, wile Python is doing it in under 5.
10:34mfexfliebel: I haven't tried any approach yet that completely follows the python approach, mine still have a byte array per file
10:34fliebelmfex: The 20s I got was with some smart-ass stuff to work with arrays all the time. Came form the mailing list: http://groups.google.com/group/clojure/browse_thread/thread/3c759739c265d14d/51b7d6233c7b1b10#51b7d6233c7b1b10
10:35bartjChousuke, AWizzArd, hoeck thank you for your responses; had to go out a bit
10:35fliebelmfex: The Python solution is simply no good on the JVM, I ran it in Jython, and it is a massive suck on there.
10:37fliebelmfex: Or at least not on high-level languages implemented on the JVM, I guess they have to much abstraction to efficiently iterate and store such a huge list of items.
10:42fliebelmfex: gtg, speek you later :)
11:02tomojuhh.. why are single-segment namespaces bad, again? I should remember this. :(
11:02tomojaleph-core->lamina gave us (ns lamina)
11:15mabestomoj: I think they are bad for java interop reasons...
11:15tomojah
11:16mabestomoj: *I think*. I can't remember the details either.
11:17tomojclojurebot: single segment namespaces?
11:17clojurebotsingle-segment namespaces is unsupported. (foo instead of foo.core) they may work in a few circumstances, but you shouldn't rely on them.
11:17tomoj"Do avoid single-segment namespaces though, which would result in classfiles being generated in the default package." http://stackoverflow.com/questions/2223190/
11:20Bootvisdid something happen to clojure.contrib.repl-utils?
11:21MayDanielBootvis: clojure.repl
11:21Bootvisthanks
11:35tomojgrr
11:40qedMorning(ish)
11:44DeusExPikachuhow does one get the git version of clojure 1.3?
11:45DeusExPikachuthe master branch of github.com/clojure seems to be for 1.2
11:48DeusExPikachunm, was using richhickey github, not he right one
14:14Raynesamalloy: Are you awake?
14:18VinzentIs there an emacs function to change ns in the repl to the ns of the current buffer?
14:19Vinzentor I should write own one
14:20hoeckVinzent: C-p M-p RET
14:20hoeckC-p M-p defaults to the namespace of the current *.clj buffer
14:23VinzentGreat, thank you! And probably you mean C-c M-p
14:25hoeckVinzent: sorry, right
14:43LauJensenMan C-c M-p is great, how long have you guys known about this?! :)
14:44RaynesSince you were just a gleam in your father's eye. Get off my lawn.
14:48VinzentLauJensen, :) By the way I want to thank you for your blog - I've found a lot of interesting things there!
14:48LauJensenVinzent: You're welcome :)
14:49RaynesGreg Burd, a project manager at Oracle, happens to own the tryclojure.com domain, and is willing to transfer it to me.
14:49RaynesI should be happy, but all I can think is "why couldn't he have tryclojure.org? :("
14:50LauJensen?
14:50Raynestryclojure.org would be more consistent. There are no trylanguage.com sites. Only .org sites.
14:51RaynesI'm a sucker for details.
14:51RaynesNot that try-clojure.org is any more consistent with the other sites.
14:51Raynestryclojure.org was probably available at the time, but Licenser probably didn't think to check because he's German. ;)
14:53LauJensenRaynes: German er legendary for their thoroughness and attention to detail, look at how they build cars!
14:53LauJensens/German/Germans/
14:53sexpbot<LauJensen> Raynes: Germans er legendary for their thoroughness and attention to detail, look at how they build cars!
14:53RaynesBut he is a special German.
14:54LauJensenOh.. He's 'Open' then :)
14:54LauJensenOpel
14:55LauJensenThat might mean nothing to you. The well known German cars are Mercedes (High Quality, Luxury), BMW (High Quality), Audi (Pretty, low quality) and VW (Mid-High Quality, boring) and Opel (Ordinary, okay quality)
14:57RaynesMeh.
14:57RaynesI drive a '96 F150 XL pickup. :|
14:58LauJensenFord?
14:58RaynesLauJensen: Yes.
14:59LauJensenk.. Ford is big here too. Im not too fond of them
15:00RaynesI wish I had a 4 door pickup.
15:01RaynesLooks like F-Series sales have been slowly decreasing since '04.
15:04RaynesTough truck though. I backed it into a pole (didn't see it because the pole was shorter than the truck) leaving Walgreens last week. Didn't scratch it.
15:05RaynesThe pole didn't suffer much damage either. I wasn't moving very fast, just backing out of a tight parking space.
15:05LauJensenNice. How durable is it? Are you getting repairs on it every now and then?
15:05LauJensenRaynes: Cars not hurt, poles not hurt. Any change you just backed over a little old lady or something? Go check under the car
15:06RaynesIt's got 194k miles on it. Haven't had it for long. Only thing that's been done to it since we got it a few months ago is a new starter and door handle that locked up and broke off.
15:06RaynesBut, for something with 194k miles on it...
15:07RaynesIt doesn't even look too bad. It had some shoddy body work after somebody wrecked it ages ago, but it isn't terrible.
15:07RaynesAlso, little old ladies aren't stout enough to make a truck stop on a dime. :p
15:07LauJensenOk, I should ask you again in a year though, it takes a long time (for me at least) to get comfy with a brand. I've had Peogeot (avoid French cars like the flu), Mercedes and now I'm looking for a BMW, hopefully I can find something nice next week
15:08amalloyRaynes: awake now. que pasa?
15:08Raynesamalloy: Ohai.
15:09RaynesIt's the first stick I've ever driven. Manual transmissions give a little excitement to driving.
15:09LauJensen?
15:09amalloyRaynes: they're fun. i learned to drive stick after i bought my car :P
15:09RaynesThere is always that slight tension that, if you screw up, you could roll backwards into the semi at the stop light.
15:10LauJensenRaynes: I get so annoyed with manual shifting - Why should I have to instruct the car on when to shift gears? .. Guess I'll have to get used to it though
15:10RaynesBeing new to it, I really like it. Ask me again in a year and I'll probably be sick of it.
15:11LauJensenAsk me again in a year and I might like it. My uncle is a BMW fanatic, he wouldn't want it any other way
15:12LauJensenWe should really get this into our calendars, so much to pick up on a year from now
15:12amalloybtw LauJensen give my thanks to the germans. i love my passat
15:12LauJensenamalloy: You do ? It must be one of the older models, they were quite solid engineering
15:12amalloy2000
15:13LauJensenYea, thats the good model
15:13amalloythe new ones are no good?
15:13LauJensenamalloy: I've hear the have problems. Like the clutches wearing out etc. They drive smoothly like Mercedes though
15:13LauJensenBut generally, I think VW is too error prone
15:20RaynesI've wanted to drive an Audi since I watched the Transporter series.
15:21amalloyclojure has some sort of weighted-random-choice thing built in, doesn't it?
15:22mrBlissamalloy: not built-in but: wrand in http://clojure.googlegroups.com/web/ants.clj?gda=AonnajoAAADKqc_OBXvAPFRl94RaAIUvKeh6_1AakPQPpm5YTGkHfO9OU0NQiFWgQuhmPR7veGf97daDQaep90o7AOpSKHW0
15:23amalloymrBliss: ah. i've written one too, but i was hoping to find a "standard" one
15:33riddochcHi, folks. Any incanter users around? I'm trying to figure out how to do a line graph with more than one line on it, and have hit a wall.
15:38amalloyaha! incanter has (defn roulette-wheel [freqs]), which is exactly what i wanted
15:43riddochcamalloy: Cool, that could be useful for various things...
15:43amalloyriddochc: yeah, sorry but i've never used incanter so i can't really help with graphs
15:46riddochcamalloy: That's okay, I think I'll just use gnuplot for now. I'll come back to incanter again, when I've got some more time to figure this out. Looks like if I figure it out, I should help a little with the documentation by writing up what I figure out.
15:48amalloyriddochc: often the case :)
15:59amalloyRaynes: pircbot. it looks like the branch is still around just for sentimental reasons. do you mind if i kill the branch and replace it with a tag?
16:00Raynesamalloy: Not sentimental reasons as much as for historical reasons.
16:00RaynesBut yeah, go for it.
16:00RaynesNo particular reason for it to be a branch.
16:00amalloyhurrah
16:00LicenserRaynes, LauJensen: try-clojure.org has a reason, dashes are clojures usual way to name multi word symbols since there is no word tryclojure (unless I am mistaken which of cause isn't the case) but the side says: "try clojure" I found it the best way to go with clojures notation there: try-clojure.
16:01RaynesLicenser: I would have aimed for consistency with the other trylanguage sites. It doesn't particularly matter. Just a name. Don't think I'm not grateful for the domain name! :D
16:02RaynesLicenser: Where have you been lately? Working hard, or hardly working?
16:02RaynesI miss my German buddy. <3
16:02LicenserI hate consistency we are better so we can have better name :)
16:02amalloyhaha
16:03Licenserfirst working hard then hardly working in vacation :) which also hits me now, GF wants my attention, see you later people!
16:03RaynesWomen. Stealing our coders.
16:03amalloyRaynes: relax. it doesn't happen often :)
16:03Raynes:p
16:04SergeyDBTW, Jacob Nielsen advises not to use dashes in domain names.
16:04SergeyDFor better usability
16:11riddochcArgh. Word processors suck.
16:12kryftWhy use one?
16:13riddochcIndeed. If I'd done this in LaTeX, I'd have been done a long time ago. Every once in a while, I think, "Maybe it might be easier..."
16:13pppaulword procs are hell
16:19riddochcBother. I'm just going to make this graph with pen, rulers, and colored pencils now. It'll just save me time.
16:19amalloyriddochc: save yourself some time and engrave it in stone. you know that'll be next anyway
16:20riddochcFor a list of the ways in which technology has failed to improve our quality of life, press 8.
16:20riddochcamalloy: :)
16:20amalloyRaynes: hurrah, more cleanup completed: pircbot is now a tag, and all branches have active development
16:20hoeckriddochc: though latex has lots of warts and inconsistencies, being able to edit and navigate the document in your favourite editor beats all the word processors on this planet
16:21riddochchoeck: Agreed. That counts for a lot.
16:22hoeckriddochc: well, and you can use git/hg, diff, grep, find etc etc :)
16:23riddochchoeck: Oh, yeah. I've become a major advocate for git, even just for single documents.
16:24riddochcI haven't looked in a while, but if there's a tortoise-* thing for git on windows, I'd be suggesting it to my non-technical friends, too.
16:25riddochcAh, there is. Cool. http://code.google.com/p/tortoisegit/
16:40SergeyDCould you advise on how to write a macro that makes the following transform?
16:40SergeyD(mymacro [par1 par2] some-form-with-par1-par2)
16:40SergeyDinto
16:40SergeyD(let [par1 "par1" par2 "par2"] some-form-with-par1-par2)
16:41chouserSergeyD: first write a function that does that
16:42chouser(defn myfn [par-vector form] ...)
16:43chouser& ((fn myfn [par-vector form] (interleave par-vector (map str par-vector))) '[par1 par2] 'body)
16:43sexpbot⟹ (par1 "par1" par2 "par2")
16:45SergeyDchouser, thanks!
16:46amalloy&(vec (mapcat (juxt identity str) '[par1 par2])) ; chouser?
16:46sexpbot⟹ [par1 "par1" par2 "par2"]
16:47SergeyDnice :)
16:51amalloySergeyD: you might want to change identity to symbol: it's slightly shorter, and then you could use it as (mymacro ["foo" "bar"]) as well as (mymacro [foo bar]) if you wanted
16:52SergeyDammaloy, thanks, I'll try
17:01Deranderokay, so I'm writing what amounts to an infinite loop for a daemon in clojure
17:01Deranderis there a way to test this in a repl w/o having to restart slime everytime?
17:04amalloyDerander: have the daemon check an atom at every iteration? then swap! it with ::stop when you want it to stop
17:04Deranderthat is a good idea
17:04Deranderthank you sir
17:05amalloyDerander: a classic hack, but not very good obviously. do something more clever when you're done developing :P
17:05Deranderheh
17:06amalloy&(class :::test)
17:06sexpbotjava.lang.Exception: Invalid token: :::test
17:15amalloywhere's that function (f val pred), which returns val if (pred val) is true, and nil otherwise? it's so handy but i can never remember where to find it
17:21Deranderamalloy: oh damn, that is handy
17:22Rayneschouser: You are so beautiful when you &. <3
17:31nickikhas anybody used appengine?
17:37amalloyargh, i give up. i'll just write (when (pred x) x) :P
17:42amalloyi know it's in clojure.contrib somewhere though, if anyone else feels like looking
17:51defnanyone in the room know anything about hudson?
18:05SergeyDGreat, now I can destructure query (named) parameters in Ring. Anybody interested?
18:07amalloyokay, i feel kinda silly here. i have a seq of [x, y] pairs, and i want to turn that into a seq that looks like [[x1 x2 x3] [y1 y2 y3]]. surely there's a better way than ((juxt keys vals) (into {} pairs))...
18:09SergeyDamalloy, using get on pairs?
18:10amalloySergeyD: i don't think i understand
18:10MayDaniel(apply map vector [[1 2] [3 4] [5 6]]) ?
18:12MayDaniel,(apply map vector [[1 2] [3 4] [5 6]])
18:12clojurebot([1 3 5] [2 4 6])
18:12amalloyMayDaniel: aha, that's it. i thought map vector seemed right but i couldn't make it fit. thanks
18:24powr-tocI once remember seeing a diagram showing 'development flow' in clojure, it showed how the reader reads the text, spits out an AST, which macros operate on, which is then passed on to the evaluator... Does anyone know where I can find this diagram?
18:28amalloyRaynes (or anyone): M-x gist-buffer has stopped working for me recently. do we suppose this is another consequence of github's change to https?
18:29powr-tocah its ok, I remember it was from Rich's clojure for java programmers presentation.
18:32Deranderparsing xml with zippers is hard
18:32Deranderhtml*
18:33amalloyDerander: is it xhtml-compliant?
18:34Deranderamalloy: it's been run through html-cleaner
18:34Deranderamalloy: the trouble is I don't understand zippers very well :-)
18:35amalloyDerander: i didn't either, but somewhere i have an example of parsing a not-quite-trivial xml tree. lemme find it for you
18:35Deranderyeah. I'm at the stage where I can hack something together to parse trivial examples, but can't write something actually useful
18:36SergeyDDerander: may be Enlive can help you
18:36DeranderI was *just* about to type that
18:37DeranderIt just occurred to me that enlive does this stuff
18:38Raynesamalloy: It's probable.
18:41LauJensenWould somebody do me a favor and take a look at core.clj on http://github.com/LauJensen/clojureql and explain to me why you can eval that file once but not twice due to Clojures warnOnOverride var stuff ?
18:41LauJensen(also, ClojureQL now supports aggregates)
18:42amalloyDerander: https://gist.github.com/ee00790a79259e69243a was me finding a map of {tag1 {attr1 val1, attr2 val2}} in a file that looked like <foo><databases><db1 config="bar" /></databases></foo>
18:42Deranderthank you
18:46morphlingLauJensen: line 56 in predicates.clj sholdn't this be clojure.core/not=?
18:47LauJensenmorphling: no, != is a fairly common operator
18:48morphlingI meant you apply = in = and = in != which seams odd
18:48LauJensenmorphling: ah! thanks for staying sharp :)
18:48morphlingI suspected a cut&paste error, but I might be wrong
18:49LauJensenfixed
18:51morphlingLauJensen: I ran the test in clojureql.core in postgresql this afternoon, seems to work
18:51morphling(after removing "autoincrement")
18:51LauJensenmorphling: Did that test include the joins?
18:53morphlingyes, but "seems to work" only means there were no exceptions thrown, I didn't actually think about what the results should have been
18:55LauJensenhehe. Well the queries are simple, they should work on both backends. The joins worked if you see the :wage column being added in the resultset
18:57LauJensenAnd only the final test should return nil
19:15morphlingLauJensen: I just checked again with the predicates commit, everything works as expected
19:16LauJensenSweet. Thanks for testing - And while you were busy I fixed the ns reloading issue
19:19morphlinggreat, pulling. So far I really like the new clojureql
19:20samxWhat's a simple way of changing nth element in a list ? Something like: (replace-elem-by-index 2 10 [1 2 3 4 5]) => (1 2 10 4 5)
19:21amalloy&(assoc [1 2 3 4 5] 2 10)
19:21sexpbot⟹ [1 2 10 4 5]
19:21samxthx :-)
19:21LauJensenmorphling: Glad to hear it - Im quite excited about it myself
19:22LauJensenTomorrow I'll hopefully find time to fix 'rename' and then the major relational algebra primitives should all be there
19:22Raynessamx, amalloy: Note that that will only work for vectors and not for sequences.
19:22amalloysamx: caveats: that only works for vectors, not lists; it can't grow/shrink the vector, but only replace existing elements
19:22ninjuddLauJensen: is there a way to get sql out of a Relation? i'm thinking about writing some tests...
19:23LauJensenninjudd: I think tests are a little pre-mature in the design alpha phase no? Right now the deref call compiles the SQL, but there's no reason that can't go into its own compile function. So if you want it I'll drop it in
19:25samxamalloy, raynes.. hmm, ok.. well, considering that i don't have a good feel yet on when the various functions return back a seq instead of a vector, i think i can live with that for now :-)
19:26amalloysamx: not many things return vectors, but you can turn any finite seq into a vector: &|(range 4)|& vs &|(vec (range 4))|&
19:27amalloyRaynes: any idea why sexpbot didn't catch that?
19:27LauJensenninjudd:
19:27LauJensenclojureql.core> (-> (table db :users [:id]) (project #{:title}) compile)
19:27LauJensen"SELECT users.title,users.id FROM users "
19:27LauJensen
19:27LauJensenI'll push it now
19:27Raynessexpbot: kill
19:27sexpbotKILL IT WITH FIRE!
19:27Raynesamalloy: No clue. He's still alive.
19:27LauJensenninjudd: Its sign off time for me - Its in the master now :)
19:28Raynesamalloy: You broke it.
19:28RaynesWrong number of args passed to execute-text.
19:28amalloybah
19:28amalloyokay
19:29RaynesWatching a movie. If you fix it, I'll live the fix as soon as I return (within the next 30 minutes to an hour).
19:29amalloyyeah, i'm on it
19:30amalloyRaynes: just missed a call site when adding params
19:32amalloyanyway samx, (vec coll) turns coll into a vector, which is fine so long as it's finite
19:32rata_hi all
19:36samxamalloy, right.. vectors are reprecented as some type of trees underneath, right?
19:37samxjust trying to figure how much overhead i'll be adding by the seq-to-vector conversion.. that is, if i should just be using a list for my data in the first place
19:38lllowhat would be the preferred way to parse HTML(XML) in clojure
19:39nickikcan i somehow add something to a classpath in leiningen? with en entery in the project.clj or somewhere else?
19:43lllodoes clojure have a xml namespace or something?
19:44lllosomething I can use?
19:46nickikclojure.xml
19:46nickikit does
19:46lllodoes it require anything else?
19:47nickik(parse <your xml>)
19:47nickiknot
19:47nickik*no
19:47lllook cool
19:50rata_lllo: there's a lazy-xml too I think
19:50lllohm
19:50llloparsing a html page didn't work :(((((
19:50amalloy_lllo: html is not, in general, well-formed xml
19:51nickikah html is diffrente if it is not done write
19:51nickik*right
19:51lllooh
19:51llloI thought it was an xml type of thing :(
19:51lllodamn
19:51nickikonly xhtml is
19:52amalloy_lllo: if you converted it to xhtml first you could use http://richhickey.github.com/clojure-contrib/#zip-filter
19:52nickikwhat is it exactly what you want to do?
19:55hiredmanyou can use tagsoup and clojure.xml together to parse html
19:57hiredmanhttp://markmail.org/message/2e7i72y4cg36wqdx is a little dated
20:00llloI want to download a page from a site
20:00llloand parse it for some info
20:00llloI guess I'll do it with regexes
20:00lllocurrently I get this message if I try to parse it
20:01lllojava.net.MalformedUrlException no protocol: <whole html file>
20:01amalloy_lllo: that has nothing to do with parsing
20:01hiredmanread the docs
20:01llloyou think?
20:02amalloy&(doc clojure.xml/parse)
20:02sexpbot⟹ "([s] [s startparse]); Parses and loads the source s, which can be a File, InputStream or String naming a URI. Returns a tree of the xml/element struct-map, which has the keys :tag, :attrs, and :content. and accessor fns tag, attrs, and content. Other parsers can be supplied by passing startparse, a... http://gist.github.com/665831
20:02lllooh
20:02llloso instead of passing it the html I can just give it the URL?
20:02amalloyindeed must, not just can :)
20:02devinusi'm not trying to start a flame war, but if i chose Clojure to learn for a lisp experience, would I miss out on the full lisp experience by shunning CL?
20:03amalloydevinus: you'd certainly miss out on some flame wars, which are arguably a part of the full experience
20:03lllohahahahaha
20:03devinus:)
20:04lllooh man I have flamewars all the time
20:04devinusi'm sure. I'm just trying to learn something that will give me the "Aha!" enlightenment expeience everyone apparently had in the 80's and 90's with Lisps
20:04amalloyi'd say no, but i only spent three weeks with CL before i gave up. very cool conceptually, but too much work to actually write in practice
20:04lllomy coworker: "all languages are of the same difficulty and they all work about the same"
20:05amalloylllo: all Blub languages, *maybe*
20:05llloI said: "try Haskell for difficulty". response: "lol wuts haskell"
20:06lllothat's the day I realized I work with people that have never seen anything but C, Java, Pascal
20:06llloand their derivatives
20:06lllodelphi for instance
20:06amalloywhoa what is pascal doing on that list. python and perl are the usual Ps that go there
20:06llloWoah Python is dynamically typed
20:07lllonobody at my work knows of anything that new :P
20:08dnolendevinus: CL has plenty of cool stuff, so does Scheme. They still have a lot of aha! to offer. Clojure has some unique aha!'s that you won't get programming Scheme or CL.
20:08devinushrm
20:12dnolendevinus: what programming languages are you familiar w/ ?
20:12devinusdnolen: Erlang, JS, Python, Ruby
20:15dnolendevinus: if you're familiar w/ those then you'll probably have a lot of fun w/ Clojure.
20:16llloman
20:16lllo(clojure.xml/parse "http://en.wikipedia.org/wiki/Bear&quot;) returns Server returned HTTP response code: 500 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd
20:17lllodamn
20:18samxdevinus, i really wouldn't worry about missing any ahas.. you can always read books/code/articles of CL/Scheme later; all of them should be fairly accessible after knowing one lisp.. at the moment i'd choose clojure as my first choice, just because it seems to have a decent amount of momentum behind it, while hmm.. CL and Scheme do not
20:21devinusdoes clojure do continuations?
20:21samxnope
20:22devinushrm apparently theres a library
20:22dnolendevinus: delimited continuations, I ported it from CL
20:22samxright.. but not first class continuations, is in scheme
20:41rata_why (key nil) throws an NullPointerException?
20:42amalloyrata_: because nil isn't a map entry?
20:42rata_yes, but shouldn't it say imposible to cast nil to map entry?
20:42amalloyno, you can cast nil to anything
20:43rata_well, any other exception message that's more descriptive would be ok
20:44rata_specially as nils can occur almost everywhere
20:45amalloy&|(.cast String nil)|& &|(.cast String "blah")|& &|(.cast String 'blah)|&
20:45sexpbot(.cast String nil) java.lang.IllegalArgumentException: No matching method found: cast
20:45sexpbot(.cast String "blah") java.lang.IllegalArgumentException: No matching method found: cast
20:45sexpbot(.cast String 'blah) java.lang.IllegalArgumentException: No matching method found: cast
20:45amalloyhey what? that works on my repl
20:48amalloy&(.cast java.lang.String nil)
20:48sexpbotjava.lang.IllegalArgumentException: No matching method found: cast
20:48amalloywtf. Raynes, why doesn't this work?
20:48amalloy,(.cast java.lang.String nil)
20:48clojurebotnil
20:49RaynesI don't know.
20:52lllo.cast is a java function?
20:53amalloyString.class.cast("blah")
20:53lllotry
20:54lllo,(cast java.lang.String nil)
20:54clojurebotnil
20:54amalloyhaha well that's a little better than using .cast, but .cast should work too
20:54amalloyhttp://download.oracle.com/javase/1.5.0/docs/api/java/lang/Class.html#cast%28java.lang.Object%29
20:54Raynes&(String. "")
20:54sexpbot⟹ ""
20:54lllothen you need to do this
20:54amalloy&(cast String "")
20:54sexpbot⟹ ""
20:55Raynes&(.replace "x" "x" "y")
20:55sexpbot⟹ "y"
20:55RaynesI don't know why that isn't working.
20:55RaynesMaybe a sandbox bug.
20:55RaynesDoesn't look like it.
20:56lllofor some reason I can't get String.class
20:57amalloy&String
20:57sexpbot⟹ java.lang.String
20:57lllo(String/class) doesn't work
20:57amalloylllo: String *is* String.class
20:57lllono
20:57Raynes...
20:57amalloy(class String)
20:57llloString is java.lang.String
20:57amalloy&(class String)
20:57sexpbot⟹ java.lang.Class
20:57lllook
20:58llloI wanted Class<String>
20:58amalloylllo: clojure doesn't have generics
20:58amalloy&(identical? String (.getClass ""))
20:58sexpbot⟹ true
20:59lllo,(.cast String nil)
20:59clojurebotnil
20:59lllook
20:59lllothen this is how you need to call .cast
20:59amalloywell, but as you pointed out i should just use cast, not .cast
20:59Raynes&(.cast String nil)
20:59sexpbotjava.lang.IllegalArgumentException: No matching method found: cast
20:59amalloyno point using interop functionality when there's a wrapper already
21:00lllo&(.getClass() "")
21:00sexpbotjava.lang.IllegalArgumentException: No matching method found: getClass for class clojure.lang.PersistentList$EmptyList
21:00amalloylllo: ()......
21:00Chousuke:)
21:00lllo&(.getClass "")
21:00sexpbot⟹ java.lang.String
21:00lllosee
21:00Chousuke,String
21:00clojurebotjava.lang.String
21:00amalloylllo: see what?
21:01lllo&(.cast (class String) nil)
21:01sexpbotjava.lang.IllegalArgumentException: No matching method found: cast
21:02lllowhat the hell
21:02amalloylllo: some kind of bug with the sandbox sexpbot is using
21:02amalloyRaynes and i will look into it when we get a chance
21:02lllo,(.cast (class String) nil)
21:02clojurebotnil
21:02Chousukelllo: (class String) returns Class
21:02llloyes I know
21:02Chousukewhat are you trying to figure out anyway?
21:03llloand .cast is a Class class member
21:03llloI don't understand how some can call .cast on java.lang.String, it's not a member method
21:03llloIIRC
21:03amalloyChousuke: rata_ was annoyed that (key nil) threw NPE instead of bad cast
21:03amalloylllo: instead of IIRC why don't you just look at the link i gave, to exactly that member method
21:03Chousukelllo: hm
21:04rata_instead of anything more descriptive
21:04Chousukelllo: cast is a method of the Class class
21:04Chousukelllo: and java.lang.String is an instance of Class
21:05lllono, java.lang.String is java.lang.String
21:05llloit's class is
21:05lllojava.lang.Class<String>
21:06llloand that has .cast member
21:06lllojava.lang.String doesn't have .cast member
21:06Chousukeerh, the class object instance does
21:06Chousuke,(class java.lang.String)
21:06clojurebotjava.lang.Class
21:06Chousukesee
21:06llloyes
21:06hiredman,(->> String class .getMethods (map #(.getName %)))
21:06clojurebot("forName" "forName" "isAssignableFrom" "isInstance" "getModifiers" "isInterface" "isArray" "isPrimitive" "getSuperclass" "getComponentType" ...)
21:07hiredman,(->> String class .getMethods (map #(.getName %)) (filter (partial = "cast")))
21:07lllostill doesn't explain how you can do
21:07clojurebot("cast")
21:07lllo,(.cast String nil)
21:07clojurebotnil
21:07Chousukelllo: because String is the class object
21:07lllothis shouldn't be possible
21:08Chousukelllo: String is not equivalent to what you get if you type String in java.
21:08Chousukelllo: it's like String.class
21:08amalloylllo: that is exactly equivalent to the following java: (String.class.cast(null))
21:08lllothen why do we have function class
21:08Chousukelllo: it gets the class of an instance.
21:08llloand why does String != (class String)
21:08llloit's the same thing
21:08amalloy&(map (juxt identity class) [String ""])
21:08sexpbot⟹ ([java.lang.String java.lang.Class] ["" java.lang.String])
21:09Chousukelllo: because the class of a class object is not the same as the class of an instance of the class that the class object represents :P
21:09llloString.class == "".getClass == (class String)
21:09Chousukelllo: no
21:09Chousukeclass String is kind of "String.class.class"
21:09amalloyChousuke: it's actually String.class.getClass()
21:09Chousukeie. the Class object representing Class :P
21:10llloaw geeze, why is clojure complicating this
21:10Chousukelllo: it's not complicated
21:10amalloyit's not
21:10llloString
21:10Chousukelllo: what are you still confused about
21:10lllo,String
21:10clojurebotjava.lang.String
21:10Chousukeyes
21:10Chousukea class object
21:10llloyes that's confusing
21:10Chousukehow so?
21:10amalloylllo: so don't use it
21:10Chousukewhat should it be?
21:11llloit says java.lang.String when actually it's Class<java.lang.String>
21:11llloif what you say is true
21:11His_Shadow->[\I \space \W \o \r \s \h \i \p \space \H \i \s \space \S \h \a \d \o \w]
21:11sexpbot⟹ [\I \space \W \o \r \s \h \i \p \space \H \i \s \space \S \h \a \d \o \w]
21:11amalloy(.toString (class ""))
21:11lllothe printout misrepresents what it actually is
21:11amalloy&(.toString (class ""))
21:11sexpbotjava.lang.IllegalArgumentException: No matching method found: toString
21:11Chousuke,(print String)
21:11clojurebotjava.lang.String
21:11Chousukelllo: it's not clojure's fault :P
21:11Chousukejava prints class objects like that.
21:11amalloy,(.toString (class ""))
21:11clojurebot"class java.lang.String"
21:12amalloyChousuke: not actually true
21:12lllohere it says class
21:12llloin clojure it doesn't
21:12lllotherefore its misleading
21:13llloand here's another thing
21:13ChousukePossibly the printout is java.lang.String because that reads in as a class object too
21:13lllowhen you do type hiting
21:13llloyou hint that the type you are passing in is a String, yet the "String" resolves to Class class
21:13Chousukeso (eval (read-str (print-str String))) returns String
21:14Chousukelllo: type hints are not class objects anyway
21:14Chousukejust symbols
21:14Chousukeor strings
21:23llloI know
21:23llloI'm just saying it's confusing sometimes :)
21:29amalloyhm. i'm implementing a quite simple lexer in clojure, and doing kinda a bad job of it. anyone have a reference to someone who did it well?
22:18hiredman~#68
22:18clojurebot68. If we believe in data structures, we must believe in independent (hence simultaneous) processing. For why else would we collect items within a structure? Why do we tolerate languages that give us the one without the other?
22:49jfkwClojure newb, starting off with some java interop (the jackcess library) and I'm trying to build the sample expression inside-out:
22:49jfkwSystem.out.println(Database.open(new File("my.mdb")).getTable("MyTable").display());
22:49jfkw(jackcess.Database.open (java.io.File. "/path/to/my.mdb"))
22:50hiredmanwhich java interop form is that?
22:50jfkwThe first one is the jackcess sample code at http://jackcess.sourceforge.net/
22:50hiredmanno it's not
22:51hiredmanah, you mean the java
22:51hiredmanI meant "of the clojure code you just pasted, what interop form is that?"
22:51hiredmanI had assumed "which java interop form is that?" was clearly not a question about java code
22:54samx_how do i do a map over the values of a hashmap (and get a map back) ? (That is: (map #(* % 2) { 1 10 2 20 }) => { 1 20 2 40 }
22:54Raynes(.display (.getTable (Database/open (File. "/path/to/my.mdb"))) "MyTable")
22:54amalloysamx_: look up fmap in clojure.contrib
22:55Raynessamx: (into {} (for [[k v] {1 10 2 20}] [k (f v])) works.
22:55amalloy(Raynes's is the way to do it with no libraries)
22:56Raynes(map (fn [[k v] m] [k (f v)]) { 1 10 2 20 }) works as well, but if you're going to destructure, you might as well use for.
23:06samx_thx.. the 'into' one seemed to work, but can't get the 'map' one to work, and not really getting what you are trying to do in it to even fix it
23:06amalloysamx_: you still need into; he means to replace for with map
23:07samx_ah, right
23:10amalloyRaynes: i don't think i'll use jflex for this thing, but it would be neat to build a cake plugin for it. do you know how to do that, or is that ninjudd's thing?
23:10RaynesI wrote the second ever cake plugin.
23:10RaynesI know my stuff.
23:10amalloyexcellent
23:17jfkwIf using lein swank, added :dependencies [org.clojars.gilesc/jackcess "1.2.0"], present ./lib/jackcess-1.2.0.jar, in what way is my (import '(com.healthmarketscience.jackcess Database)) incorrect?
23:18jfkwCould not initialize class com.healthmarketscience.jackcess.Database [Thrown class java.lang.NoClassDefFoundError]
23:29nimredwhich which way to install clojure/swank/slime/ for use with emacs ?
23:37samx_Is there a function in the standard libraries to calculate powers ? (Math/pow 2 3) is easy enough, just wondering
23:38samx_hmm... actually, I guess Math/pow will always end up convering values to doubles
23:39amalloy&(doc clojure.math/expt)
23:39sexpbotjava.lang.Exception: Unable to resolve var: clojure.math/expt in this context
23:39amalloy&(require 'clojure.math)
23:39sexpbotjava.io.FileNotFoundException: Could not locate clojure/math__init.class or clojure/math.clj on classpath:
23:39amalloybah
23:40amalloysamx_: it's clojure.math/expt, or i guess maybe clojure.contrib.math/expt
23:40Raynesamalloy: Yeah, I can't figure that one out either. Motivation to work on you know what.
23:40samx_ok. thx
23:44Raynesamalloy: Since when is there a clojure.math namespace, by the way?
23:45amalloyRaynes: man, like i said: or maybe clojure.contrib.math
23:45RaynesHehe.
23:45amalloywhich *apparently* is where it actually is
23:45nimredwhere to find a recent documentation on installing clojure/swank/slime ? Any www link to point to ?
23:46amalloynimred: there's a swank-clojure package in elpa
23:46woobynimred: http://data-sorcery.org/2009/12/20/getting-started/ and scroll down a bit
23:46nimredi do not use elpa
23:49nimredFile error: Cannot open load file, slime
23:50nimredhttp://clojure.pastebin.com/BHDt3H1Z
23:51nimredhttp://clojure.pastebin.com/mvqjB3BB
23:51nimredoops
23:51nimredhttp://clojure.pastebin.com/mvqjB3BB
23:52nimredshould'nt it work ?
23:59nimredwooby amalloy no way to install without using elpa ?
23:59amalloynimred: there is, but it's been a while since i did it and my instructions won't be very good