2011-11-10
| 00:11 | mindbender1 | $findfn :stu |
| 00:11 | lazybot | [] |
| 00:14 | mindbender1 | $(defrecord Person [fname lname address]) |
| 00:15 | mindbender1 | ,(defrecord Person [fname lname address]) |
| 00:15 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 00:19 | mindbender1 | what's the equivalent of java interface in clojure? |
| 00:29 | terom | mindbender1: protocol (IIRC, haven't used them yet) |
| 01:01 | brehaut | mindbender1, terom: multimethods, protocols and interfaces all exist in clojure and perform related but different things |
| 02:27 | tsdh | Does anyone have an example on how to use `name-with-attributes' from the tools.macro contrib lib? |
| 03:07 | tsdh | I figured it out and added an example to clojuredocs: http://clojuredocs.org/clojure_contrib/clojure.contrib.def/name-with-attributes |
| 04:31 | Fossi | somebody know why appengine-magic uses jetty directly and not ring.adapter.jetty? |
| 04:31 | Fossi | feels wrong to reimplement ssl connector handling |
| 06:12 | Blkt | (a late) good morning everyone |
| 07:24 | drguildo | can somebody help me solve problem 28 on 4clojure? i don't want the solution, just some pointers as i'm not making any progress. |
| 07:24 | drguildo | "write a function that flattens a sequence" |
| 07:25 | drguildo | apparently it's "easy" |
| 07:30 | drguildo | i've tried using cons but that requires cons'ing with something which produces a new sequence so i still end up with sub-sequence |
| 07:30 | drguildo | i tried using map but that just produces a sequence |
| 07:38 | drguildo | i guess not so easy that anyone can offer some advice |
| 07:39 | fronx | drguildo: mapcat and recursion may be useful to you. |
| 07:39 | fliebel | Are any of the Clojure books available in mobi? |
| 07:39 | fliebel | drguildo: I missed the question? |
| 07:40 | clgv | drguildo: humm there is an elegant way that uses a certain function - but that would be at least 66% of the solution |
| 07:40 | drguildo | all my solutions so far have used recursion and i took a quick look at mapcat but dismissed it quite quickly so i'll look at it some more |
| 07:40 | drguildo | clgv: :-/ |
| 07:41 | clgv | drguildo: you have to decide whether I should tell you the function name |
| 07:42 | drguildo | probably not at this point, thanks. i really want to solve this properly. the only reason i asked now is because i hit a point where i'm making literally no progress. |
| 07:43 | drguildo | i guess part of the problem is my knowledge of the various functions is very poor (i'm a total beginner) and so i've been trying to hammer a nail with only a saw. |
| 07:44 | clgv | drguildo: than you should have a look at e.g. http://clojure.github.com/clojure/branch-1.2.x/index.html |
| 07:44 | drguildo | i should but i'm desperate to solve this problem before i move on to doing something else as it's bothering me now |
| 07:47 | clgv | drguildo: a little hint: if tail-recursion becomes too complicated, you might as well try the lazy way |
| 07:48 | drguildo | is this problem really "easy" if it requires the use of tail-recursion and laziness? |
| 07:48 | drguildo | i mean i've had no real problem with previous ones up to this point |
| 07:48 | drguildo | but this one has stumped me |
| 07:50 | clgv | I dont remember all of the previous one but their is a light increase in diffculty from fibonacci to palindrom to this flatten |
| 07:51 | drguildo | i solved those previous ones without much difficulty |
| 07:52 | drguildo | maybe i'm weird or there is some huge gap in my knowledge |
| 07:52 | clgv | why does your recursion approach fail? |
| 07:53 | drguildo | because i've been trying to use cons and map and both of them produce sequences |
| 07:53 | drguildo | so i still end up with nested sequences |
| 07:54 | drguildo | i need to somehow make it produce nested cons calls but with a []/'() when it reaches the final element of the top-most sequence but i have no idea how |
| 07:55 | drguildo | i guess a distinct initial call to the function before doing recursive ones... maybe |
| 07:55 | drguildo | i'm at the point where i've tried lots of different things with varying degrees of success (failure?) and now my head is a bit of a mess |
| 07:57 | clgv | maybe you should tak a break and continue later on |
| 07:57 | drguildo | well i went to sleep and woke up not long ago |
| 08:00 | lucian | drguildo: i think i used concat for mine |
| 08:04 | drguildo | i need to find a way of dealing with the recursive call that passes in (rest xs) where it's an empty seq. hrmmmmm... |
| 08:05 | lucian | i do an if sequential? |
| 08:06 | drguildo | i still get a stackoverflowerror |
| 08:07 | clgv | drguildo: the stackoverflow is due to not using loop-recur aka tailrecursion |
| 08:08 | drguildo | i don't see how because there would have to be a lot of nested sequences for that to happen and right now i'm just testing on an already flat one |
| 08:08 | clgv | oh, then your recursion stop criterion is wrong |
| 08:08 | drguildo | exactly |
| 08:09 | drguildo | (rest xs) is, at the end of a list, going to be a [] |
| 08:09 | drguildo | so it'll just go into an infinite loop |
| 08:09 | drguildo | so i need to figure out how to avoid that |
| 08:10 | drguildo | this code seems far too verbose but i guess something that just works is a good start |
| 08:11 | lucian | my solution is also pretty verbose |
| 08:12 | clgv | SO NOW YOU GOT ME TO OPTIMIZE MY GOLFSCORE ON THAT PROBLEM ;) |
| 08:12 | clgv | ups. damn key^^ |
| 08:12 | drguildo | how much did you reduce it by? |
| 08:12 | clgv | 19 |
| 08:12 | clgv | to 43 |
| 08:12 | drguildo | excellent |
| 08:13 | clgv | could be a few more if there was a shortcut for recursive usage in a #() statement |
| 08:16 | lucian | how can you see this "golfscore"? and what is it? |
| 08:16 | clgv | lucian: it's the number of characters you used and you have to enable it in the options |
| 08:16 | lucian | ah, ok |
| 08:16 | drguildo | is there a way to do a conditional bind? like if (rest xs) is empty then bind a variable to [], otherwise bind it to the result |
| 08:16 | lucian | so pointless, and wisely hidden by default :) |
| 08:17 | lucian | drguildo: if-let might do what you want |
| 08:17 | lucian | acutally, it doesn't bind conditionally, it just binds the condition |
| 08:17 | clgv | lucian: ah well it's interesting to see how short your solution is in comparison |
| 08:18 | lucian | clgv: what's your handle on 4clj? so i can follow you |
| 08:18 | clgv | lucian: I didnt do much there. only 37 of the easier problems so far ;) |
| 08:18 | lucian | i haven't done much either, 71 |
| 08:19 | clgv | its the same as here |
| 08:19 | lucian | clgv: really? search must be broken or something |
| 08:20 | lucian | yeah, yours is way shorter :) |
| 08:21 | clgv | but not minimal it seems form the chart - I wonder whats the last trick |
| 08:21 | lucian | mine's from the time i was reading "the little schemer" |
| 08:30 | drguildo | urgh |
| 08:30 | drguildo | still no further forward |
| 08:31 | drguildo | i have two options: unflattened list or stack overflow |
| 08:32 | drguildo | am i right in thinking it's impossible to get an unflattened list while using cons? |
| 08:32 | drguildo | erm |
| 08:32 | drguildo | am i right in thinking it's impossible to get an flattened list while using cons? |
| 08:32 | lucian | drguildo: try conj |
| 08:32 | lucian | i use concat if it's a sequence and conj if it's not |
| 08:33 | drguildo | because of the cons problem? |
| 08:35 | lucian | drguildo: sure. and it's more general |
| 08:47 | kzar | Is there a Clojure / Java library that splits up a URL into it's component parts? I was hoping to get a map back ideally |
| 08:48 | drguildo | is it just me or are clojure error messages practically useless? |
| 08:51 | drguildo | clgv: can you tell me the name of that function? |
| 08:52 | tsdh | kzar: Doesn't the standard Java URL class have getters for the individual components? |
| 08:53 | clgv | drguildo: you can do it via tree-seq. that was my first one. but now I changed it to reduce size and its using basic lazy primitives only |
| 08:53 | kzar | tsdh: Oh yea, you're right |
| 08:53 | kzar | ,(.getHost (java.net.URL. "http://google.com")) |
| 08:53 | clojurebot | "google.com" |
| 08:53 | drguildo | clgv: which ones? |
| 08:54 | clgv | drguildo: lazy-seq coll? mapcat |
| 08:54 | fliebel | drguildo: What are you trying to do? I've seen you ask seq related question all morning :) |
| 08:54 | clgv | though coll? works on the examples but maybe not in general for all flatten cases |
| 08:54 | drguildo | write a function that flattens a sequence |
| 08:55 | fliebel | drguildo: 4clojure? Because there is just a flatten function in core. |
| 08:55 | drguildo | yeah |
| 08:55 | babilen | kzar: (bean (URL. "http://www.clojure.org")) |
| 08:58 | fliebel | drguildo: If you want to do fancy, you could as well use http://clojure.github.com/clojure/clojure.zip-api.html#clojure.zip/next |
| 09:03 | drguildo | i want to do "something i can actually get to work" ;-) |
| 09:09 | clgv | drguildo: the read about tree-seq and try that approach |
| 09:10 | TimMc | drguildo: Which problem? |
| 09:11 | fliebel | TimMc: flatten a seq |
| 09:11 | drguildo | 28 |
| 09:14 | TimMc | Oh, huh -- chouser's solution is mine, but inside out. |
| 09:15 | TimMc | I think it is a little better in efficiency that way, maybe. |
| 09:19 | cemerick | kzar: that's what the url fn in com.ashafa.clutch.utils does, actually :-) |
| 09:19 | cemerick | obviously built for clutch's purposes, but it might help you |
| 09:20 | kzar | cemerick: I switched back to 0.2.5 because I couldn't get the watch for changes feature working with 0.3.0. Again I posted on the group but my reply didn't show up |
| 09:20 | TimMc | drguildo: So you tried a recursive solution, but it didn't work? |
| 09:20 | kzar | cemerick: Right I ended up writing my own, using clj-url.core/parse and then just renaming :path to :name pretty much (and stripping the "/" ) |
| 09:21 | cemerick | kzar: google caught your emails as spam :-( I whitelisted you. |
| 09:21 | kzar | cemerick: Hey that's weird, I use google apps for my email too! cheers |
| 09:22 | cemerick | yeah, groups' spam detection isn't so great |
| 09:22 | cemerick | kzar: I'll have to reply later, but maybe you could send (another) email with your watch-changes call(s), or a gist to the same? |
| 09:24 | kzar | cemerick: Sure, that's totally fine. I reduced it down to simply adding a hook like (clutch/watch-changes db :test println :include_docs true) and I still found it to not work, then when I switched back it was working again. Might be me but I suspect the feature's buggered in the new version |
| 09:25 | drguildo | TimMc: yeah |
| 09:26 | cemerick | kzar: the tests pass, but, well, stranger things have happened than tests passing while a bug is floating about |
| 09:26 | cemerick | I'll definitely look at it some time this week |
| 09:26 | kzar | cemerick: Hey I meant to ask, what's your talk going to be about? Or is it secret? |
| 09:26 | abedra | cemerick: I believe somebody said something about tests passing and bugs |
| 09:26 | abedra | cemerick: can't quite place it though ;) |
| 09:26 | kzar | abedra: That _does_ ring a bell, heh |
| 09:27 | cemerick | abedra: I heard something like that somewhere. |
| 09:27 | cemerick | ;-) |
| 09:27 | cemerick | kzar: http://clojure-conj.org/schedule#emerick |
| 09:28 | technomancy | so is clojure.test.generative quickcheck ported to clojure? |
| 09:28 | abedra | cemerick: that's a good thing |
| 09:28 | technomancy | without type inference? =) |
| 09:28 | abedra | technomancy: not quite |
| 09:28 | abedra | technomancy: it doesn't have narrowing |
| 09:28 | redinger | cemerick: you have time for Q&A? |
| 09:28 | kephale | cemerick: i do a fair amount of machine learning so your talk looks pretty cool. any chance you'll post your slide somewhere? |
| 09:28 | abedra | technomancy: but it is done in the spirit of qcheck |
| 09:29 | TimMc | drguildo: Can you gist your (broken) solution? |
| 09:29 | cemerick | ibdknox: all bark, no bite ;-) |
| 09:29 | technomancy | http://ruby.sadi.st/Heckle.html |
| 09:29 | ibdknox | cemerick: probably. :D |
| 09:29 | abedra | technomancy: that would be interesting |
| 09:29 | abedra | technomancy: and actually really easy |
| 09:29 | cemerick | redinger: fair point. we'll see |
| 09:29 | kephale | cemerick: given that i'm still in MA instead of conj |
| 09:30 | technomancy | abedra: easier with CinC though |
| 09:30 | cemerick | kephale: slides, code, etc. |
| 09:30 | abedra | technomancy: yes |
| 09:30 | technomancy | well, maybe not; hmm |
| 09:30 | cemerick | kephale: where in MA? |
| 09:30 | kephale | yay |
| 09:30 | abedra | technomancy: didn't Ryan convert ruby into sexps to make Heckle? |
| 09:30 | technomancy | abedra: pretty much |
| 09:30 | abedra | technomancy: well we are already there :) |
| 09:30 | kephale | cemerick: waltham at the moment, but often in amherst hanging out with Lee |
| 09:31 | kzar | technomancy: Oh, I meant to say; I couldn't get that buildpack working it said it wasn't found. I ended up doing this: `heroku config:add LEIN_NO_DEV=1` which just set the environment variable manually and that worked fine |
| 09:31 | cemerick | kephale: right, right; couldn't place your handle at first :-) |
| 09:31 | abedra | technomancy: the cool thing would be to have a repl that replaced the reader with the reader + a heckler |
| 09:31 | kephale | cemerick: Brandeis to be precise. good luck on your talk though |
| 09:32 | cemerick | Thanks! |
| 09:33 | technomancy | kzar: ah, bummer. I'll see if I can get it working after the conj |
| 09:33 | technomancy | abedra: yeah, going upstream of the compiler would sidestep the cinc issue |
| 09:34 | abedra | technomancy: yeah, the reader is the place for now where this would have to happen |
| 09:37 | lnostdal_ | is it possible to extend deref and @ so it can work with other non built-in things? |
| 09:37 | ibdknox | lnostdal_: yes |
| 09:38 | TimMc | IDeref, right? |
| 09:38 | ibdknox | yep |
| 09:38 | lnostdal_ | yeah, i need to do some java interop? |
| 09:38 | ibdknox | no |
| 09:38 | ibdknox | you can just do deftype |
| 09:39 | ibdknox | and implement IDeref |
| 09:39 | TimMc | that is sort of interop |
| 09:39 | lnostdal_ | ok, cool |
| 09:39 | ibdknox | fair enough |
| 09:39 | ibdknox | it doesn't really *look* like interop :) |
| 09:39 | ibdknox | lnostdal_: http://stackoverflow.com/questions/2944108/implementing-custom-data-structures-using-clojure-protocols |
| 09:39 | mjwhitt | are clojure conj slides online anywhere? |
| 09:40 | abedra | lnostdal: Make sure to look at how deref works in the current set around blocking when being printed |
| 09:40 | abedra | mjwhitt: they will be |
| 09:40 | abedra | and the videos should be as well |
| 09:41 | redinger | mjwhitt: They'll be here when we get them: https://github.com/relevance/clojure-conj/tree/master/2011-slides |
| 09:41 | ibdknox | lnostdal_: so you'd do that with clojure.lang.IDeref |
| 09:41 | mjwhitt | thanks |
| 09:41 | redinger | We'll announce them and the videos later |
| 09:43 | lnostdal_ | ibdknox, awesome; thank you |
| 09:56 | kzar | technomancy: Should futures work OK on Heroku? |
| 09:56 | technomancy | absolutely |
| 09:56 | technomancy | you can do "heroku run lein repl" to experiment |
| 09:57 | kzar | oh, good point I'll use that |
| 09:57 | kzar | thanks |
| 10:00 | melipone | I have a question about Java interop. I'm using lein repl and I am putting a jar file into the lib directory so it's in my classpath. I do (import '(net htmlparser jericho)) to access the jar file but I get a class not found exception. I can access the jar fine through a Java program that I import, so WTF? |
| 10:01 | technomancy | (import 'net.htmlparser.Jericho) maybe? |
| 10:01 | drguildo | TimMc: i don't even have a solution right now because i've had about 2^2809423 varies attempts none of which have failed so i just deleted it all with the aim of starting over |
| 10:01 | srid | do we have an IRC channel specific to clojure/conj? |
| 10:01 | danlarkin | wow @fakerichhickey is really tweeting up a storm |
| 10:02 | TimMc | srid: Like, a backchannel? |
| 10:02 | drguildo | https://gist.github.com/1355036 |
| 10:02 | drguildo | that's the last one i tried |
| 10:03 | drguildo | i don't actually even understand why it doesn't work heh |
| 10:03 | TimMc | drguildo: You'll probably have better luck using map. |
| 10:03 | drguildo | i've tried using map |
| 10:03 | redinger | srid: I debated that, I am in #clojure/conj, but didn't think everybody in here would mind if we just hung out here :) |
| 10:03 | drguildo | same problem: i get back the exact same sequence |
| 10:03 | drguildo | well, apart from the outer one being a list |
| 10:04 | TimMc | drguildo: ##(seq [1 2 3]) |
| 10:04 | lazybot | ⇒ (1 2 3) |
| 10:04 | TimMc | ,(seq? [1 2 3]) rather |
| 10:04 | drguildo | my problem is i can't use map or cons/conj without getting back another list |
| 10:04 | clojurebot | false |
| 10:05 | drguildo | so any recursive call to them is going to result in another list leading to nested lists |
| 10:05 | drguildo | by lists i mean sequences but whatever |
| 10:05 | lucian | heroku have nice graphics |
| 10:05 | TimMc | drguildo: so you want to concatenate them |
| 10:06 | drguildo | so wait |
| 10:06 | drguildo | what do i use instead of seq? i thought vectors were sequences |
| 10:06 | gtrak | /join #clojure/conj |
| 10:06 | TimMc | drguildo: If you have '[[1 2 3] [a b c]] how do you turn that into '[1 2 3 a b c]? |
| 10:06 | TimMc | drguildo: coll? |
| 10:06 | drguildo | TimMc: if i could answer that i'd be able to solve this problem |
| 10:06 | TimMc | vectors, lists, maps, sets, and sequences are all colls |
| 10:06 | TimMc | and are all seqable |
| 10:07 | clgv | drguildo: I suggest structuring your code so that if you know your argument is a collection than you apply your function on every element and concatenate the result |
| 10:07 | redinger | Alright, let's take the clojure/conj talk over to #clojure/conj |
| 10:07 | drguildo | i think i solved it |
| 10:07 | drguildo | https://gist.github.com/1355050 |
| 10:07 | clgv | coll? works on the 3 examples but not necessarily on all flatten use cases |
| 10:07 | drguildo | TimMc: why does seq? return false on a vector? |
| 10:08 | clgv | drguildo: since it doesnt implement ISequential ##(doc seq?) |
| 10:08 | lazybot | ⇒ "([x]); Return true if x implements ISeq" |
| 10:08 | TimMc | drguildo: Because a vector is a collection, but not a sequence. (seq some-vector) is a sequence. |
| 10:08 | clgv | Iseq rather |
| 10:08 | drguildo | hrmm, ok |
| 10:08 | drguildo | i thought they were all sequences by default |
| 10:08 | TimMc | It is seq-able -- you can get a seq of it -- but it itself is just a collection. |
| 10:08 | TimMc | drguildo: It's the other way around -- sequences are themselves collections. |
| 10:09 | TimMc | but it is very easy to work with any collection as a sequence. |
| 10:09 | drguildo | i think i need to sit down and read an actual book sequentially (pun intended) because i get the impression there are basic things i should know that i don't |
| 10:09 | raek | drguildo: the functions in clojure that expect a sequence as an argument will call (seq ...) on the argument first before using it |
| 10:09 | TimMc | seq vs. coll is a bit complicated. |
| 10:09 | abedra | ,(= '(1 2 3) [1 2 3] #{1 2 3}) |
| 10:09 | clojurebot | false |
| 10:10 | drguildo | what should i do to understand it? is there something i should read? is it important to know? |
| 10:10 | TimMc | ,(= '(1 2 3) [1 2 3]) |
| 10:10 | clojurebot | true |
| 10:10 | raek | IMHO, it would have been more intuitive (but more verbose) if the core function would not have called 'seq' automatically |
| 10:10 | abedra | TimMc: yes, sorry, I got carried away |
| 10:11 | TimMc | ,(vec (seq #{1 2 3})) |
| 10:11 | clojurebot | [1 2 3] |
| 10:11 | TimMc | ,(vec (seq #{3 2 1})) |
| 10:11 | clojurebot | [1 2 3] |
| 10:11 | pjstadig | ,(= '(1 2 3) [1 2 3] (seq #{1 2 3})) |
| 10:11 | clojurebot | true |
| 10:11 | raek | drguildo: most of the time, you just use sequences and use vectors as sequence literals |
| 10:11 | TimMc | ,(ancestors (class #{2 1 3})) |
| 10:12 | drguildo | yeah but right now trying to use a vector as a sequence literal bit me in the ass so i need to have a more precise understanding than that |
| 10:12 | TimMc | oh, clojurebot |
| 10:12 | TimMc | &(ancestors (class #{2 1 3})) |
| 10:12 | lazybot | ⇒ #{java.util.Set clojure.lang.IMeta clojure.lang.IObj clojure.lang.IFn java.util.concurrent.Callable clojure.lang.IEditableCollection java.lang.Runnable clojure.lang.IPersistentCollection clojure.lang.Seqable java.lang.Object java.lang.Iterable java.util.Collection ... https://gist.github.com/1355062 |
| 10:12 | drguildo | i wasted hours because i was using seq? on a vector |
| 10:12 | raek | drguildo: how did it bite you? |
| 10:12 | drguildo | and it was returning false |
| 10:12 | drguildo | read the last 2 gits i pasted |
| 10:12 | raek | also, to remove one level of nesting of sequences, use (apply concat ...) |
| 10:13 | drguildo | the first fails and the second works |
| 10:13 | raek | ,(apply concat [[1 2 3] [4 5 6]]) |
| 10:13 | TimMc | clojurebot is down |
| 10:13 | TimMc | suddenly |
| 10:13 | raek | &(apply concat [[1 2 3] [4 5 6]]) |
| 10:13 | lazybot | ⇒ (1 2 3 4 5 6) |
| 10:13 | abedra | TimMc: you killed it |
| 10:13 | TimMc | maybe pj did |
| 10:13 | TimMc | he was the last to poke it |
| 10:14 | abedra | true |
| 10:14 | TimMc | drguildo: ##(if (seq [1 2 3]) "It's seqable" "It's not seqable") |
| 10:14 | lazybot | ⇒ "It's seqable" |
| 10:14 | pjstadig | who me? |
| 10:14 | pjstadig | nah |
| 10:14 | clojurebot | #{clojure.lang.IPersistentSet clojure.lang.AFn java.util.concurrent.Callable clojure.lang.IObj clojure.lang.IMeta ...} |
| 10:14 | clojurebot | (1 2 3 4 5 ...) |
| 10:14 | drguildo | right, but it isn't a seq |
| 10:14 | TimMc | haha |
| 10:14 | TimMc | Oh, clojurebot |
| 10:15 | TimMc | ,(seqable? [1 2 3]) |
| 10:15 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: seqable? in this context, compiling:(NO_SOURCE_PATH:0)> |
| 10:15 | TimMc | &(seqable [1 2 3]) |
| 10:15 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: seqable in this context |
| 10:15 | TimMc | &(seqable? [1 2 3]) |
| 10:15 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: seqable? in this context |
| 10:15 | TimMc | What am I missing? |
| 10:15 | pjstadig | seqable? doesn't exist? |
| 10:15 | raek | seqable? is in contrib (and does not always work) |
| 10:15 | TimMc | Oh! It's a contrib thing? |
| 10:16 | ibdknox | yes |
| 10:16 | drguildo | sequential? |
| 10:16 | hiredman | no |
| 10:16 | TimMc | Not quite. |
| 10:16 | abedra | &(apropos 'seq) |
| 10:16 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: apropos in this context |
| 10:16 | TimMc | apropos is a repl util |
| 10:16 | raek | the clojure collections are seqable, so you can use 'coll?' |
| 10:16 | abedra | thought it might be available here |
| 10:16 | ibdknox | &(require 'clojure.repl) |
| 10:16 | lazybot | ⇒ nil |
| 10:16 | TimMc | ,(coll? "foo") |
| 10:16 | clojurebot | false |
| 10:16 | ibdknox | &(apropos 'seq) |
| 10:16 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: apropos in this context |
| 10:17 | ibdknox | &(clojure.repl/apropos 'seq) |
| 10:17 | lazybot | ⇒ (seq-test if-seq-error seqable? chunked-seq? sequential? doseq sequence rseq seq? xml-seq seque rsubseq seq re-seq resultset-seq file-seq tree-seq enumeration-seq iterator-seq lazy-seq line-seq subseq seq-zip parsed-seq parsed-smile-seq) |
| 10:17 | TimMc | drguildo: Basically, colls and seqs and so forth are best represented with a Venn diagram that no one was drawn yet. |
| 10:17 | TimMc | *has |
| 10:17 | drguildo | so a string is sequable even though it isn't a coll? |
| 10:17 | raek | yes |
| 10:17 | TimMc | yeah, it's a special case of sorts |
| 10:17 | raek | doesn't support conj, for instance |
| 10:17 | TimMc | &(seq "hello") |
| 10:17 | lazybot | ⇒ (\h \e \l \l \o) |
| 10:18 | pjstadig | which means you can't... |
| 10:18 | drguildo | so seqs are the union of collections and some other stuff? |
| 10:18 | abedra | and other behavior you might not expect |
| 10:18 | abedra | &(reverse "hello") |
| 10:18 | lazybot | ⇒ (\o \l \l \e \h) |
| 10:19 | melipone | (import 'net.htmlparser.jericho) does not work either ... |
| 10:19 | raek | anyway, flatten is a bit weird function to have since the line between collection and "atom" is a bit fuzzy in clojure |
| 10:19 | raek | (I have never used it) |
| 10:19 | pjstadig | ,(into "hello " (seq "world")) |
| 10:19 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IPersistentCollection> |
| 10:19 | pjstadig | ^ a sad fact |
| 10:20 | tsdh | raek: Why is it fuzzy? No collection is an atom, isn't it? |
| 10:20 | raek | melipone: the part after the last dot must be a class (you cannot import every class in a package) |
| 10:20 | technomancy | pjstadig: I wonder if that's just waiting for more seq stuff to get moved to protocols |
| 10:20 | TimMc | drguildo: Point of clarification: "atom" is an overloaded word here. |
| 10:20 | abedra | oh wow, did both bots die? |
| 10:20 | pjstadig | technomancy: maybe |
| 10:20 | TimMc | there are only so many good names |
| 10:20 | TimMc | &(+ 1 1) |
| 10:20 | lazybot | ⇒ 2 |
| 10:21 | TimMc | &(println "still alive") |
| 10:21 | lazybot | ⇒ still alive nil |
| 10:21 | clgv | ,(println "still alive") |
| 10:21 | clojurebot | still alive |
| 10:21 | hiredman | /win 22 |
| 10:22 | hiredman | whoops |
| 10:23 | raek | melipone: (import 'net.htmlparser.jericho.Attribute) or (import '(net.htmlparser.jericho Attribute Config)) |
| 10:24 | raek | but use (:import net.htmlparser.jericho.Attribute) or (:import (net.htmlparser.jericho Attribute Config)) in a 'ns' form |
| 10:28 | TimMc | drguildo: Makin' a spreadsheet of this stuff. |
| 10:30 | fliebel | Huh... How can I access the TO field? http://download.oracle.com/javaee/5/api/javax/mail/Message.RecipientType.html |
| 10:31 | fliebel | d'oh javax.mail.Message$RecipientType/TO |
| 10:32 | ibdknox | in case anyone finds this useful: https://github.com/ibdknox/watchtower |
| 10:32 | duck1123 | fliebel: did you look at the postal library? |
| 10:32 | fliebel | duck1123: Not yet. I first wont to familiarize myself with the Java way. |
| 10:32 | drguildo | TimMc: ok, thanks |
| 10:34 | duck1123 | fliebel: I just started using it myself yesterday, but so far, it seems pretty easy. I had to do crazy things like attach a file to the email, and postal made that way easier than using the java lib directly |
| 10:34 | fliebel | duck1123: Huh, I remember someone showing me some project wrapping javamail, but I seem to remember it was way less mature |
| 10:36 | duck1123 | fliebel: https://github.com/drewr/postal |
| 10:36 | fliebel | duck1123: yeayea, did you show that to me before? Or was that someone else with a different library? |
| 10:37 | duck1123 | fliebel: I don't think it was me. I just found it yesterday |
| 10:38 | alexbaranosky | I've gotten by with: (:import [org.apache.commons.mail SimpleEmail]) |
| 10:38 | fliebel | duck1123: It was the same probable, or at least it also does not include receiving mail. |
| 10:39 | drewr | fliebel: yes, postal is currently send-only |
| 10:40 | drewr | or just Message contruction if you want to take care of sending yourself |
| 10:41 | fliebel | drewr: So it can map to and from maps to javax.mail.Message? |
| 10:43 | drewr | fliebel: yes |
| 10:43 | drewr | or at least it should! |
| 10:44 | drewr | open a ticket if there's a deficiency and I'll fix quickly |
| 10:44 | fliebel | drewr: So I "only" need to find a nice api for mailboxes and such. |
| 10:45 | drewr | fliebel: for imap et al? |
| 10:46 | fliebel | drewr: yea |
| 10:48 | drewr | I'll add those eventually |
| 10:48 | drewr | the main thing I constantly needed was a one-liner for sending out a message (for monitoring, etc.) |
| 10:54 | TimMc | $findarg (map % [true 5 "" nil false]) [true true true false false] |
| 10:54 | lazybot | [] |
| 10:55 | bhenry | seq |
| 10:56 | bhenry | (boolean (seq %)) |
| 10:56 | bhenry | oh that's wrong too |
| 10:56 | bhenry | ,(boolean nil) |
| 10:56 | clojurebot | false |
| 10:56 | bhenry | just boolean i guess. |
| 10:57 | duck1123 | ,(boolean 5) |
| 10:57 | clojurebot | true |
| 10:57 | TimMc | &(= (map boolean [true 5 "" nil false]) [true true true false false]) |
| 10:57 | lazybot | ⇒ true |
| 10:58 | TimMc | lazybot, you fail |
| 10:58 | duck1123 | ,(map identity [true 5 "" nil false]) |
| 10:58 | clojurebot | (true 5 "" nil false) |
| 10:58 | meteorfox | , (print "Hello") |
| 10:58 | clojurebot | Hello |
| 10:59 | meteorfox | hi, can anyone explain the bots? what's the difference between the clojurebot and the lazybot? |
| 10:59 | pyr | hi |
| 10:59 | pyr | is there a way for leiningen to use repos with credentials ? |
| 10:59 | pyr | i.e if a maven repo is protected by a htaccess |
| 11:00 | duck1123 | pyr: have you tried setting up whatever you have to do in ~/.m2/settings.xml for the same thing in maven? |
| 11:01 | pyr | duck1123: yep, this works |
| 11:01 | pyr | duck1123: i just want to know if there's a way to keep the config in project.clj |
| 11:01 | pyr | duck1123: it doesn't seem to accept the http://user@password:... scheme |
| 11:02 | pyr | i meant http://user:password@host/path |
| 11:03 | duck1123 | https://github.com/technomancy/leiningen/blob/1.x/sample.project.clj#L136 |
| 11:03 | duck1123 | :username and :password flags |
| 11:04 | pyr | thank! |
| 11:04 | pyr | thanks, rather :) |
| 11:07 | TimMc | $findfn "<" "<" |
| 11:07 | lazybot | [] |
| 11:07 | TimMc | ah well |
| 11:10 | pjstadig | &(System/exit 0) |
| 11:10 | lazybot | java.security.AccessControlException: access denied (java.lang.RuntimePermission exitVM.0) |
| 11:10 | ibdknox | lol |
| 11:10 | ibdknox | :p |
| 11:16 | TimMc | technomancy: Hey, isn't "[1.3.0,1.4.0)" not supposed to pick up 1.4? |
| 11:17 | technomancy | TimMc: not sure exactly. it may allow everything up to but not including the release, and the snapshots are considered prior to the release. |
| 11:18 | TimMc | I didn't understand that/ :-( |
| 11:18 | technomancy | (< 1.3.0 1.4.0-SNAPSHOT 1.4.0) ; basically |
| 11:19 | TimMc | ew ew ew |
| 11:19 | duck1123 | [1.3.0, 1.3.∞-1] |
| 11:19 | technomancy | 1.4.0 is not included in that range, but the snapshot is "under" the release. |
| 11:19 | TimMc | Any way to say "1.3.*" then? |
| 11:19 | technomancy | not sure off the top of my head |
| 11:20 | TimMc | I see this as one of the things holding back large-project robustness (not just in Clojure.) |
| 11:20 | technomancy | well generally applications should never use version ranges, just libraries |
| 11:21 | TimMc | That's what I mean. |
| 11:21 | TimMc | When libraries depend on libraries... |
| 11:22 | duck1123 | TimMc: but you can just lock down the transitive dependencies in your project, that way you're sure |
| 11:23 | technomancy | more details here: http://docs.codehaus.org/display/MAVEN/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges |
| 11:28 | TimMc | OK, so [1.3.0,1.3.999] for now. |
| 11:36 | seancorfield | amalloy: Raynes comment about juxt made me check the WS codebase... 13 occurrences of juxt in ~3kloc :) |
| 11:44 | pjstadig | &(deref (future)) |
| 11:44 | lazybot | java.lang.SecurityException: You tripped the alarm! future-call is bad! |
| 11:51 | lnostdal_ | couldn't ref-set, reset! and others be replaced by a generic setter facility now? .. with all the new stuff added to clj recently |
| 11:53 | vijaykiran | Hi .. I'm experimenting with enlive templating with compojure webapp - when I change the html file - the application doesn't reload it unless I stop and start it again .. |
| 11:53 | vijaykiran | is there anyway I can make it dynamically loaded whenver there's file change? |
| 11:54 | lnostdal_ | vijaykiran, re-load the resourc (xml-resource, html-resource) on every call to your templating code |
| 11:54 | lnostdal_ | resource* |
| 11:55 | lnostdal_ | at least that's what i do; on production i have (let [resource ...] (defn my-handler [] ...)) while developing i have (defn my-handler [] (let [resource ...] ...)) |
| 11:55 | raek | vijaykiran: if you have a repl you can reload the namespace that contains the deftemplate with (require ... :reload) |
| 11:56 | raek | there is middleware for reloading .clj files automatically, but that wouldn't trigger if you change a .html file |
| 11:57 | seancorfield | i had to solve that problem in fw/1 so i have a dev mode (that reloads the namespaces and resets the html node cache on every request) and a url param (configurable) that lets you force a reload |
| 12:09 | frem | I'm lazy. Is there a version of Clojure Box updated for 1.3? |
| 12:29 | rplevy | Raynes: OAKFOREST / CJ4MMF |
| 12:36 | Raynes | rplevy: Gotcha. Thanks. |
| 12:36 | wawa | ii |
| 12:41 | scottj | cemerick: when are you releasing your bayes lib? during/after your talk? |
| 12:42 | cemerick | scottj: sometime after |
| 12:42 | scottj | cemerick: best estimate? |
| 12:42 | scottj | "when it's ready" :) |
| 12:42 | cemerick | on review, someone pointed out a relatively significant flaw in my treatment of continuous variables, so I want to fix that before letting people trip up on it |
| 12:42 | cemerick | Next week, I'm hoping. |
| 12:42 | scottj | cool |
| 12:43 | cemerick | gd integrals |
| 12:43 | nuclearsandwich | cemerick: I am taking those math classes. Even we trip up on stuff like that all the time. ;) |
| 12:44 | ibdknox | ewwww math. |
| 12:44 | scottj | people at conj: are they recording this year? (have they announced it/do you see a camera?) |
| 12:44 | ibdknox | yes |
| 12:44 | cemerick | yeah, it's all being recorded |
| 12:44 | scottj | cool |
| 12:44 | nuclearsandwich | scottj: yeah they have I think confreaks doing it. High quality in my past experiences |
| 13:28 | TimMc | $findfn name [:a :b] {:a "a" :b "b"} |
| 13:28 | lazybot | [] |
| 13:29 | Bronsa | ,(into {} (map (juxt identity str) [:a :b])) |
| 13:29 | clojurebot | {:a ":a", :b ":b"} |
| 13:32 | mabes | According to the docs on extend (clojure 1.2) I should be able to provide interfaces (not just protocols), however this fails: (extend Foo clojure.lang.IFn {:invoke (fn [foo n] (if (= n 0) (.a foo) (.b foo)))}) |
| 13:32 | mabes | it says "interface clojure.lang.IFn is not a protocol" |
| 13:33 | mabes | the same happens with the extend-type macro since it just expands to use extend |
| 13:33 | mabes | however, if I inline the interface functions in the deftype it does work |
| 13:33 | mabes | any suggestions on what I'm doing wrong? |
| 13:44 | semperos | I'm new to logic programming, and obviously to core.logic; I'm converting some "regular" functions into ones that return goals |
| 13:44 | semperos | take this code for example: https://gist.github.com/1354083 |
| 13:45 | semperos | I have a function that relies on some Java interop under the hood and returns a boolean |
| 13:45 | semperos | but I've not seen any example of unifying a function's return value with `true`, as I've done in that gist |
| 13:45 | semperos | is this the "right" way in this situation? |
| 13:48 | fliebel | semperos: iirc, you need to use project to mix up regular and goal functions. |
| 13:49 | fliebel | Imagine what would happen is foo was unbound. |
| 13:50 | fliebel | So project walks the var, and binds the ground value, so you can use it in normal functions. |
| 13:50 | semperos | ok |
| 13:52 | semperos | fliebel: thanks, I'll try to get my head around project more, I had seen it used in a simple arithmetic example |
| 13:57 | callen | do you guys think the community needs a blog that documents common foibles and confusions that noobies run into when learning Clojure? |
| 13:57 | klauern | YES! |
| 13:57 | ibdknox | the community needs a starting point in general |
| 13:58 | klauern | I'm just learning Clojure now and I have had lots and lots of problems that amounted to simple things like (quote) and REPL behavior |
| 13:59 | semperos | one of the challenges in documenting such a starting point is the diversity of "skills" required to get started |
| 13:59 | klauern | I've even got this link bookmarked because I keep tripping up with it: http://blog.8thlight.com/colin-jones/2010/12/05/clojure-libs-and-namespaces-require-use-import-and-ns.html |
| 13:59 | semperos | JVM experience, Lisp development, functional programming... |
| 14:00 | ibdknox | semperos: yeah, I think part of what would be helpful is starting from no framepoint |
| 14:00 | ibdknox | semperos: because then you're forced to explain yourself in plain english in a way that could be universally understood |
| 14:00 | semperos | ibdknox: possibly, but then you're reading 100+ pages of material before you're really started :) |
| 14:01 | ibdknox | semperos: not if it's written right ;) |
| 14:01 | semperos | agreed |
| 14:01 | ibdknox | I've been thinking about taking that up as a project soon |
| 14:01 | cemerick | ibdknox: how many projects do you need? ;-) |
| 14:02 | ibdknox | cemerick: 27 at least ;) |
| 14:02 | cemerick | sounds about right |
| 14:02 | cemerick | as if I should talk :-P |
| 14:02 | semperos | another possible approach is what Rich did with the videos, in terms of detailed introductions for folks coming from Java, Lisp, etc. backgrounds |
| 14:02 | ibdknox | absolutely, I think both are extremely useful |
| 14:03 | ibdknox | and necessary! |
| 14:03 | technomancy | there's this site, but it kinda sputtered out: http://learn-clojure.com/ |
| 14:03 | semperos | I know for myself that I "got" Clojure in multiple phases, spending large swaths of time focusing on those individual skills until one day a critical "grok mass" was reached |
| 14:04 | ibdknox | technomancy: yeah, it needs work... lots of work. |
| 14:08 | callen | sooooo |
| 14:08 | callen | is it something I should do? |
| 14:08 | callen | I have a clojure project I am working on already |
| 14:08 | callen | it would simply be a matter of documenting as I go. |
| 14:09 | callen | I've been writing Clojure for 1-1.5 years but still feel stoopid. :| |
| 14:09 | technomancy | maybe you could contact the site's maintainer and see if he wants help |
| 14:09 | callen | heh, I've gone down that route before |
| 14:09 | callen | trying to pick up on poorly maintained stuff |
| 14:10 | callen | it turns into a shit-show. |
| 14:10 | callen | unless they're prepared to hand over the site and the domain, I'm not going to do that. |
| 14:10 | technomancy | maybe. there are a lot of independent efforts for things like this and not much coordination. |
| 14:10 | callen | that's not in the slightest my fault that people are too lazy to work with me. |
| 14:10 | ibdknox | hm |
| 14:10 | callen | HN Office Hours is derelict because I couldn't get the guys I worked with to stop sitting on it and let me code. |
| 14:10 | technomancy | well there's always the wiki |
| 14:11 | callen | I worked with the original weekend hackathon crew to get it deployed. |
| 14:11 | technomancy | no bottlenecks there |
| 14:11 | callen | I'm sharing anecdote |
| 14:11 | puredanger | klauern: I have argued for a while now that the content on Colin's blog you reference should be on one of the prominent pages on clojure.org instead of what is currently on http://clojure.org/libs but I never got a blessing to do it. I catalogued a bunch of similar ideas here: http://dev.clojure.org/display/doc/clojure.org+TODO+list |
| 14:11 | callen | not authoritative wiki content. |
| 14:11 | technomancy | puredanger: that absolutely should happen |
| 14:12 | puredanger | technomancy: well I have edit rights on the wiki. :) But I am typically delicate in changes on those pages unless blessed by Stu or Rich. |
| 14:12 | callen | that's the thing |
| 14:13 | callen | I'm not in the mood to debate, or argue, or try to make an encyclopedia of Clojure |
| 14:13 | callen | I just want to share anecdotes that will be relevant to noobies. |
| 14:13 | callen | "here's why my classpath was fucked" |
| 14:13 | callen | "here's what I misunderstood about namespaces" |
| 14:13 | technomancy | puredanger: I can see if I can corner one of them |
| 14:13 | ibdknox | that's a very different kind of content |
| 14:13 | callen | that's not wiki content. |
| 14:13 | ibdknox | and a very good kind of content |
| 14:13 | callen | that's my point. |
| 14:13 | callen | it's not wiki relevant at all |
| 14:13 | ibdknox | go for it |
| 14:14 | puredanger | clojure-docs is a good place for stuff like that example stuff but it is function-focused |
| 14:14 | callen | that's not a good place for what I'm talking about. |
| 14:14 | puredanger | yeah |
| 14:14 | callen | this is why I just do what's in my head normally. |
| 14:14 | callen | okay, so we're back to where I started |
| 14:14 | callen | making a blog. |
| 14:14 | callen | got it. |
| 14:14 | puredanger | things like "contains? doesn't do what you think it does. try some." |
| 14:14 | ibdknox | puredanger: cleaning up clojure.org would definitely make a huge difference. Just making it less like a PhD candidate's website is a good start. |
| 14:15 | technomancy | I don't necessarily think a "Pitfalls" page would be out of place on the wiki |
| 14:15 | ibdknox | technomancy: that's fair |
| 14:15 | puredanger | ibdknox: my best thoughts after collecting and distilling ideas on the web site a year ago are on that referenced to do list. |
| 14:16 | callen | technomancy: I don't want my content to be subject to the whims of the community. |
| 14:16 | callen | technomancy: I'm just making a blog. |
| 14:16 | puredanger | ibdknox: they are mostly not radical changes though, just cleaning and improving organization. I'm not a web site designer |
| 14:16 | klauern | Well, one thing that still trips me up is when walking through a tutorial and they have me type (ns foo) or something equivalent, I then try using (doc) (find-doc) or whatnot and realize that it doesn't work anymore |
| 14:16 | klauern | This is in the REPL |
| 14:16 | ibdknox | puredanger: yeah, I would want to do something a little more radical :) |
| 14:17 | puredanger | ibdknox: if someone wanted to take over and do whatever to learn-clojure, I'm sure Kyle would be happy to let people hack on it |
| 14:17 | klauern | Part of the problem I have is that I don't feel like when I'm in the REPL as a n00b I know enough about anything to be effective or useful. There's not (help) command, for instance, or (help ns) (help import), etc., that would be different from (doc ns) |
| 14:17 | semperos | what would folks consider to be the "most successful" non-clojure.org Clojure reference website? (informal poll) |
| 14:17 | ibdknox | puredanger: interesting... |
| 14:17 | mdeboard | klauern: What language are you coming from? |
| 14:17 | klauern | Java primarily |
| 14:17 | callen | semperos: github.com |
| 14:17 | klauern | Ruby on the side |
| 14:17 | TimMc | semperos: clojuredocs.org |
| 14:18 | puredanger | klauern: there is an api to get examples from clojuredocs at the repl |
| 14:18 | TimMc | It's the only one I know of. |
| 14:18 | puredanger | i find the core docs to be both wonderfully (and painfully) concise - clojuredocs plugs a hole there in providing examples |
| 14:18 | ibdknox | yeah, I have a sample size of one :/ |
| 14:18 | ibdknox | examples are the key to language acqusition |
| 14:18 | klauern | puredanger: what is that? I usually flit between clojuredocs and my REPL to figure things out |
| 14:19 | technomancy | the docstrings that just say "please see clojure.org" are always fun to hit when you're on a plane |
| 14:19 | TimMc | haha |
| 14:19 | ibdknox | :( |
| 14:19 | puredanger | technomancy: :) special forms ... |
| 14:19 | TimMc | good times with bad docs |
| 14:19 | semperos | my thought was clojuredocs.org as well, and even though an API/examples reference site, distilling what makes that so successful would be a first-step in standing up a proper and comprehensive "learning Clojure" site, from a usability and reliability-of-information standpoint, imho |
| 14:20 | puredanger | if anyone out there uses DuckDuckGo as their search engine (try it!) you can do "!clojure" in searches to search clojuredocs |
| 14:20 | lambdanaut | (reduce * (range 1 101) ) gives me an int overflow. What do? |
| 14:20 | TimMc | (inc DuckDuckGo) |
| 14:20 | puredanger | klauern: the lib to access clojuredocs from the repl is at https://github.com/dakrone/cd-client |
| 14:21 | semperos | lambdanaut: (reduce *' (range 1 101)) |
| 14:21 | semperos | is one way |
| 14:21 | TimMc | Is this a 1.2 vs. 1.3 thing? |
| 14:21 | klauern | puredanger: excellent! |
| 14:21 | semperos | yep |
| 14:21 | TimMc | ,(doc *') |
| 14:21 | ibdknox | ,(doc *') |
| 14:21 | semperos | lambdanaut: the return value of that is a clojure.lang.BigInt |
| 14:21 | lambdanaut | Oh thanks! What does that apostraphe do? |
| 14:21 | ibdknox | lol |
| 14:21 | clojurebot | "([] [x] [x y] [x y & more]); Returns the product of nums. (*) returns 1. Supports arbitrary precision. See also: *" |
| 14:21 | clojurebot | "([] [x] [x y] [x y & more]); Returns the product of nums. (*) returns 1. Supports arbitrary precision. See also: *" |
| 14:21 | TimMc | lambdanaut: It's part of the name. |
| 14:22 | semperos | lambdanaut: gives you 1.2-style auto-promoting arithmetic |
| 14:22 | TimMc | ,(name '*') |
| 14:22 | clojurebot | "*'" |
| 14:22 | lambdanaut | Oh ok |
| 14:22 | TimMc | &(type (+' 1 2)) |
| 14:22 | lazybot | ⇒ java.lang.Long |
| 14:23 | TimMc | &(+ Integer/MAX_VALUE 1) |
| 14:23 | lazybot | ⇒ 2147483648 |
| 14:23 | TimMc | &(+ Long/MAX_VALUE 1) |
| 14:23 | lazybot | java.lang.ArithmeticException: integer overflow |
| 14:23 | TimMc | &(+' Long/MAX_VALUE 1) |
| 14:23 | lazybot | ⇒ 9223372036854775808N |
| 14:25 | puredanger | re the previous discussion on better pages on clojure.org... IF you have a concrete page you would like to improve, then please write alternative text and file a jira. /core can bless and I'd be happy to do the work to change the page but I am lacking in time to do the writing itself. |
| 14:27 | puredanger | and if someone wants to take the initiative to hack on learn-clojure, I'd be happy to talk to Kyle (he's here in St. Louis) and I'm sure he'd be happy to have that happen. |
| 14:27 | puredanger | his original intention was to have it be that kind of resource but he is also busy running a company and other boring things like that :) |
| 14:28 | ibdknox | puredanger: I think I'd like to do that, but I'll need a bit of time before I'll be ready to really do the work |
| 14:28 | puredanger | ibdknox: I'll connect you |
| 14:28 | ibdknox | puredanger: great, thanks :) |
| 14:28 | puredanger | ibdknox: or did you mean clojure.org or learn-clojure ? |
| 14:29 | ibdknox | puredanger: learn-clojure |
| 14:30 | TimMc | Is there a way I can get '(1 2 3) to print as '(1 2 3) instead of (quote (1 2 3))? |
| 14:31 | TimMc | or (1 2 3) |
| 14:31 | ibdknox | pr |
| 14:31 | mdeboard | ,("'(1 2 3)") |
| 14:31 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn> |
| 14:31 | mdeboard | darn :( |
| 14:31 | ibdknox | ,(pr '(1 2 3)) |
| 14:31 | clojurebot | (1 2 3) |
| 14:32 | mdeboard | ,(prn "'(1 2 3)") |
| 14:32 | clojurebot | "'(1 2 3)" |
| 14:32 | mdeboard | :o |
| 14:32 | gfredericks | TimMc: printing source code? |
| 14:33 | ibdknox | ,(pr-str '(1 2 3)) |
| 14:33 | clojurebot | "(1 2 3)" |
| 14:33 | gfredericks | TimMc: you want a reader-macro-writer? :) |
| 14:33 | TimMc | gfredericks: Sort of. I am making an HTML page that shows the results of evaluating various functions on various bits of data. |
| 14:33 | gfredericks | I bet you want (fn [%] (foo %)) to be printed as #(foo %) too, don't you? |
| 14:33 | gfredericks | :) |
| 14:33 | TimMc | heh |
| 14:33 | TimMc | just the data, ma'am |
| 14:34 | kephale | ,(pr (clojure.string/replace (clojure.string/replace `'(1 2 3) "(quote " "'") "))" ")")) |
| 14:34 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: java.lang.ClassNotFoundException: clojure.string> |
| 14:34 | gfredericks | TimMc: the repl prints lists without quotes... |
| 14:34 | TimMc | yeah |
| 14:34 | kephale | : P |
| 14:34 | TimMc | https://github.com/timmc/seqs/blob/master/src/seqs/core.clj |
| 14:35 | licenser | ibdknox: I was told by swanky people you are clojurescript smrt? |
| 14:35 | TimMc | My data examples are at the top. |
| 14:35 | kephale | ,(use 'clojure.string) |
| 14:35 | clojurebot | WARNING: replace already refers to: #'clojure.core/replace in namespace: sandbox, being replaced by: #'clojure.string/replace |
| 14:35 | clojurebot | WARNING: reverse already refers to: #'clojure.core/reverse in namespace: sandbox, being replaced by: #'clojure.string/reverse |
| 14:35 | ibdknox | licenser: lol potentially |
| 14:35 | clojurebot | nil |
| 14:35 | kephale | ,(pr (clojure.string/replace (clojure.string/replace `'(1 2 3) "(quote " "'") "))" ")")) |
| 14:35 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox> |
| 14:35 | melipone | how do I find a character in a string? |
| 14:35 | kephale | err |
| 14:35 | ibdknox | uh oh |
| 14:35 | kephale | eep |
| 14:35 | abedra | ,(require '[clojure.string :as str]) |
| 14:35 | ibdknox | hiredman: clojurebot is toast |
| 14:35 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalStateException: replace already refers to: #'clojure.string/replace in namespace: sandbox> |
| 14:36 | technomancy | ibdknox: he should restart himself every 10m iirc |
| 14:36 | dakrone | melipone: (.indexOf "aoeu" "e") |
| 14:36 | ibdknox | haha that's an awesome failsafe |
| 14:36 | gfredericks | TimMc: my thought is that if you're displaying data, lists should be printed with bare parens, just like the repl does. |
| 14:36 | licenser | heh :) ibdknox I was just bothering technomancy about lein handling clojurescript deps he told me you're the go to gut - then he might just wanted to get rid of me :P |
| 14:37 | TimMc | gfredericks: I'd like to hide the implementation detail of seqs as lists. Maybe I should just use strings and eval. -.- |
| 14:37 | ibdknox | licenser: ah, well it actually handles cljs as jars just fine already |
| 14:37 | ibdknox | licenser: the only "tough" part is making sure that when you run the compiler, they're on your classpath |
| 14:37 | gfredericks | TimMc: that sounds like a separate issue... |
| 14:37 | gfredericks | why is '(1 2 3) any less of a list that (1 2 3)? |
| 14:37 | ibdknox | licenser: if you use cljs-watch it should just work |
| 14:38 | kephale | &(do (require '[clojure.string :as s]) (pr (s/replace (s/replace `'(1 2 3) "(quote " "'") "))" ")"))) |
| 14:38 | lazybot | ⇒ "'(1 2 3)"nil |
| 14:38 | gfredericks | s/that/than |
| 14:38 | licenser | ibdknox: that means we can just toss clojurescript libs in clojars and all is fine and fluffy? |
| 14:38 | TimMc | gfredericks: Because (1 2 3) does not evaluate to itself whereas [1 2 3] does. |
| 14:38 | ibdknox | licenser: yessir |
| 14:38 | gfredericks | TimMc: I thought it was data -- why would you be evaluating it? |
| 14:39 | licenser | ibdknox: technomancy did not promise too much when recommending you :P |
| 14:39 | TimMc | gfredericks: I want to show that (coll? (seq [1 2 3])) gives true -- and that involves being able to print "(seq [1 2 3])". |
| 14:40 | ibdknox | licenser: that's because I can't do much ;) |
| 14:40 | licenser | lol |
| 14:40 | gfredericks | TimMc: ah, okay, so it's not just data |
| 14:41 | TimMc | right |
| 14:41 | gfredericks | I'm not sure where I got that idea, I may have made it up. |
| 14:41 | TimMc | I may have said it. |
| 14:41 | gfredericks | if the problem is hard, invent something that simplifies it. |
| 14:47 | seancorfield | technomancy: why is the swank-clojure switch repl to namespace command bound to C-c M-p? that seems hard to type and C-c C-n seems more intuitive ('n' for namespace) and didn't seem bound to anything else (at least for me) |
| 14:49 | danlarkin | p is for package |
| 14:49 | danlarkin | from common lisp |
| 14:49 | technomancy | yep |
| 14:49 | callen | I prefer the Count, rather than learning the alphabet. |
| 14:50 | callen | THREE! AH AH AHHH |
| 14:50 | hiredman | looking for tests for syntax quote |
| 14:50 | hiredman | https://github.com/hiredman/syntax-quote/blob/master/test/syntax_quote/core_test.clj |
| 14:50 | callen | hiredman: for what? |
| 14:50 | hiredman | thats what I got, but I am sure there are cases that I have missed |
| 14:51 | callen | hiredman: what...is this? |
| 14:51 | callen | hiredman: what's with the backticks? |
| 14:56 | TimMc | "clojure's syntax quote as a macro" |
| 14:56 | TimMc | hiredman: Nested quoting. |
| 14:58 | TimMc | hiredman: You might also consider checking that gensym for the same symbol is different in different quotes. |
| 14:59 | seancorfield | danlarkin: thanx, that makes sense now |
| 15:00 | seancorfield | i've rebound it to C-c C-n which makes more sense for me with clojure (and is way easier to type / press!) |
| 15:01 | scottj | what % of the time do you go to the repl after doing C-c M-p? |
| 15:02 | seancorfield | you're going to tell me there's an easier way? (he asks, hopefully!) |
| 15:02 | scottj | well I have C-c C-S-z do C-c M-p and C-c C-z |
| 15:03 | jlf | seancorfield: C-c C-<letter> bindings are reserved for major modes, so that may get you into trouble later -- C-c <letter> bindings are reserved for users |
| 15:03 | jlf | see http://www.gnu.org/software/emacs/elisp/html_node/Key-Binding-Conventions.html |
| 15:07 | hiredman | seancorfield: https://gist.github.com/1355999 |
| 15:08 | seancorfield | jlf: good to know... but i find C-c <letter> harder to type than C-c C-<letter> - i already bound something else to other-window because C-x o was too awkward (i kept pressing C-x C-o by accident) |
| 15:10 | seancorfield | very nice hiredman thanx! |
| 15:12 | wwmorgan | how would you download an image from a URL to a file? The first 2 or 3 things I've tried either give me an empty file, or only download half the image. |
| 15:14 | hiredman | (clojure.java.io/copy (URL. ...) (clojure.java.io/file ...)) |
| 15:14 | hiredman | (that may or may not work) |
| 15:16 | drewr | (URL. ...) => (io/file "http://...") |
| 15:16 | drewr | in case that's easier |
| 15:17 | puredanger | Re the earlier discussion on improving Clojure docs, I blogged some ideas and links here: http://tech.puredanger.com/2011/11/10/improving-clojures-docs/ |
| 15:17 | wwmorgan | aha. You're using io/file for the destination, I was using io/output-stream. That might explain it |
| 15:19 | wwmorgan | OK I think I'm in business with (with-open [is (.openstream (java.net.URL. url))] (io/copy is (io/file dest))). Thanks hiredman, drewr, technomancy! |
| 15:20 | danlarkin | you can io/copy an url itself |
| 15:21 | drewr | danlarkin: you're right... io/copy promotes its args doesn't it |
| 15:22 | wwmorgan | darlarkin: can you? I tried a string URL and a java.net.URL. The first one just gave me the contents of the string itself and the second gave me a no multimethod error |
| 15:22 | danlarkin | yeah it's implemented as a bunch of multimethods so it munges its args until it's in a form that it can actually copy bytes |
| 15:22 | danlarkin | oh really? |
| 15:23 | danlarkin | well I know that the String defmethod copies the bytes of the string, but I thought there was a java.net.URL version |
| 15:23 | danlarkin | maybe there isn't |
| 15:23 | hiredman | there may not be one for http urls |
| 15:24 | wwmorgan | no dice on (io/copy (java.net.URL. "http://clojure.org/file/view/clojure-icon.gif") (io/file "/tmp/logo.gif")) |
| 15:24 | hiredman | might only work with file http urls |
| 15:24 | hiredman | er |
| 15:24 | hiredman | file urls |
| 15:25 | wwmorgan | but I can wrap the URL in io/input-stream and everything works again |
| 15:25 | hiredman | yeah, well |
| 15:26 | drewr | wwmorgan: don't bother with the URL constructor |
| 15:27 | drewr | try (io/file "http://...") |
| 15:27 | drewr | or io/reader |
| 15:27 | danlarkin | no no don't use io/reader if you don't want it sucked into a String |
| 15:28 | danlarkin | which ballses binary data |
| 15:28 | raek | use io/url if you want a url... |
| 15:28 | raek | and as danlarkin says, reader is for text, input-stream is for binary data |
| 15:29 | wwmorgan | I've got (io/copy (io/input-stream url) (io/file dest)), which works |
| 15:29 | drewr | danlarkin: that's right he's dealing with an image isn't he |
| 15:29 | drewr | wwmorgan: nice |
| 15:30 | wwmorgan | the final solution was entirely too simple for me to struggle for so long. Thanks again! |
| 15:30 | danlarkin | that will leak an inputstream, won't it? |
| 15:31 | wwmorgan | danlarkin: It would appear so. I'll use with-open |
| 15:31 | drewr | ah, io/file is only for File (derp) |
| 15:35 | seancorfield | emacs/lein workflow question: if you update project dependencies in project.clj, how do you go about running lein deps and refreshing your repl? |
| 15:36 | seancorfield | right now i'm using an eshell to run lein deps, then running clojure-jack-in (and killing the previous process) |
| 15:36 | technomancy | seancorfield: you should be able to use pomegranate for that, but for some reason it doesn't work with swank |
| 15:36 | technomancy | open issue, for now just re-jack-in |
| 15:36 | technomancy | if you set :checksum-deps true in project.clj you don't need to run deps manually |
| 15:37 | seancorfield | ah, right, i remember reading about that the other day |
| 15:37 | seancorfield | is there a page that documents all of the stuff that can appear in project.clj? |
| 15:37 | technomancy | lein help sample |
| 15:39 | seancorfield | ah good point technomancy thanx |
| 15:40 | technomancy | sure |
| 15:40 | seancorfield | holy %$@& that's a lot of options! |
| 15:41 | duck1123 | seancorfield: it might be easier to read on the github page |
| 15:42 | technomancy | lein help sample > #<buffer sample.clj> # C-x b sample, M-x clojure-mode |
| 15:42 | technomancy | if you're in eshell |
| 15:42 | technomancy | and you want highlighting |
| 15:50 | _ulises | I suppose nobody here knows how to reset ones clojars password? |
| 15:52 | melipone | ,(.indexOf "aeoa" "e") |
| 15:52 | clojurebot | 1 |
| 15:53 | melipone | ,(.indexOf "aeoa" "a") |
| 15:53 | clojurebot | 0 |
| 15:53 | _ulises | sod it |
| 15:56 | technomancy | _ulises: I think you need to contact alex osborne |
| 15:56 | _ulises | technomancy: thanks. I've registered again. I'll let him know anyway to avoid username pollution |
| 16:00 | TimMc | $mail drguildo I'm writing up an explanation of seqs and colls, starting here: https://github.com/timmc/seqs (just playing around so far) |
| 16:00 | lazybot | Message saved. |
| 16:17 | _ulises | eep |
| 16:18 | gfredericks | _ulises: you went to the profile page and it wouldn't work? |
| 16:18 | _ulises | gfredericks: I couldn't log in as I didn't remember my password |
| 16:18 | gfredericks | oh. haha. of course. |
| 16:18 | duck1123 | keepass |
| 16:19 | _ulises | :) |
| 16:27 | gfredericks | duck1123: beanbag? |
| 16:28 | gfredericks | duck1123: also don't want the name to imply that it has anything to do with EJBs and spring and all that :/ |
| 16:28 | duck1123 | that could work. Took me a second to figure out wft you were talking about though |
| 16:29 | gfredericks | I know :) |
| 16:29 | gfredericks | maybe a name centered around class generation |
| 16:30 | gfredericks | settlers. |
| 16:30 | brehaut | gfredericks: ##(apply str "lib-" (repeatedly 4 #(rand-int 10))) have you forgotten your own rules already‽ |
| 16:30 | lazybot | ⇒ "lib-2367" |
| 16:30 | gfredericks | lib-2367 it is. |
| 16:31 | gfredericks | "The 2367 is for the future!" |
| 16:33 | gfredericks | brehaut: do you have a keyboard shortcut for the interrobang or something? |
| 16:33 | brehaut | gfredericks: os x text replacement |
| 16:33 | gfredericks | slick. |
| 16:44 | klauern | in leiningen, if you've defined a project as 'foo', how are the .clj files and (ns) definitions parsed under the src/ directory? |
| 16:45 | klauern | can I have a (ns bar) inside of the src/ directory even if the project is 'foo' ? |
| 16:45 | klauern | can I have a src/bar/thing.clj file or do I have to keep everything under src/foo ? |
| 16:45 | brehaut | klauern: im pretty sure the namespaces provided by the project are completely seperate to the project (and thus package) name |
| 16:45 | klauern | ok |
| 16:46 | klauern | I keep tripping up with the REPL because I use one leiningen project for alot of scratch files and they don't follow the same structure as the project |
| 16:46 | klauern | I'm still learning, so I'll have a foo.clj file in the src/ directory and not know why I can't (require 'foo) properly |
| 16:47 | brehaut | does it have (ns foo) in it? |
| 16:47 | klauern | that's what I'm still experimenting with |
| 16:47 | technomancy | clojurebot: single-segment namespaces? |
| 16:47 | clojurebot | single-segment namespaces is unsupported. (foo instead of foo.core) they may work in a few circumstances, but you shouldn't rely on them. |
| 16:48 | hiredman | is?! |
| 16:48 | brehaut | english must be clojurebot's second language |
| 16:49 | hiredman | ~english |
| 16:49 | clojurebot | English is the official language of the universe |
| 16:50 | brehaut | i expect us in color and the correct spelling of aluminium from now on |
| 16:51 | technomancy | bring it on |
| 16:51 | gfredericks | duck1123: https://github.com/fredericksgary/lib-2367 |
| 16:51 | brehaut | technomancy: no apropos comic? |
| 16:52 | brehaut | gfredericks: lol :) |
| 16:52 | technomancy | oh snap |
| 16:52 | brehaut | technomancy: is the queens english your kryptonite? |
| 16:52 | technomancy | brehaut: nah I'm all about lifts and carparks and so forth |
| 16:53 | technomancy | just none of my comic authors appear to be |
| 16:53 | brehaut | stalemate then |
| 16:54 | brehaut | technomancy: what would you call a carpark if you didnt call it a carpark? |
| 16:54 | technomancy | brehaut: "parking lot" ಠ_ಠ |
| 16:54 | technomancy | it's pretty lame |
| 16:54 | brehaut | yeah |
| 16:56 | seancorfield | technomancy: just saw that eshell trick of redirecting output to a buffer! awesome! i seem to learn something new about emacs every day that makes it even more powerful and cool :) |
| 16:56 | gfredericks | I once talked to an Argentine who thought it was completely ridiculous that we didn't have a word for "traffic light". |
| 16:57 | technomancy | you can pipe to elisp functions too |
| 16:58 | seancorfield | technomancy: oh boy... my brain will explode :) |
| 16:58 | seancorfield | just learned how to hide join / part messages in erc too (thanx google) |
| 16:58 | technomancy | s'okay, clojurebot can usually clean up the mess |
| 16:59 | brehaut | how many of you are at the conj at the moment? |
| 17:00 | gfredericks | I doubt anyone will be bothered by my taking the group name 'lib-2367' on clojars. |
| 17:00 | callen | I'm at work. |
| 17:00 | callen | ya bums. |
| 17:01 | technomancy | brehaut: M-| wc on /names in #clojure/conj says 21 |
| 17:01 | seancorfield | at the conj, listening to stuart halloway on "power" |
| 17:01 | brehaut | technomancy: are you trying to expand my mind with emacs tricks again? |
| 17:01 | technomancy | couldn't hurt |
| 17:02 | brehaut | technomancy: very soon im going to have more emacs tricks pinned to my wall than wall |
| 17:03 | seancorfield | brehaut: i'd rather have them "pinned" to my brain... but there may not be enough room :( |
| 17:04 | brehaut | seancorfield: likewise. they keep falling out of my mind |
| 17:04 | seancorfield | maybe i just need more pins... |
| 17:21 | callen | seancorfield: get a voodoo doll. |
| 17:21 | callen | seancorfield: someone, somewhere, will start learning Clojure. Painfully. |
| 17:21 | callen | seancorfield: "BWAHAHAHA, HOW YOU LIKE MY NAMESPACE NOW?!" |
| 17:24 | callen | damn, tough crowd. |
| 17:24 | callen | y'all some haters. |
| 17:25 | technomancy | everybody's busy watching the conj talk |
| 17:25 | callen | technomancy: rink? |
| 17:25 | mjwhitt | and it's a good talk |
| 17:25 | callen | RINK |
| 17:26 | technomancy | http://clojure-conj.org/schedule#halloway |
| 17:26 | callen | that is *not* a video. |
| 17:26 | callen | :( |
| 17:26 | brehaut | where did this assumption that there would be live streams come from? |
| 17:26 | callen | I assumed a lack of communism. |
| 17:26 | callen | clearly I should've quit my job and shown up. |
| 17:27 | aperiodic | are they being filmed for later uploading? |
| 17:27 | michael_campbell | yes |
| 17:27 | aperiodic | *all* of them? |
| 17:27 | callen | well then. |
| 17:27 | callen | I will asynchronously process the talks. |
| 17:28 | michael_campbell | Camera's been going since the first talk, near as I can see. |
| 17:28 | aperiodic | awesome |
| 17:28 | callen | <3 |
| 17:28 | duck1123 | it's a minor consolation |
| 17:28 | aperiodic | thanks to whomever's in charge of that |
| 17:28 | aperiodic | better than nothing! |
| 17:29 | callen | BY FAR |
| 17:29 | duck1123 | oh yes, thank you to whoever is filming, I still really wish I was there |
| 17:30 | michael_campbell | talks are over for the day; time to go drink. |
| 17:31 | erldave | I have a basic question on function arguments: |
| 17:31 | erldave | (defn another-fn [& {:keys [id] }] {:ty :link :id id }) |
| 17:31 | erldave | (defn add-link [& args] (println "Answer of another fn" (another-fn args))) |
| 17:31 | erldave | (add-link :a-ns "ns1" :id "testlink" :from-obj rq :to-obj qs) |
| 17:31 | erldave | why doesn't the above work? |
| 17:32 | erldave | I assume is because the variable args in add-link is not of type map any more |
| 17:32 | erldave | how should I solve this? |
| 17:32 | brehaut | erldave: add-link collects its arguments as a seq |
| 17:32 | aperiodic | args is a sequence contianing all the arguments passed to add-link |
| 17:32 | brehaut | erldave: but another-fn wants a map |
| 17:32 | erldave | yes, so how would I forward the call on? |
| 17:32 | brehaut | apply |
| 17:33 | erldave | how do I "gather" the map into a variable so I can call another-fn ? |
| 17:33 | brehaut | but you might want to reconsider you API design |
| 17:33 | duck1123 | (apply another-fn args) |
| 17:33 | erldave | thanks |
| 17:34 | erldave | apply - perfect, thanks |
| 17:40 | nickmbailey | anyone around use leiningen and also build debian packages of their projects? |
| 17:41 | nickmbailey | i'm not extremely well versed in either debian packaging or maven but the two refuse to play nice |
| 17:41 | nickmbailey | basically 'fakeroot lein deps' refuses to work |
| 17:42 | jodaro | isn't there a lein-deb plugin? |
| 17:42 | duck1123 | I was just thinking the same thing |
| 17:43 | jodaro | https://github.com/travis/lein-deb |
| 17:43 | nickmbailey | hmm interesting |
| 17:43 | jodaro | never used it, but you might take a look |
| 17:43 | nickmbailey | i doubt i'll be able to use it but it certainly might help me figure out whats going on |
| 17:43 | nickmbailey | thanks |
| 17:43 | duck1123 | In my experience, using lein with anything other than the way it says in the readme is destined to fail |
| 17:44 | jodaro | i haven't built debian packages before but our ops guys require rpms for everything |
| 17:44 | jodaro | and i've been able to get most wacky build tools to deal with it since all you really need is to be able to run a shell command |
| 17:45 | nickmbailey | yeah i have no trouble building rpms |
| 17:45 | nickmbailey | debian packages have so much fancy tooling around them though |
| 17:45 | duck1123 | huzzah! My last test passes. I have now officially replaced clj-record with Korma in my work project |
| 17:45 | jodaro | nice |
| 17:45 | brehaut | duck1123: awesome :) |
| 17:46 | jodaro | ibdknox will be proud of you |
| 17:46 | duck1123 | although I'm really starting to think there might still be room for a level of abstraction on top of korma |
| 17:50 | brehaut | duck1123: there probably is |
| 17:51 | brehaut | duck1123: something like django's admin + south on top of korma would satisfy a particular niche quite nicely |
| 17:51 | duck1123 | brehaut: doubtful there's much yet |
| 17:52 | duck1123 | I'd like to see something where the queries return the maps back as records, that way I could extend protocols and dispatch on types. I'm sure I can do it with the :transform flag, just haven't gotten there yet |
| 17:53 | brehaut | duck1123: ive been quite happy with multimethods and plain maps from couchdb for my site |
| 17:54 | brehaut | i can see the value in protocols, but i think id want a much more involved datamodel than most the sorts of websites i buld |
| 17:55 | duck1123 | how do you determine the type of the map? I had a fork of clj-record a couple of years back (that old) that attached metadata to the records, and I use karras for my mongodb work because it gives me a record to use |
| 17:55 | brehaut | duck1123: a combination of a :type member and keys |
| 17:56 | TimMc | $mail drguildo I moved it to https://github.com/timmc/seqs-and-colls |
| 17:56 | lazybot | Message saved. |
| 18:01 | duck1123 | I wrote this big extensive macro system that would allow me to dispatch a record based on the combination of it's type, the response format used, and the transport protocol and then stopped using it |
| 18:01 | brehaut | oh |
| 18:01 | brehaut | :/ |
| 18:02 | brehaut | duck1123: one other option that might be useful is core.match |
| 18:02 | duck1123 | https://github.com/duck1123/ciste look at "sections" |
| 18:03 | brehaut | give me a minute, i dont want to miss the next book depository deail |
| 18:04 | duck1123 | There was one place I tried to use core.match, then I learned it didn't work that way. It's staying on my classpath though. Just looking for a good place to use it |
| 18:07 | brehaut | back in a bit; lunch |
| 18:13 | callen | brehaut: hawaii? |
| 18:24 | brehaut | callen: new zealand |
| 18:39 | duck1123 | are there any good examples of libraries that use macros to define functions and also change the metadata? (in my case, arglist) |
| 18:39 | duck1123 | I seem to be missing something |
| 19:22 | TimMc | http://www.brainonfire.net/files/seqs-and-colls/seqs-and-colls.html |
| 19:25 | TimMc | (sorry, not a response to you, duck1123) |
| 19:25 | TimMc | $mail drguildo http://www.brainonfire.net/files/seqs-and-colls/main.html |
| 19:26 | lazybot | Message saved. |
| 19:53 | gtrak | is there a way to seek into java code from slime/swank and emacs? |
| 19:53 | napping | I don't think there is |
| 19:54 | napping | I was looking at things a bit and there are possibly appropriate slime/swank messages which the clojure mode doesn't implement |
| 19:57 | napping | Actually, it's the disassemble message which isn't implemented, but could perhaps return bytecode for anything |
| 19:59 | napping | For writing some small Swing code it seems inner defs is convenient for naming subexpressions: http://pastebin.com/NFJ8RM6H I'd like to avoid using def, but it seems I'd need to hardcode a lot of the allowed forms to get similar results with a macro. |
| 20:00 | napping | Actually, it may only be the add method that other widgets can be nested inside |
| 20:46 | tensorpudding | hmm, running massive programs in swank which use up 1 gb of memory is a bad idea |
| 20:46 | tensorpudding | because java won't free that memory until you kill swank, it seems |
| 20:49 | brehaut | java never frees memory that its acquired from the OS |
| 20:49 | tensorpudding | is it possible to tune the jvm to not take so much memory |
| 20:49 | brehaut | yes |
| 20:50 | brehaut | lein has a project property |
| 20:50 | brehaut | :jvm-opts |
| 20:51 | brehaut | you can use that to pass a max heap size to use which will cause the collector to kick more readily and limit the total growth |
| 20:51 | tensorpudding | i didn't use lein that i know of, i just used clojure-mode to compile a piece of source code, which suddenly started running the program |
| 20:51 | brehaut | if you are using swank you are likely using either lein or cake |
| 20:53 | tensorpudding | i don't think i had to install lein to install clojure mode |
| 20:54 | brehaut | you dont need to use clojure mod |
| 20:54 | brehaut | e |
| 20:54 | brehaut | but clojure mode does not evaluator your code for you |
| 20:54 | brehaut | perhaps you are using inferior lisp mode? |
| 20:55 | tensorpudding | no |
| 20:55 | tensorpudding | a moment |
| 20:55 | tensorpudding | oh wait, it is swank-clojure |
| 20:56 | tensorpudding | i was running a slime command to compile it |
| 20:56 | tensorpudding | of course... |
| 20:57 | brehaut | if you use -Xmx256m as a :jvm-opt then the heap size will be limited to 256 mb, causing the collector to be more aggressive |
| 20:59 | tensorpudding | i don't know how to configure the options sent to java, to be honest |
| 20:59 | brehaut | brb. rubbernecking |
| 21:00 | tensorpudding | well, it uses lein jack-in |
| 21:00 | tensorpudding | so it's probably configurable through lein |
| 21:03 | tensorpudding | though i don't see how |
| 21:04 | tensorpudding | oh, the LEIN_JVM_OPTS variable maybe |
| 21:04 | brehaut | tensorpudding: as i said earlier, you can set the java options though your lein project file with the :jvm-opts key. it takes a vector of strings. |
| 21:04 | tensorpudding | this particular instance didn't involve a project |
| 21:04 | tensorpudding | there was no project.clj file here |
| 21:04 | tensorpudding | i just compiled a .clj file |
| 21:04 | tensorpudding | and sent it to swank |
| 21:05 | tensorpudding | well, i mean, there was the project that i used to jack-in, but that wasn't where the code that i compiled was |
| 21:05 | brehaut | the project that you used to jack in is the important part |
| 21:06 | tensorpudding | meh |
| 21:06 | tensorpudding | i suppose so |
| 21:09 | leo2007 | does the reference on clojure.org provide any more info than the doc-strings src? |
| 21:11 | brehaut | leo2007: it varies; often it has more conceptual or rational type docs, if not concrete examples |
| 21:11 | brehaut | leo2007: clojuredocs.org is pretty solid for examples though |
| 21:11 | brehaut | (where they exist) |
| 21:11 | ajsharp | so i'm a complete clojure newb -- am i heading down a sadomasochistic path by trying to program clojure in vim? |
| 21:12 | gfredericks | ajsharp: there's an embarrassed but significant minority of us. |
| 21:12 | ajsharp | gfredericks: good to know :) |
| 21:12 | gfredericks | I mostly try to get by by not thinking about what I'm missing. |
| 21:12 | ajsharp | sounds like emacs and SLIME is how the hardcore dudes work in clojure |
| 21:12 | tensorpudding | it's a good excuse to try emacs out |
| 21:13 | tensorpudding | if you haven't yet |
| 21:13 | ajsharp | tensorpudding: also good to know |
| 21:13 | tensorpudding | though getting started through swank/slime is drinking from a big firehose |
| 21:13 | gfredericks | ajsharp: I also reassure myself by noting that nearly half of the issues brought up in #clojure are people having trouble with their swanks and their swines and their thing-modes. |
| 21:13 | tensorpudding | slime |
| 21:13 | tensorpudding | not swine |
| 21:13 | ajsharp | the thing that always threw me about emacs was constantly keeping my pinky on the ctrl key, but i don't want to get into a vim / emacs discussion... |
| 21:14 | tensorpudding | i totally would find emacs unusable if i didn't bind caps lock as control a while ago |
| 21:14 | tensorpudding | it helps in general |
| 21:15 | ajsharp | tensorpudding: yea, i do the same already |
| 21:15 | ajsharp | actually, i bind it as escape, but i use it exclusively for vim |
| 21:15 | ajsharp | anyway |
| 21:15 | ajsharp | i also have very limited experience with the jvm, so that said, what is nailgun? |
| 21:16 | brehaut | ajsharp: totally use vim if you know it |
| 21:17 | ajsharp | brehaut: yea, i'm definitely going to start with vim, and maybe i'll give emacs a try at some point before i get too deep |
| 21:17 | brehaut | ajsharp: i have heard good things about evil-mode for vim expats in emacs land |
| 21:17 | brehaut | (which is apparently better than vyper?) |
| 21:18 | ajsharp | haha |
| 21:18 | ajsharp | that's awesome -- evil-mode |
| 21:18 | ajsharp | vim for emacs |
| 21:18 | ajsharp | so nailgun is a clojure development server? |
| 21:25 | gfredericks | nailgun is a generic jvm server |
| 21:25 | gfredericks | exists to circumvent the jvm startup time |
| 21:31 | ajsharp | gfredericks: oh ok, cool, thanks |
| 21:34 | leo2007 | brehaut: thanks for that. |
| 21:35 | leo2007 | why (seq? [1 2 3]) is false? |
| 21:36 | brehaut | leo2007: many collections that are sequential are not seqs |
| 21:36 | brehaut | ,(map (juxt seq? sequential) [[] () {} #{}]) |
| 21:36 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: sequential in this context, compiling:(NO_SOURCE_PATH:0)> |
| 21:37 | brehaut | ,(map (juxt seq? sequential?) [[] () {} #{}]) |
| 21:37 | clojurebot | ([false true] [true true] [false false] [false false]) |
| 21:37 | leo2007 | brehaut: thanks again. |
| 21:38 | brehaut | leo2007: a seq is a particular abstraction; you hardly ever use seq? in real code, but you might use coll? |
| 21:38 | leo2007 | brehaut: I see. |
| 21:39 | brehaut | leo2007: and to complete this pile of noise, vectors while sequential are implemented use trees (well, tries) internally |
| 21:41 | TimMc | brehaut: I'm trying to throw together a page explaining colls and seqs in clojure: http://www.brainonfire.net/files/seqs-and-colls/main.html |
| 21:42 | brehaut | TimMc: excellent |
| 21:42 | TimMc | Needs a lot more text and organization. |
| 21:44 | brehaut | and perhaps discussion of equality partitions? |
| 21:44 | TimMc | Good point! |
| 21:50 | aperiodic | wait, so vectors have lg(n) access time? |
| 21:50 | TimMc | base 32, I think |
| 21:51 | gfredericks | aperiodic: that means yes |
| 21:51 | aperiodic | well, that's not too bad |
| 21:51 | klauern | Are there any tips or strategies for making Clojure wrappers around Java libs? |
| 21:52 | klauern | In particular, how to do you wrap a method that returns an instance of a type or List<T> of something? |
| 21:56 | aperiodic | wait, is a vector just a map with integer keys? |
| 21:56 | brehaut | aperiodic: roughly |
| 21:56 | brehaut | it is different |
| 21:56 | aperiodic | how so? |
| 21:57 | brehaut | ,(assoc {} 3 1) |
| 21:57 | gfredericks | {1 :foo, 10000000 :bar} would not go well as a vector |
| 21:57 | clojurebot | {3 1} |
| 21:57 | brehaut | ,(assoc [] 3 1) |
| 21:57 | clojurebot | #<IndexOutOfBoundsException java.lang.IndexOutOfBoundsException> |
| 21:58 | brehaut | vectors are required to have contigous keys |
| 21:58 | aperiodic | okay |
| 21:58 | brehaut | and you conj onto a vector with a single item, but you conj onto a map with a pair |
| 21:58 | gfredericks | aperiodic: I think most people associate them more closely with lists than with maps. |
| 21:59 | aperiodic | so it's a map with tight restrictions on the keys, and presumably some performance benefits resulting from that? |
| 21:59 | brehaut | yes |
| 21:59 | aperiodic | gfredericks: i always thought maps were more or less arrays (constant-access) |
| 22:00 | brehaut | klauern: timmc is right about type erasure; List<T> is a java langauge ficton that doesnt really exist in the JVM |
| 22:00 | gfredericks | in terms of performance you could maybe say that, but certainly having arbitrary objects for keys distinguishes maps from arrays rather drastically |
| 22:00 | napping | klauern: can you seq it? |
| 22:00 | aperiodic | s/maps/vecs/ |
| 22:01 | aperiodic | brain fart |
| 22:01 | klauern | I would think so, but I'm new to Clojure, so I don't know how well clojure understands lists in Java |
| 22:01 | napping | It seems to work |
| 22:01 | gfredericks | aperiodic: and of course in any case the persistent-immutable thing is definitely not very array-like |
| 22:01 | gfredericks | pardon me if you're well familiar with that and I'm just nit-picking |
| 22:02 | klauern | I would think that returning whatever the Java call created is bad form as far as Clojure is concerned, and it'd be better to weave in a more Clojuresque return type |
| 22:03 | napping | klauern: Call seq on the result |
| 22:03 | napping | maybe |
| 22:03 | brehaut | klauern: java interop is first class in clojure; dealing with java objects is not dirty |
| 22:04 | klauern | ah |
| 22:04 | napping | If it's just a collection like a list or something, converting it might be nice, but if it's more useful than that, you might as well expose it |
| 22:04 | aperiodic | gfredericks: i mean, i know they're not arrays in some very important respects, but my rough mental categorization was seq -> linked list, vec -> array, map -> hashtable |
| 22:05 | brehaut | ,(seq (doto (java.util.ArrayList.) (.add :a) (.add :b))) |
| 22:05 | clojurebot | (:a :b) |
| 22:05 | napping | unless you are going to a lot of trouble to rewrite a nicer interface. I guess you could say that's what clojure collections are already |
| 22:05 | brehaut | ,(map inc (doto (java.util.ArrayList.) (.add 2) (.add 1))) |
| 22:05 | clojurebot | (3 2) |
| 22:05 | klauern | Right now I'm hoping to learn Clojure idioms and just get a better feel for the language |
| 22:06 | klauern | if the library I create ends up being useful at the end, all the better I suppose |
| 22:06 | gfredericks | aperiodic: that's a decent rough mental categorization. |
| 22:06 | aperiodic | gfredericks: so it was just a bit weird to hear that vecs are actually tries |
| 22:07 | aperiodic | i might wanna look at the implementation to make sure i'm not doing anything too stupid with them |
| 22:08 | brehaut | ,(map #(java.util.Collections/frequency % 1) [[] [1] [2 1 0 1 0 3]]) |
| 22:08 | clojurebot | (0 1 2) |
| 22:08 | brehaut | klauern: ^ as you can see, clojures operations know about java objects and clojrues collections fullfil the appropriate interfaces for java operations |
| 22:09 | klauern | That's good to know |
| 22:09 | gfredericks | aperiodic: that's because of the persistent-immutable part |
| 22:10 | brehaut | aperiodic: it means they are more naturally paralizable |
| 22:10 | gfredericks | else it'd be hard to have good performance for "changing" vectors |
| 22:10 | brehaut | aperiodic: and are cheaper for internal updates |
| 22:10 | aperiodic | yeah, that makes sense, because otherwise the entire vector would have to be copied whenever a single location was updated |
| 22:11 | aperiodic | which would be less than ideal |
| 22:11 | TimMc | brehaut: I got a start on equality partitions. Anything beyond the 4 coll types to cover? |
| 22:11 | brehaut | TimMc: interop ;) ? |
| 22:11 | TimMc | urgh |
| 22:12 | brehaut | i wouldnt worry about that |
| 22:12 | TimMc | I could mention the interfaces. |
| 22:12 | TimMc | There's more basic stuff to cover first. |
| 22:12 | brehaut | TimMc: i think theres only three equality partitions though, so just those 4 should be fine |
| 22:12 | brehaut | (sequentials, maps, sets right?) |
| 22:12 | TimMc | yeah |
| 22:13 | brehaut | you might want to note that sorted or not isnt relevate to identity ? |
| 22:13 | brehaut | but meta data is? |
| 22:14 | brehaut | err isnt |
| 22:14 | duck1123 | metadata does not impact equality |
| 22:15 | brehaut | thats what i was trying to say, but failed at completely |
| 22:16 | TimMc | ,(= (sorted-set) (hash-set)) |
| 22:16 | clojurebot | true |
| 22:16 | gfredericks | ,(= [] #{}) |
| 22:16 | clojurebot | false |
| 22:17 | TimMc | gfredericks: This is the article I am working on: http://www.brainonfire.net/files/seqs-and-colls/main.html |
| 22:17 | gfredericks | ,(= () (new java.util.ArrayList)) |
| 22:17 | clojurebot | true |
| 22:17 | aperiodic | so, let's say that i wanted a thread-local mutable array in clojure, for doing something like image processing (so the array's size would make the log_32 factor non-trivial) |
| 22:17 | aperiodic | what would i use? |
| 22:17 | brehaut | gfredericks: new? thats old school right? |
| 22:17 | gfredericks | aperiodic: a transient vector? |
| 22:18 | brehaut | aperiodic: for image processing? use an array |
| 22:18 | gfredericks | aperiodic: or just an array, if you want |
| 22:18 | gfredericks | brehaut: what's old school about it? |
| 22:18 | brehaut | gfredericks: its from before the (Constructor.) notation? |
| 22:19 | gfredericks | I like new. Constructor. looks like a typo. |
| 22:19 | gfredericks | it's just hiding there. |
| 22:19 | aperiodic | likewise |
| 22:19 | gfredericks | verbs go up front! |
| 22:19 | aperiodic | so easy to miss if you're not careful |
| 22:20 | aperiodic | and "new " is only 4 more chars |
| 22:20 | gfredericks | I don't want my eye to have to wander to the end of a long qualified classname just to figure out what we're doing with it |
| 22:20 | gfredericks | aperiodic: 3, since you save the "." |
| 22:21 | gfredericks | dang whippersnappers. |
| 22:21 | brehaut | i find the the lumbering CapitalCamelNames usually is sufficient to spot a constructor ;P |
| 22:21 | gfredericks | brehaut: vs static field access? |
| 22:21 | brehaut | but that always has a /fieldName |
| 22:21 | gfredericks | yeah but I can't tell that till I've gotten to the end of the thing |
| 22:21 | brehaut | i suspect this is my python roots showing through |
| 22:23 | brehaut | aperiodic: http://dosync.posterous.com/lispers-know-the-value-of-everything-and-the |
| 22:23 | leo2007 | Is -main special? I have seen something like (def -main start-repl) in a few projects? |
| 22:23 | brehaut | leo2007: - is the default prefix for genclass methods |
| 22:24 | brehaut | -main the is compiled to a public static main method of the genclass class |
| 22:25 | aperiodic | brehaut: handy, thanks! |
| 22:25 | brehaut | (which if you are unfamilar with the jvm, is the entry point for a startup class) |
| 22:25 | brehaut | aperiodic: dnolen's posterous is choc full of interesting stuff |
| 22:26 | aperiodic | brehaut: bookmarked |
| 22:26 | aperiodic | (inc brehaut) |
| 22:26 | gfredericks | (dec lazybot) |
| 22:26 | lazybot | You want me to leave karma the same? Fine, I will. |
| 22:27 | aperiodic | what a bum |
| 22:27 | gfredericks | lazybot: get a job. |
| 22:27 | brehaut | raynes really needs to fix that |
| 22:28 | aperiodic | &(inc 3) |
| 22:28 | lazybot | ⇒ 4 |
| 22:28 | TimMc | ,(inc brehaut) |
| 22:28 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: brehaut in this context, compiling:(NO_SOURCE_PATH:0)> |
| 22:28 | brehaut | lol |
| 22:28 | gfredericks | &(let [brehaut (rand-int 10)] (inc brehaut)) |
| 22:28 | lazybot | ⇒ 9 |
| 22:28 | aperiodic | is it a problem with karma in particular? |
| 22:28 | Raynes | Yeah, somewhere along the line the karma plugin got broken. Don't know why, don't know how. |
| 22:28 | brehaut | yeah, karma doesnt run through the evaluator |
| 22:29 | aperiodic | right |
| 22:29 | Raynes | But if somebody bitches about it after the conj, I'll definitely fix it. |
| 22:29 | brehaut | Raynes: i read through your slides; looked good |
| 22:29 | brehaut | great cats |
| 22:29 | Raynes | Heh |
| 22:29 | aperiodic | i had a problem trying to setup lazybot the other week where it would only respond to evaluation commands |
| 22:29 | aperiodic | everything else it would ignore |
| 22:30 | Raynes | aperiodic: I bet you were mistaking your evaluation prefix with your command prefix. |
| 22:30 | Raynes | aperiodic: Can I see your ~/.lazybot/config.clj file? Minus passwords and such. |
| 22:31 | aperiodic | Raynes: sure, one sec |
| 22:32 | brehaut | karma raynes |
| 22:33 | brehaut | and i realise ive forgotten the command prefix |
| 22:34 | TimMc | $karma Raynes |
| 22:34 | lazybot | Raynes has karma 0. |
| 22:34 | TimMc | $inc Raynes |
| 22:34 | TimMc | guess not |
| 22:34 | brehaut | $karma amalloy |
| 22:34 | lazybot | amalloy has karma 0. |
| 22:34 | brehaut | yeah its really borken |
| 22:34 | TimMc | hah |
| 22:35 | brehaut | maybe amalloy amassed so much karma that the bot couldnt track it any longer |
| 22:35 | aperiodic | Raynes: https://gist.github.com/1357108 |
| 22:35 | gfredericks | Raynes: are the old karmas forgotten? If so, I'm going to stop being helpful. |
| 22:36 | Raynes | I'm getting it is a communication-with-database problem. |
| 22:36 | Raynes | s/getting/thinking. |
| 22:36 | brehaut | Raynes: signs do point that way |
| 22:36 | gfredericks | Okay. I will tentatively continue trying to be helpful. |
| 22:36 | Raynes | https://github.com/flatland/lazybot/blob/develop/src/lazybot/plugins/karma.clj if anyone wants to take a look and be super cool and try to fix it themselves before I get a chance. |
| 22:37 | brehaut | Raynes: switched from mongo to dev null? |
| 22:37 | Raynes | Also, update congomongo while you're at it. |
| 22:37 | Raynes | ;) |
| 22:37 | Raynes | aperiodic: One sec. |
| 22:37 | aperiodic | Raynes: also, when i ran &(doc foo), all the "s"s in the docstring were removed. i have no idea how |
| 22:37 | Raynes | &(doc slurp) |
| 22:37 | lazybot | ⇒ "([f & opts]); Opens a reader on f and reads all its contents, returning a string. See clojure.java.io/reader for a complete list of supported arguments." |
| 22:37 | aperiodic | they were replaced with spaces |
| 22:38 | aperiodic | i felt crazy |
| 22:38 | Raynes | Are you using the latest from the develop branch on github.com/flatland/lazybot |
| 22:38 | Raynes | ? |
| 22:38 | Raynes | Like, the very latest? I seem to recall fixing that 100 years ago. |
| 22:38 | leo2007 | brehaut: thanks |
| 22:38 | Raynes | (a couple of weeks ago) |
| 22:39 | aperiodic | Raynes: not the very latest, no |
| 22:39 | Raynes | Updating ought to fix that 's' problem. |
| 22:39 | Raynes | So, how were you trying to evaluate commands? |
| 22:39 | Raynes | Show me an example |
| 22:40 | aperiodic | Raynes: it was at a2ab9d |
| 22:41 | aperiodic | Raynes: "$fortune" |
| 22:41 | Raynes | aperiodic: Look at the ':prepends' key in your config. |
| 22:41 | Raynes | Those are what the bot will respond to normal commands for. |
| 22:41 | aperiodic | ah, so that's what that is |
| 22:41 | Raynes | By default, that'd be @. |
| 22:41 | Raynes | I need to rename that to 'prefixes'. |
| 22:42 | Raynes | I don't think prepend is a word. |
| 22:42 | aperiodic | i think it is a word, but it's not obvious what it was for |
| 22:42 | Raynes | Agreed. |
| 22:42 | aperiodic | thanks for the help! |
| 22:42 | Raynes | No problem. |
| 22:42 | Raynes | :) |
| 22:43 | Raynes | Also, lazybot recently went under heavy renovation, including a move to 1.3. If any of the plugins don't work, let me know by creating an issue on the Github page. |
| 22:43 | Raynes | Night #clojure! |
| 22:43 | brehaut | later Raynes |
| 22:44 | aperiodic | gnight! |
| 22:51 | leo2007 | If I change project.clj do I need to restart swank? |
| 22:51 | brehaut | leo2007: it might depend on what the change is, but i suspect so? |
| 22:52 | leo2007 | I just changed :dev-dependencies |
| 22:52 | brehaut | then yes |
| 22:59 | gfredericks | ,(:foo :bar :baz) |
| 22:59 | clojurebot | :baz |
| 23:02 | brehaut | lol |
| 23:04 | gfredericks | clojure: it just works. |
| 23:05 | gfredericks | (def identity (partial :foo :bar)) |
| 23:05 | brehaut | classic |
| 23:05 | brehaut | keywords also double as false then |
| 23:06 | gfredericks | how so? |
| 23:06 | brehaut | in lambda calc true is (fn [t _] t) and false is (fn [_ f] f) |
| 23:07 | gfredericks | aah |
| 23:07 | gfredericks | not if you pass them a map |
| 23:07 | brehaut | hah |
| 23:07 | brehaut | true |
| 23:07 | gfredericks | (def true (comp first list)) (def false (comp second list)) |
| 23:08 | gfredericks | okay on that note, I'm going to go dream about lambdas. |
| 23:08 | brehaut | brain fart time. i think and is (fn [a b] (a b a)) and or is (fn [a b] (a a b)) ? |
| 23:09 | gfredericks | which I assume are some kind of sheep/llama-type animal |
| 23:09 | brehaut | haha |
| 23:09 | brehaut | night |
| 23:58 | brehaut | woo enlive to the rescue |
| 23:59 | brehaut | my atom feed is no longer the worst quality on the clojure planet |