2011-10-07
| 00:16 | no_mind | Repeating question. Is it possible to have all files under a directory to have same namespace identified by directory path. For eg. all files in path xyz/applications/accounts have same namespace as xyz.applications.accounts . I have tried using compile and lein compile but both throw errors |
| 00:30 | devn | inferior lisp is nice enough. |
| 00:30 | devn | footholds are nice, but they are not requirements. |
| 01:25 | joshnz | Hi all. I started playing around with slime/swank and clojure the other night. The first thing I noticed was that the doc function doesn't appear to be loaded. If I lein repl then it's there out of the box. So why the difference? |
| 01:41 | amalloy | joshnz: it's just not in core; the repl probably loads some other namespaces like clojure.repl |
| 01:41 | duck1123 | doc is now in clojure.repl |
| 01:41 | amalloy | ,#'doc |
| 01:41 | clojurebot | #'clojure.repl/doc |
| 01:42 | duck1123 | either that, or lein is using 1.2 for it's repl. Did you start it in the context of a project for the repl? |
| 01:45 | joshnz | Running lein repl in the project folder, *clojure-version* reports 1.3 as expected. I can, straight off the bat and in the user ns, call (doc first) all ok |
| 01:46 | joshnz | in the slime repl, *clojure-version* is also 1.3. This is from a jack-in via the same project. |
| 01:46 | joshnz | It also starts in the user ns, but doc is undefined |
| 01:47 | duck1123 | odd. I don't use lein repl, anyway: (use 'clojure.repl) and you're all set |
| 01:47 | cark | that change is annoying as hell |
| 01:48 | cark | while developing, you nbeed to import it in each of your current namespaces |
| 01:48 | cark | or fully qualify it |
| 01:48 | duck1123 | or C-c C-d d |
| 01:49 | cark | that messes my window configuration =P |
| 01:49 | amalloy | fwiw C-c C-d C-d works too; i find it easier than remembering to let go of C- |
| 01:50 | cark | then you have find-doc |
| 01:50 | duck1123 | I need to get in the habit of using it. The only reason I mentioned it was because technomancy mentioned it when this came up earlier |
| 01:51 | joshnz | according to here: http://stackoverflow.com/questions/6443922/why-does-repl-treat-clojure-core-doc-as-a-var doc is "used" implicitly in the user ns, which is the behaviour I see from the command line repl, but not via slime. So something must be different in the way the swank repl is created...? |
| 01:52 | cark | in the past, it was "used" implicitely in all namespaces, and it made sense |
| 01:52 | cark | anyways ...can't have all we want all the time =) |
| 01:53 | duck1123 | core is big enough. doc can afford to move |
| 01:54 | cark | that's just an annoyance, nothing to write home about |
| 01:55 | joshnz | I'm not worried about the ns and implicit using or anything, what interests me is that the behaviour between the two repls is different. I would have thought they would have ultimately resolved to same thing. Cheers for the C-c C-d C-d tip, that works better than doc anyways :) |
| 01:57 | duck1123 | It probably has something to do with swank not really concerning itself with repls and just acting as an interface, and thus that code doesn't get called |
| 03:37 | Blkt | good morning everyone |
| 04:02 | ejackson | morning folks |
| 04:17 | cemerick | ejackson: Damn, now you're, what, 9 hours ahead of me? |
| 04:21 | ejackson | 9 ! |
| 04:22 | ejackson | you in SF now ? |
| 04:22 | ejackson | is |
| 04:22 | ejackson | 09:20 here |
| 04:23 | cemerick | feh, typical! |
| 04:23 | cemerick | ;-) |
| 04:23 | cemerick | ejackson: yeah, was here for java one |
| 04:24 | cemerick | flying back in 4 hours. |
| 04:24 | ejackson | oh yeah, how was your talk ? |
| 04:24 | ejackson | wait.... its 1am there and you're flying in 4 hours... |
| 04:24 | ejackson | borg ! |
| 04:25 | cemerick | yeah |
| 04:25 | cemerick | This has been a rough trip re: the actual traveling. |
| 04:25 | cemerick | The talk went well. |
| 04:25 | cemerick | Not really my sort of crowd tho. *shrug* |
| 04:26 | ejackson | hehe, don't worry, the conj is soon. |
| 04:26 | cemerick | I was a little peeved that there was *no* recording of the session at all. |
| 04:26 | ejackson | really ? that's a bit amateur hour for such a big conf |
| 04:26 | cemerick | I'm going to do some screencasts very shortly, starting with a reprise of the topic from my talk at the bay area clojure group tonight. |
| 04:26 | cemerick | Yeah, I don't know what to say about that. |
| 04:27 | ejackson | i'll be on the lookout for them, can't get enough tutorials |
| 04:27 | ejackson | oh, |
| 04:27 | cemerick | ClojureScript views in CouchDB, baby. Not sure if that counts as a tutorial, but… :-D |
| 04:28 | ejackson | (probability being what it is, I managed to book myself onto the same plane across the atlantic is christophe, fun) |
| 04:28 | cemerick | right, yes, I saw that :-) |
| 04:28 | cemerick | nice serendipity |
| 04:28 | ejackson | it does make the world go round |
| 04:28 | cemerick | odd that he (they) are going through London? |
| 04:28 | ejackson | they, yes. |
| 04:29 | ejackson | i'm not sure why, usual airline industry madness i'm sure |
| 04:30 | cemerick | tell me about it |
| 04:30 | cemerick | was stuck in Philadelphia overnight on Sunday. |
| 04:30 | ejackson | happy days, did you at least get a cheese steak ? |
| 04:30 | cemerick | Not even! |
| 04:30 | cemerick | Barely got a flight out the next day. |
| 04:31 | cemerick | Had to wrangle the customer "service" person to get me on a different airline's flight. Then had to run back and forth between the two, holding their hands so that they'd work together. |
| 04:31 | cemerick | It was a total cluster. |
| 04:32 | ejackson | you guys need some more trains |
| 04:32 | cemerick | not gonna happen |
| 04:32 | ejackson | two weeks ago I did a boston,nyc,washington trip, the connecting trains were great |
| 04:32 | cemerick | Maybe for short runs |
| 04:32 | cemerick | yeah, east coast works fine |
| 04:33 | cemerick | trains can't cross country in reasonable time. |
| 04:33 | cemerick | ~30 hours, optimistically |
| 04:33 | clojurebot | It's greek to me. |
| 04:33 | ejackson | then you need to shrink the country, only sensible solution |
| 04:33 | ejackson | airlines are no good |
| 04:34 | ejackson | i've finally managed to write something based on macros that seems to make sense (after christophe imparted some zen master wisdom to me) |
| 04:35 | ejackson | its the usual orm-ish malarky but useful |
| 04:53 | cemerick | ejackson: Christophe is good at that. :-) |
| 04:54 | ejackson | have a good one, catch you soon |
| 05:10 | skuro | ,(let [cur *ns* alien (namespace 'alien)] (in-ns alien) (println *ns*) (in-ns cur)) |
| 05:11 | clojurebot | #<NullPointerException java.lang.NullPointerException> |
| 05:11 | skuro | why is that throwing an NPE? |
| 05:22 | clgv | hmm that's strange I changed my project dependency to incanter 1.2.4 but lein deps still copies old 1.2.3 versions of incanter.core 1.2.3 into my lib folder. |
| 05:23 | clgv | ah lol incanter 1.2.4 lists the old dependencies in its project.clj :( |
| 06:30 | MrMc | I want to split comma separated values and collect specific fields with nth in Common lisp this is done with a loop in conjuction with collect how is this done in clojure |
| 06:33 | clgv | MrMc: like that ##(let [vs (split "1,2,3,4,5,6,7" #",")] (println (nth vs 0) (nth vs 5))) |
| 06:33 | lazybot | java.lang.Exception: Unable to resolve symbol: split in this context |
| 06:33 | clgv | MrMc: like that ##(let [vs (clojure.string/split "1,2,3,4,5,6,7" #",")] (println (nth vs 0) (nth vs 5))) |
| 06:33 | lazybot | ⇒ 1 6 nil |
| 06:36 | MrMc | clgv:Thats it in principle. Can a get this as a vector or list |
| 06:36 | clgv | &(type (clojure.string/split "1,2,3,4,5,6,7" #",")) |
| 06:36 | lazybot | ⇒ clojure.lang.PersistentVector |
| 06:36 | clgv | so split returns a vector |
| 06:37 | MrMc | yes |
| 06:38 | skuro | ##(let [v (clojure.string/split "1,2,3,4")] (map #(nth v %) [1 3])) |
| 06:38 | lazybot | java.lang.IllegalArgumentException: Wrong number of args (1) passed to: string$split |
| 06:38 | skuro | ##(let [v (clojure.string/split "1,2,3,4" #",")] (map #(nth v %) [1 3])) |
| 06:38 | lazybot | ⇒ ("2" "4") |
| 06:39 | clgv | there is 'vec to get a vector from a collection |
| 06:40 | MrMc | skuro:that is what I am looking for |
| 07:33 | noidi | what's the preferred way of manipulating fields of records (deriving new records)? |
| 07:33 | noidi | map functions such as assoc and update-in? |
| 07:34 | ambrosebs | I guess so, since records are just maps |
| 07:34 | ambrosebs | can't really go wrong with the map functions |
| 07:35 | noidi | I was just thinking that there might be a better performing way |
| 07:35 | noidi | since records are Java classes |
| 07:36 | ambrosebs | records are maps with certain keys optimized |
| 07:36 | ambrosebs | so you get the speed for "free" |
| 07:36 | ambrosebs | AFAIK |
| 07:38 | noidi | ok |
| 07:53 | michaelr525 | hey |
| 07:54 | gfredericks | michaelr525: hey |
| 07:58 | antares_ | if I have a record in a namespace abc.de that is required as de, how do I address it? de/MyRecord or do I need to import it as a Java class? |
| 07:59 | gfredericks | antares_: import |
| 07:59 | antares_ | gfredericks: thank you |
| 07:59 | gfredericks | np |
| 08:59 | lnostdal | hm, i can't even read from a DB within a clojure transaction? |
| 09:00 | cark | transactions might be retried, woudl you want to pay the cost of a database query on each retry ? |
| 09:01 | lnostdal | to make things simple, sure |
| 09:01 | lnostdal | at least for now |
| 09:02 | cark | well reading from a daztabase is a side effect |
| 09:03 | cark | but what's really important is that you shouldn't have to do this |
| 09:03 | cark | transactions should be small and localized |
| 09:04 | cark | by doing a long operation like reading from a database, you increase the risk of a retry |
| 09:04 | lnostdal | i'm doing a simple login check in a http request .. other http requests do more complex things and need a outer dosync wrapper .. but i don't want to think about what needs stm and doesn't, so i wrap all http request handlers in an outer dosync |
| 09:05 | lnostdal | perhaps this is wrong .. (heck, i actually want a pessimistic stm, but yeah .. :>) |
| 09:05 | cark | you're trying to avoid thinking about your concurrency issues |
| 09:05 | cark | that's a receipe for disaster |
| 09:06 | lnostdal | a pessimistic stm? .. it's simpler, no write-skew or anything |
| 09:07 | cark | you can picture a dosync like a lock, a very elaborate lock which will not lock very often, but still, that's a contention point |
| 09:07 | cark | you don't want to spend too much time inside your locks |
| 09:10 | inhortte | Hello. I'm getting this error: Exception in thread "main" java.lang.IllegalArgumentException: No matching field found: getRoot for class clojure.lang.Var when adding a model with clj-record to a Noir app. Has anyone else encountered this? |
| 09:11 | antares_ | inhortte: sounds like clj-record is not 1.3 ready and you are using 1.3 |
| 09:11 | duck1123 | I have a patch somewhere i think |
| 09:11 | inhortte | I thought it may be that, though when I switch back to 1.2.1, I get an unrelated error. |
| 09:12 | inhortte | duck -> That would be great. :) |
| 09:13 | duck1123 | hmm... that's not one of the things I've changed |
| 09:14 | cark | lnostdal: usually you want to use stm to "protect" some kind of datastructure(s), you would put the dosyncs on the functions which are the entry points for manipulating those data structures |
| 09:14 | duck1123 | I actually didn't have to change much to get clj-record working, is this with running tests? |
| 09:14 | inhortte | No, this is with attempting to access a model. |
| 09:14 | cark | lnostdal: the "http request" layer of your application has nothing to do with stm |
| 09:14 | lnostdal | sure cark .. but i might call several of them, and that'll lead to transactions from other threads being interwoven |
| 09:14 | duck1123 | The real issue is getRoot is now getRawRoot |
| 09:15 | inhortte | I did not run the tests. (And I should say that I am new at clojure, by the way) |
| 09:15 | lnostdal | a http request handler is the proper granularity i'm after; it does a set of things that must be done atomically |
| 09:15 | inhortte | Ah. I can attempt to modify clj-record, I guess. |
| 09:15 | duck1123 | inhortte: is it giving you a stacktrace? |
| 09:16 | inhortte | duck -> It is giving me a stacktrace, beginning with the line I first posted. |
| 09:16 | cark | lnostdal: it is not the proper granularity if you want to mix dosync with database reads |
| 09:16 | lnostdal | cark, i could do the i/o ,that is db stuff (just read in this case), in an agent .. except i can't use await so it's worthless |
| 09:17 | inhortte | If the model is not required, then there is no error. |
| 09:17 | cark | all your problems are because you're mixing presentatin layer with business layer |
| 09:18 | duck1123 | inhortte: here's the branch I'm using https://github.com/duck1123/clj-record/tree/kronkltd |
| 09:18 | inhortte | So my guess is that clj-record.core/init-model macro is doing something wrong (not calling getRawRoot, I suppose). |
| 09:18 | inhortte | OK. I'll clone that branch. Thanks, duck. |
| 09:18 | tudor | inhortte: do you use slime when working with noir? |
| 09:19 | inhortte | tudor -> I set up slime earlier, but it would not work using clojure-jack-in. |
| 09:19 | tudor | I'm trying to but it looks like it doesn't load all the libraries so it can't compile my module |
| 09:19 | inhortte | tudor -> I can only get slime working if I run a swank server independently. |
| 09:19 | tudor | this happens with clojure-jack-in |
| 09:20 | tudor | I was curious if I'm expecting too much from slime, to know of my libraries or if it's just a bug |
| 09:20 | inhortte | tudor -> I've not had any luck with slime not only with my noir project, but ANY project. I can use the repl for random stuff, but not in the project. I have to create my own repl with leim to do that. |
| 09:21 | tudor | inhortte: thanks, that was my experience as well. |
| 09:22 | duck1123 | what errors are you guys getting? And are you using the slime from elpa? |
| 09:23 | inhortte | duck -> I'm using the slime from elpa. |
| 09:23 | inhortte | duck -> one moment. |
| 09:24 | tudor | duck1123: I start slime with clojure-jack-in in the project directory. try to compile a random view and get errors like : "don't know what defpartial is", I don't have the exact error message around for reference |
| 09:24 | tudor | defpartial is a macro used in noir, "use"'d in the currently open view |
| 09:24 | inhortte | tudor -> hm. It worked this time. |
| 09:25 | inhortte | tudor -> what steps did you take to compile the view? |
| 09:25 | inhortte | tudor -> once slime was running, that is? |
| 09:25 | lnostdal | cark, ok, yeah, i suppose my request handlers need to do without dosync .. then i need to parse input, do db i/o (read), then call some Model type function/handler which only there wraps everything in a dosync, then write to DB afterwards .. something like that anyway |
| 09:25 | inhortte | tudor -> I want to try it. |
| 09:26 | duck1123 | I've never been a big fan of clojure-jack-in. I prefer to keep my apps running in screen |
| 09:27 | inhortte | duck -> this is the first day of my life that I have used clojure-jack-in. It seems to be working now, however, oddly. I dislike when things fix themselves. :) |
| 09:29 | ejackson | I can never figure out where the output goes with clojure-jack-in, seems to vaporize. |
| 09:29 | wink | hm, is the jetty via "lein run" that slow? 10 concurrent (via siege) on a seemingly simple noir webapp firing ~11 simple sql-queries on a ridiculously small local mysql db (50 datasets), indexes are ok -a nd I get 3-4 sec response times. |
| 09:34 | tudor | inhortte: I'm never sure what keys to use to compile stuff. most of the time I try C-M-x |
| 09:34 | tudor | how do you guys compile in slime? |
| 09:34 | duck1123 | uce C-c C-k, that way you keep the line numbers |
| 09:34 | tudor | do I get the error because of C-M-x? |
| 09:35 | duck1123 | possibly if you changed the ns form and forgot to send it |
| 09:35 | duck1123 | C-c C-k reloads the whole file |
| 09:35 | tudor | duck1123: thanks, will try that later today |
| 09:36 | inhortte | tudor -> C-M-x complies. |
| 09:36 | inhortte | tudor -> oops. Duck's answer was better. C-c C-k |
| 10:16 | inhortte | I'm pretty sure, after more investigation, that the problem is with clojure.contrib.sql. :( |
| 10:19 | ejackson | inhortte: you know that's deprecated, yeah ? |
| 10:22 | inhortte | ejackson -> nope. What shall I use instead? |
| 10:22 | ejackson | if you're on 1.3 you should go to clojure.java.jdbc |
| 10:23 | ejackson | as contrib is being broken up |
| 10:23 | inhortte | OK. I just found that. Thank you, anyway. |
| 10:24 | ejackson | np, it caught me out |
| 10:30 | stuartsierra | Does `*print-dup* true` automatically imply `*print-meta*` true? |
| 10:36 | TimMc | ,(binding [*print-meta* false, *print-dup* true] (print ^{:foo :bar} [])) |
| 10:36 | clojurebot | ^#=(clojure.lang.PersistentArrayMap/create {:foo :bar}) [] |
| 10:36 | TimMc | (No idea if I'm testing this the right way.) |
| 10:36 | TimMc | ,(binding [*print-meta* true, *print-dup* true] (print ^{:foo :bar} [])) |
| 10:36 | clojurebot | ^#=(clojure.lang.PersistentArrayMap/create {:foo :bar}) [] |
| 10:38 | gfredericks | why isn't "^#=(clojure.lang.PersistentArrayMap/create {:foo :bar})" redundant? |
| 10:39 | gfredericks | isn't it the same as #^{:foo :bar}? |
| 10:39 | gfredericks | or something similar |
| 10:49 | clgv | how can I force leiningen to check clojars again? |
| 10:49 | gfredericks | clgv: rm -rf ~/.m2 ? :) |
| 10:50 | clgv | a bit drastic. but I can lookfor the library I intend to update |
| 10:50 | gfredericks | yeah that's what I normally do |
| 10:52 | clgv | a builtin parameter would be nice ^^ |
| 10:53 | gfredericks | clgv: what kind of use case is not covered by version-bumps and checkouts? |
| 10:53 | clgv | gfredericks: I just did lein deps this morning. but there was an error in the jar that is fixed now. but leiningen didnt check back I guess |
| 10:54 | gfredericks | clgv: if the contents of the jar changed, shouldn't that be a new version? |
| 10:55 | clgv | I dont know any details on how leiningen and clojars work together and if leiningen does check back there everytime |
| 10:56 | gfredericks | is it a SNAPSHOT version? |
| 11:04 | clgv | not really. error when releasing ;) |
| 11:04 | clgv | but it's solved now manually^^ |
| 11:08 | bendlas | hi |
| 11:09 | bendlas | does anybody have experience getting packages with native dependencies to run on JDK7? |
| 11:11 | bendlas | I wanted to play around with overtone, but it segfaults on JDK7 |
| 11:17 | wiseen | Is ClojureScript missing (case ) statement implementation or I'm I doing something horribly wrong ? |
| 11:21 | gfredericks | does anybody know what a "Duplicate method name&signature" on a (defrecord) is likely to mean? |
| 11:22 | clgv | gfredericks: defrecord methods have no extra namespace so it might be possible that you have a function outside the defrecord with the same name and arity |
| 11:22 | gfredericks | oh hmm |
| 11:22 | clgv | or maybe you pull it into the namespace via a :use |
| 11:22 | gfredericks | no wait |
| 11:22 | gfredericks | neither of those are the case |
| 11:22 | gfredericks | I'm doing this in a stripped-down manner now, to debug |
| 11:23 | raek | I hink there can be problems if you have a field and a method with the same name |
| 11:23 | dnolen | gfredericks: you're probably defining a method defrecord already defines. |
| 11:23 | gfredericks | aah -- like count! |
| 11:23 | dnolen | gfredericks: yup |
| 11:23 | gfredericks | so what do I do if the interface has a method called count? |
| 11:23 | toxmeister | hey, speaking of defrecords… which protocol do i have to extend/implement to have that record supported by the count & conj functions? |
| 11:24 | gfredericks | toxmeister: I think you get that automatically |
| 11:24 | toxmeister | no way, crossover. same question twice.. ;) |
| 11:24 | toxmeister | well say my record is just (defrecord polygon [vertices]) and i want count not count the number of fields in the record, but the number of vertices in that field |
| 11:26 | gfredericks | toxmeister: sounds like that'd be bad form, since you'd be breaking the behavior of IPersistentMap |
| 11:26 | wiseen | Can someone plz check (case 1 1 1 2 2) in ClojureScript REPL just so I know if it's my install problem or is it really not implemented |
| 11:26 | gfredericks | toxmeister: use deftype if you don't want a map? |
| 11:27 | toxmeister | i quite like the map, since I might add a few other fields later |
| 11:27 | PPPaul | why is there clojure in my javascript? |
| 11:28 | gfredericks | toxmeister: well it can't be both a map and not a map. The other option is to create a count function in your own namespace, and the callers have to distinguish |
| 11:28 | dnolen | PPPaul: because it's good. |
| 11:28 | PPPaul | does clojurescript have into? |
| 11:28 | toxmeister | and re: breaking IPersistentMap, that's exactly why i'd like to implement that functionality myself (count, conj etc.) but have these applied to the vertices field only |
| 11:28 | PPPaul | (into |
| 11:28 | PPPaul | i love into |
| 11:28 | dnolen | PPPaul: ClojureScript has pretty much everything you expect from Clojure and then some. |
| 11:28 | gfredericks | toxmeister: but then your record is no longer a map, because I can assoc onto it but the count stays the same |
| 11:29 | toxmeister | gfredericks: not, if the (count poly) actually returns (count (:vertices poly)) |
| 11:30 | toxmeister | hmm, but i see the point about assoc would be problematic... |
| 11:30 | toxmeister | okay, will try deftype then and see how i fare… thanks a lot! |
| 11:30 | gfredericks | sure |
| 11:32 | gfredericks | I guess my answers to toxmeister answer my own question as well. Since maps/records have a .count method, I can't implement an interface that has a method by the same name :/ |
| 11:41 | dnolen | pattern matching is hard |
| 11:42 | gfredericks | dnolen: with clojure it's easy! have you seen dnolen's pattern matching library? |
| 11:43 | dnolen | gfredericks: ha! easy to use, tricky to implement. |
| 11:44 | dnolen | I think I'm down to one last serious correctness bug (knock on wood) |
| 11:46 | gfredericks | fliebel: you give me too much credit. It was just a lame joke. |
| 11:46 | gfredericks | s/credit/the benefit of the doubt/ |
| 11:46 | lazybot | <gfredericks> fliebel: you give me too much the benefit of the doubt. It was just a lame joke. |
| 11:47 | fliebel | dnolen: pattern matching is not hard, your view of what good pattern matching is is hard to implement. |
| 11:48 | dnolen | fliebel: heh, it's not "my view", it's the view of 25 years of FP research. |
| 11:51 | dnolen | core.match on the innovation scale is pretty close to zero :) pushing the work into predicate dispatch might have a tiny bit of real novelty. |
| 11:51 | fliebel | dnolen: So what is going on under the hood? Is all the dag magic and openness from the predicate papers in htere? |
| 11:51 | dnolen | fliebel: no openness is my own invention - though it ended up being similar to Racket's implementation. |
| 11:52 | bsod1 | is there a clojure REPL with syntax coloring and auto-indentation? like python's ipython |
| 11:52 | gfredericks | dnolen: "multimatches"? |
| 11:52 | fliebel | dnolen: Did you blog about the exception stuff already? That sounded really weird. |
| 11:53 | wiseen | please please please will someone try (case 1 1 1 2 2) in clojurescript repl, I just want to confirm that what I'm getting isn't because I installed it wrong |
| 11:53 | dnolen | fliebel: no, what's weird about it? just uses exceptions for backtracking, it's been done before in Java applications. |
| 11:53 | fliebel | dnolen: Just that I've never seen it, and don;t know how it works. |
| 11:54 | gfredericks | wiseen: okay okay okay |
| 11:55 | dnolen | fliebel: just create an exception store it in a var. And reuse it. |
| 11:55 | dnolen | wiseen: that doesn't work for me, you should open a ticket in JIRA |
| 11:55 | gfredericks | ditto |
| 11:55 | wiseen | tnx. was going nuts looking trough the cljs source for implementation of it |
| 11:56 | dnolen | wiseen: actually now that I think about it, you probably shouldn't open a ticket |
| 11:56 | gfredericks | wiseen: (case 1) and (case 1 1 1) seem to fail the same way |
| 11:56 | dnolen | wiseen: case is a JVM specific optimization |
| 11:57 | dnolen | wiseen: there is no comparable constant time switch for JS as far as I know. |
| 11:58 | gfredericks | dnolen: should there at least be a ticket to remove it then? |
| 11:58 | gfredericks | or make it do whatever it was put there to do |
| 11:58 | wiseen | oh ok, but is there any equivalent way to do it ? without (cond (= 1 1) (= 2 2)) |
| 11:58 | gfredericks | wiseen: use pattern matching :) |
| 11:59 | wiseen | hmm tried that also got a CLJS error |
| 11:59 | wiseen | will try more tough :) |
| 12:00 | dnolen | gfredericks: what do you mean remove it, it doesn't exist thus the error. |
| 12:01 | dnolen | wiseen: cond works fine. |
| 12:01 | gfredericks | dnolen: oh ha. sorry misunderstood the error then. |
| 12:02 | gfredericks | (defn case [v & pairs] (let [pairs (partition 2 pairs)] (second (first (filter #(= v (first %)) pairs))))) |
| 12:02 | gfredericks | wiseen: ^ make your own? |
| 12:03 | chouser | (condp i = 1 "one" 2 "two") |
| 12:03 | chouser | sorry, (condp = i 1 "one" 2 "two") |
| 12:04 | chouser | ,(condp = 2 1 "one" 2 "two") |
| 12:04 | clojurebot | "two" |
| 12:04 | gfredericks | chouser: so (def case (partial condp =))? :) |
| 12:05 | chouser | yeah, but that'll actually because differently than clojure's case |
| 12:05 | gfredericks | I bet I have missed many opportunities to use condp :/ |
| 12:05 | gfredericks | I can't ever get those years back. |
| 12:05 | wiseen | chouser: nice, tnx ! |
| 12:06 | dnolen | we need a CLJS repl in here. |
| 12:06 | chouser | clojure's case doesn't eval the conditions, and uses literal lists to mean "or" |
| 12:07 | fliebel | dnolen: I still don't get it. You make an exception, and then? reuse = throw? Do you have an example on something to read or google for? |
| 12:07 | chouser | ,(case + (+ 1 2) "plus or one or two") |
| 12:07 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: No matching clause: clojure.core$_PLUS_@593f4e> |
| 12:07 | chouser | ,(case '+ (+ 1 2) "plus or one or two") |
| 12:07 | clojurebot | "plus or one or two" |
| 12:08 | dnolen | fliebel: http://blogs.oracle.com/jrose/entry/longjumps_considered_inexpensive |
| 12:09 | chouser | dnolen: have you gotten any pushback from Rich on that? |
| 12:09 | dnolen | chouser: pushback on what? |
| 12:09 | chouser | exceptions for flow control |
| 12:10 | dnolen | chouser: Clojure's STM uses the same technique. |
| 12:10 | chouser | hm, ok. |
| 12:10 | chouser | I did the same thing in error-kit and thought I remembered enduring some frowns because of it. |
| 12:11 | dnolen | chouser: I think the idea was using it a real form of non-local control. In core.match, it's an implementation detail. |
| 12:14 | dnolen | chouser: In ClojureScript I throw 0. That's fun. |
| 12:15 | dnolen | probably should throw a namespaced keyword. |
| 12:46 | toxmeister | sorry to ask so many newbie questions, but am trying to get my head around some defprotocol weirdness(es).. could someone please have a look at this and explain why the exception occurs for the 3-arg func call using the protocol, but works fine using the same arity specs on a normal function? |
| 12:46 | toxmeister | https://gist.github.com/1270747 |
| 12:49 | hiredman | toxmeister: protocols don't do varargs |
| 12:51 | toxmeister | arrgh! that explains things… would be good if this could be pointed out on: http://clojure.org/Protocols |
| 12:51 | toxmeister | thanks, hiredman |
| 12:53 | chouser | dnolen: heh |
| 13:18 | dnolen | cool! http://ww2.cs.mu.oz.au/~sulzmann/chr/ |
| 13:27 | gtrak` | i think maybe the best way to distribute a clojurescript library right now is in single-file form, a la core.clj, building up namespaces as you go, has anyone thought about that kind of stuff? |
| 13:30 | gtrak` | ah, i see there is some talk of jaring up dependencies and using lein |
| 13:40 | aaelony | Hi - I wanted to check out Cheshire with Clojure 1.3, but it seems to clobber the doc function. http://pastie.org/2656615 Do others see this too? |
| 13:41 | hiredman | aaelony: you need to (use 'clojure.repl) in your new namespace |
| 13:41 | aaelony | i see. thanks hiredman! |
| 13:49 | antares_ | is there a seq function like iterate that stops when the function it is given returns nil? |
| 13:51 | cark | (filter identity (iterate .... )) |
| 13:52 | cark | err take-while or something |
| 13:52 | dbushenko | did you guys try storm? |
| 13:53 | dbushenko | I've just tried to follow the examples and everything I have -- just the errors |
| 13:53 | cark | ,(take-while identity [1 nil nil]) |
| 13:53 | aaelony | antares: there is nice blog posting on this (http://blog.malcolmsparks.com/). See "Preventing infinite application". |
| 13:53 | clojurebot | (1) |
| 13:53 | cark | antares_: remember we're working with lazy sequences |
| 13:57 | antares_ | cark: I have been about to try take-while, thanks. Sorry, what specifically do you want me to keep in mind? |
| 13:57 | antares_ | cark: my broader goal is to turn a generator function that will eventually return nil into a lazy seq |
| 14:00 | cark | i was only pointing out that it should stop even though you have an infinite list |
| 14:00 | cark | but it looks like you know that already =) |
| 14:03 | antares_ | cark: yeah, I am not *that* new to FP and lazy evaluation :) |
| 14:33 | devth | i'd like to use (read-string) on some user input, and handle differently if the input was a string or number. how do I check the resulting type of (read-string)? |
| 14:34 | ibdknox | ,(doc type) |
| 14:34 | clojurebot | "([x]); Returns the :type metadata of x, or its Class if none" |
| 14:34 | ibdknox | ,(doc string?) |
| 14:34 | clojurebot | "([x]); Return true if x is a String" |
| 14:34 | ibdknox | ,(doc number?) |
| 14:34 | clojurebot | "([x]); Returns true if x is a Number" |
| 14:35 | devth | ah, thanks. i was trying isa? without luck. |
| 14:35 | hiredman | read-string results in a clojrue datastructure, how do you check the type of anything in clojure? |
| 14:37 | devth | ,(string? (read-string "foo")) |
| 14:37 | clojurebot | false |
| 14:38 | hiredman | correct |
| 14:38 | devth | ,(string? (type (read-string "foo"))) |
| 14:38 | clojurebot | false |
| 14:38 | devth | ok, what am i missing? |
| 14:38 | hiredman | ,(read-string "foo") |
| 14:38 | clojurebot | foo |
| 14:38 | hiredman | ,(read-string "\"foo\"") |
| 14:38 | clojurebot | "foo" |
| 14:38 | hiredman | ,(type (read-string "foo")) |
| 14:38 | clojurebot | clojure.lang.Symbol |
| 14:38 | hiredman | ,(type (read-string "\"foo\"")) |
| 14:38 | clojurebot | java.lang.String |
| 14:39 | hiredman | read-string is just like what happens with clojure source code |
| 14:39 | hiredman | foo is a symbol, "foo" is a string |
| 14:39 | devth | (type (read-string "1.0")) |
| 14:39 | devth | ,(type (read-string "1.0")) |
| 14:39 | clojurebot | java.lang.Double |
| 14:39 | devth | i guess that was throwing me off. |
| 14:50 | cgray | i'm having some trouble with java interop... there is a class with constructor public HangmanGame(String secretWord, int maxWrongGuesses) { ... } and I am doing (def game (HangmanGame. "abbey" 5)) and getting the error Class clojure.lang.Compiler$NewExpr can not access a member of class HangmanGame with modifiers "public" |
| 14:55 | hiredman | cgray: what version of clojure? |
| 14:55 | cgray | 1.2 |
| 14:57 | gtrak` | dnolen, if only the kinesis had an integrated trackpoint |
| 14:57 | hiredman | cgray: can you pastebin more? |
| 14:57 | cgray | hiredman: sure, just a sec |
| 14:58 | amalloy | cgray: sounds like the HangmanGame class probably isn't itself public |
| 14:58 | cgray | amalloy: ahh, you're right |
| 15:05 | cgray | are classes not public by default? |
| 15:06 | hiredman | they are not |
| 15:06 | hiredman | also you may run into trouble if the class is not in a proper package |
| 15:11 | amalloy | java's default visibility settings are absurd |
| 15:30 | michaelr525 | what is a good windows software for making screencasts? |
| 15:34 | jcromartie | Would it make sense to bang-ify functions like: "uuid!" or "timestamp!" |
| 15:35 | jcromartie | things that are not pure functions? |
| 15:35 | jcromartie | or what is the definition of "not safe in a STM transaction" |
| 15:35 | jcromartie | I'm going off of http://dev.clojure.org/display/design/Library+Coding+Standards |
| 15:35 | gfredericks | jcromartie: something more specific than impure |
| 15:35 | gfredericks | e.g., clojure.core/send |
| 15:36 | jcromartie | hm ok |
| 15:36 | jcromartie | so something using current time or PRNG is not quite unsafe |
| 15:36 | jcromartie | but if you retry the transaction, it would get a new value, right? |
| 15:37 | gfredericks | yes. but that's fine right, in this particular case? |
| 15:37 | jcromartie | probably |
| 15:37 | gfredericks | I'm not too familiar with the issue, beyond what I've already said |
| 15:46 | todun | Brand new to Clojure. Looking for a tutorial that will walk me through from installation to basic syntax to practice problems(or group of tutorials). Any tips are welcome! |
| 15:48 | gfredericks | todun: 4clojure.com is not exactly a tutorial but you might find it helpful |
| 15:50 | dnolen | todun: if you're just starting out, I recommend looking into clooj first. |
| 15:50 | dnolen | todun: unless you already have a dev environment you'd like to continue using. |
| 15:51 | todun | gfredericks: dnolen thanks. when I google clooj, I get github repo |
| 15:53 | droidboi | hi |
| 15:54 | dnolen | todun: yup, there's a download link on the repo. |
| 15:55 | gfredericks | droidboi: hi |
| 15:55 | todun | dnolen: ok. I was thinking of working from the CLI using emacs. |
| 15:55 | amalloy | todun: yeah, 4clojure will help you learn the language. not really the "mechanics" like installation, though. it's a pure-browser solution, though, that can help you get your feet wet without having to install stuff |
| 15:56 | dnolen | todun: then you have an environment that you want to continue using - http://dev.clojure.org/display/doc/Getting+Started+with+Emacs |
| 15:58 | todun | amalloy: ok thanks. |
| 15:58 | todun | dnolen: yes indeed. |
| 15:59 | todun | will read up and come back with my questions. thanks all. |
| 16:02 | jcromartie | I wonder if depending heavily on refs is bad API design? |
| 16:02 | jcromartie | it starts to feel very stateful |
| 16:02 | jcromartie | like, to have most of your functions depend on certain refs |
| 16:02 | jcromartie | I guess I could pass the ref |
| 16:03 | jcromartie | that would be better |
| 16:03 | stuarthalloway | or its value |
| 16:03 | jcromartie | ah yes |
| 16:03 | jcromartie | I'm just not sure what to call them :) |
| 16:03 | jcromartie | I have two main refs: logins and organizations |
| 16:04 | jcromartie | that's basically the state of my system |
| 16:04 | jcromartie | all non-loign data lives under an organization |
| 16:04 | stuarthalloway | why don't the functions take one state and return another |
| 16:04 | jcromartie | yeah that's probably a better idea |
| 16:04 | jcromartie | and write them at the organization level |
| 16:04 | jcromartie | the organization itself may be a huge data structure (various values may have a million elements or more) |
| 16:05 | jcromartie | but that's not really a problem |
| 16:05 | jcromartie | until I start printing things :) |
| 16:05 | srid | what is the best way to dispatch to functions based on a value? for eg. I have foo, bar, baz functions. I also have the similarly-named function in a different module. whenever I invoke foo, I want to pick the module dynamically based on a command-line argument. |
| 16:06 | srid | (in python, i normally lookup func/modjules dynamically based on name) |
| 16:06 | ibdknox | srid, multimethods? |
| 16:06 | dbushenko | do you guys have any examples of storm-projects except storm-starter? |
| 16:11 | tdrgabi | I started slime with clojure-jack-in from a noir project. try to compile a view and I get: "error: java.lang.RuntimeException: java.lang.NoClassDefFoundError: Could not initialize class noir.core__init" |
| 16:11 | tdrgabi | can we compile noir files from slime? |
| 16:12 | ibdknox | gfredericks, really? I didn't know that either |
| 16:12 | gfredericks | ibdknox: and to think I was considering assembling a record by hand. |
| 16:13 | gfredericks | now to figure out if there's a factory for initializing a record with nils somewhere... |
| 16:13 | ibdknox | tdrgabi: noir isn't any different than other Clojure libs, but I don't use emacs, so I can't help you much :( |
| 16:16 | gfredericks | ibdknox: what do you use? |
| 16:18 | ibdknox | gfredericks, VIM |
| 16:18 | gfredericks | :) |
| 16:19 | ibdknox | I keep trying to learn emacs, but working at 10% efficiency for a while is a hard barrier for me to get over |
| 16:24 | Raynes | I'm currently using a mutant mix of Emacs and Vim. |
| 16:24 | cgray | viper-mode is a nice hit of methadone |
| 16:25 | Raynes | I'm an Emacs user, mostly. Just thought I'd give Vim a go. I like it, but I'm not sure it can really give me what Emacs gives me. |
| 16:25 | ibdknox | cgray, I found no reason to use emacs with viper over just normal vim, you lose paredit, which seems like the most useful part |
| 16:26 | michaelr525 | cgray: ಠ_ಠ |
| 16:27 | cgray | ibdknox: emacs has paredit |
| 16:27 | Raynes | ibdknox: Vim has paredit too. I guess it isn't quite as sophisticated, but it does everything I needed. |
| 16:28 | mcstar | does anybody have a clue as to why nothing show up on an incanter graph for me? |
| 16:30 | amalloy | mcstar: given only that information, i don't think anyone in the world could help |
| 16:31 | mcstar | i tried running incanter from clojure/cake, and from its distribution too |
| 16:31 | mcstar | i use the (view) call, a window comes up, but its completely blank |
| 16:31 | mcstar | (view (function-plot sin -1 1)) |
| 16:31 | mcstar | for exmaple |
| 16:32 | mcstar | im using sun's jre |
| 16:32 | mcstar | +linux |
| 16:32 | mcstar | i dont know what else could be relevant, help me out, i answer your question |
| 16:35 | gfredericks | does anybody know if there's anything that does the inverse of clojure.core/bean? Else I'll be writing my own... |
| 16:51 | ibdknox | mcstar, put a gist up with some simple code and maybe someone can help |
| 16:51 | mcstar | ibdknox: there nothing to put up, its the simplest example from any incanter tutorial |
| 16:53 | amalloy | gfredericks: writing your own? good luck with that |
| 16:54 | gfredericks | amalloy: thanks, I'm halfway done :) at least according to my own requirements. Not a strict interpretation of what I asked for. |
| 16:55 | stuartsierra | gfredericks: people have done it, search the list/IRC archives |
| 16:55 | stuartsierra | Although it won't work in the general case. |
| 16:56 | gfredericks | stuartsierra: My case is I have an interface that has getters/setters with standard names, and I want to convert a map to a proxy object that implements the interface |
| 16:57 | gfredericks | I seem to be getting into macro trouble though :/ |
| 16:58 | stuartsierra | Try writing out what you want by hand. |
| 16:59 | gfredericks | stuartsierra: you mean for a specific interface? |
| 16:59 | stuartsierra | yes |
| 16:59 | gfredericks | for my own sake or to communicate to IRC what I want? |
| 16:59 | stuarthalloway | stuartsierra: just the man I am looking for! |
| 16:59 | stuartsierra | uh oh |
| 16:59 | stuarthalloway | please check to see if I just cut alpha1 |
| 17:00 | ibdknox | run |
| 17:00 | ibdknox | run fast |
| 17:00 | gfredericks | stuart fight! |
| 17:00 | stuarthalloway | and if I didn't please do so |
| 17:00 | stuarthalloway | the release build (#314) vanished from the Hudson UI. Totally weird |
| 17:01 | stuartsierra | stuarthalloway: You did not. |
| 17:01 | stuarthalloway | can you try it, and see if you can do better? |
| 17:01 | stuartsierra | http://build.clojure.org/view/Clojure/job/clojure/314/console |
| 17:01 | stuarthalloway | pretty please? |
| 17:01 | stuartsierra | " [INFO] Failed to create assembly: Error adding file to archive: /var/lib/hudson/jobs/clojure/workspace/changes.txt isn't a file." |
| 17:02 | stuartsierra | The build expects to find a file named changes.txt |
| 17:02 | stuartsierra | That file got renamed to changes.md |
| 17:02 | stuartsierra | It just needs to be changed in src/assembly/distribution.xml |
| 17:02 | stuarthalloway | OK, I can do that |
| 17:02 | stuarthalloway | thanks |
| 17:03 | stuartsierra | np |
| 17:03 | gfredericks | no more macro trouble; can use init-proxy fn instead of proxy macro. |
| 17:03 | amalloy | gfredericks: if you have an interface, and want to implement it in terms of a map (i guess a ref of a map, for setters?), that's possible, and probably not even that hard |
| 17:03 | stuartsierra | gfredericks: By the way, my suggestion of writing stuff by hand was a general trick for designing macros. |
| 17:03 | amalloy | it's the general case that's impmossible |
| 17:04 | stuartsierra | In general, the general case is impossible |
| 17:04 | gfredericks | by "general case" you mean arbitrary objects that aren't so bean-like? |
| 17:04 | gfredericks | s/objects/classes |
| 17:04 | lazybot | <gfredericks> by "general case" you mean arbitrary classes that aren't so bean-like? |
| 17:05 | amalloy | gfredericks: doesn't even matter if they're bean-like; i mean not having a known class, or not having a known set of methods |
| 17:05 | gfredericks | oh oh of course |
| 17:05 | gfredericks | I was assuming the class/interface was an extra argument |
| 17:05 | gfredericks | sorry |
| 17:05 | gfredericks | yes, clearly impossible :) |
| 17:05 | amalloy | also, using proxy for this makes me a bit sick. why not just use reify? you have an interface to implement, not a class to extend |
| 17:06 | gfredericks | amalloy: because I don't know what reify does, so it didn't occur to me :) |
| 17:07 | amalloy | (as-interface m [:name] MyInterface) => (let [data (ref m)] (reify MyInterface (getName [this] (:name @data)) (setName [this x] (dosync (alter data assoc :name x))))) |
| 17:09 | amalloy | for extra credit you can use reflection on MyInterface to derive the list of field names, but having them be explicitly passed is easier and imo simpler |
| 17:09 | gfredericks | amalloy: I already wrote the reflective function to take an interface and derive method names |
| 17:09 | gfredericks | but reify being a macro seems to make this harder |
| 17:09 | gfredericks | unless I make a def for each interface I want to use, rather than a general function of maps/interfaces |
| 17:10 | amalloy | proxy is a macro too, though? |
| 17:10 | gfredericks | yeah, I had the same problem there, and was digging into the proxy src to see how to do it with lower-level functions |
| 17:10 | hiredman | ugh |
| 17:11 | gfredericks | hiredman: I asked for help, I'm not asserting that I have great ideas |
| 17:12 | amalloy | gfredericks: it sounds like you've done the hard work; making it work with reify instead is a small change |
| 17:13 | gfredericks | amalloy: I did the reflective work. Didn't solve the macro problem. Reify wants the interface-names and method-names at compile time, when I'm trying to supply them at runtime |
| 17:13 | gfredericks | I think... |
| 17:13 | amalloy | i don't believe you. you must know the interface name at compile time, or proxy wouldn't work |
| 17:14 | gfredericks | amalloy: so if I write my thing as a macro, then I'm accepting a symbol to refer to the interface. Do I resolve that symbol somehow? |
| 17:15 | amalloy | *nod* just like proxy does, i think |
| 17:16 | amalloy | (or, if not, then reify certainly does) |
| 17:16 | gfredericks | yeah, I just thought to look at how reify does it |
| 17:16 | amalloy | i mean, i guess there's a special form for that, reify* |
| 17:16 | amalloy | so it may be the compiler doing the resolution, but either way it's passed a symbol and has to turn it into a class at some point |
| 17:16 | hiredman | amalloy: I believe he was looking at proxy, but proxy doesn't work |
| 17:17 | amalloy | hiredman: they should both work, right? proxy is uglier but viable? |
| 17:17 | gfredericks | hiredman: I was, but amalloy pointed out reify, which I wasn't familiar with, so I'm looking at that now |
| 17:17 | hiredman | not if he wants runtime code generation |
| 17:17 | amalloy | i don't think he actually does |
| 17:17 | hiredman | you don't have to do resolution or anything at all |
| 17:18 | hiredman | just emit (reify SomeInterfaceName some-methods) |
| 17:18 | gfredericks | hiredman: how do I know what methods? |
| 17:18 | amalloy | hiredman: right. which is how the version i proposed would work |
| 17:18 | amalloy | he wants to inspect the interface and magically determine the methods to emit |
| 17:18 | hiredman | gfredericks: you said you did reflective stuff? |
| 17:18 | gfredericks | hiredman: yeah, already got that; a function that takes an interface and returns a map of method-name info |
| 17:19 | hiredman | ,(-> String .getMethods) |
| 17:19 | clojurebot | #<Method[] [Ljava.lang.reflect.Method;@849bd> |
| 17:19 | amalloy | but at compile time; just saving his users from typing in stuff |
| 17:19 | amalloy | which, as i mentioned above, i think is a misfeature that isn't really worth doing |
| 17:19 | hiredman | gfredericks: so you write a macro that uses that function to generate the call to reify |
| 17:19 | gfredericks | hiredman: and the macro has to resolve the interface name |
| 17:20 | hiredman | gfredericks: why? |
| 17:20 | gfredericks | hiredman: else it's just a symbol. |
| 17:20 | hiredman | for the function? |
| 17:20 | gfredericks | yeah |
| 17:20 | hiredman | ,(resolve 'String) |
| 17:20 | clojurebot | java.lang.String |
| 17:20 | hiredman | thats how you do it |
| 17:20 | gfredericks | are there complications when the macro is in one ns and the call is in another? |
| 17:21 | hiredman | resolve is relative to the value of *ns* when resolve is called |
| 17:21 | gfredericks | I guess I can try this out pretty easily... |
| 17:21 | hiredman | which will be the current ns, not the one where the macro is defined |
| 17:21 | gfredericks | oh |
| 17:22 | hiredman | yeah, try it out, stop making problems up, you will hit plenty of real ones as you code |
| 17:22 | gfredericks | so if the calling ns has imported the interface name, and is using the short name, then resolve won't work? |
| 17:22 | hiredman | it will |
| 17:22 | hiredman | (import 'clojure.lang.RT) |
| 17:22 | hiredman | ,(import 'clojure.lang.RT) |
| 17:22 | clojurebot | clojure.lang.RT |
| 17:22 | hiredman | ,(resolve 'RT) |
| 17:22 | clojurebot | clojure.lang.RT |
| 17:23 | bartj | hi, is there any clojure library to find |
| 17:23 | gfredericks | hiredman: I mean when the calling ns imports, but the ns defining the macro doesn't |
| 17:23 | bartj | positions of HTML elements as rendered by Webkit, etc. |
| 17:24 | amalloy | gfredericks: just try it. it's super-easy to test that |
| 17:24 | hiredman | gfredericks: I already tried to explain that it would work, and obviously failed, so just try it |
| 17:25 | jcrossley3 | hi - is it possible to define a "once" test fixture for *all* the namespaces i'm running tests for? |
| 17:26 | stuartsierra | no |
| 17:26 | stuartsierra | sorry about that |
| 17:27 | jcrossley3 | stuartsierra: would it be difficult to implement? |
| 17:27 | stuartsierra | yes |
| 17:29 | jcrossley3 | stuartsierra: really? :) |
| 17:29 | stuartsierra | The way clojure.test is written right now, yes |
| 17:30 | jcrossley3 | stuartsierra: is it a common request? do most people work around it using test-ns-hook or something? |
| 17:31 | stuartsierra | you're the first :) |
| 17:31 | stuartsierra | that I know of |
| 17:31 | stuartsierra | I think people work around it by writing their own test drivers. |
| 17:32 | amalloy | when it's time for me to run tests, i call stuartsierra and have him run the once-hooks for me |
| 17:32 | stuartsierra | Huh, just like the Clojure release process. |
| 17:32 | technomancy | jcrossley3: nah, it's not uncommon. |
| 17:33 | stuartsierra | I'll take a patch, just don't have time to do it. |
| 17:33 | jcrossley3 | technomancy: any common solutions? |
| 17:34 | hugod | stuartsierra: would a patch for http://dev.clojure.org/jira/browse/CLJ-840 be likely to get applied? |
| 17:34 | technomancy | jcrossley3: some people write a hook for leiningen.test/form-for-testing-namespaces |
| 17:34 | technomancy | not the cleanest, but it works |
| 17:34 | stuartsierra | hugod: maybe |
| 17:36 | hugod | zi has an initScript parameter that gets called before running tests |
| 17:36 | stuartsierra | Test setup/teardown is almost always messy, no matter how you do it. |
| 17:36 | stuartsierra | hugod: just put a comment on CLJ-840 |
| 17:37 | hugod | stuartsierra: a comment about? |
| 17:37 | stuartsierra | I mean, I put a comment there |
| 18:00 | aaelony | I'm likely misunderstanding something. I'm seeking only to output when values equal "Profile" for a particular key. I believe I need filter for this, but first I sought to grab one row to test it. I see the key/value pair I want in this row, but the = function returns false rather than true as I expect. Just to investigate further, if I do (= "Profile" "Profile") I also get false, so I am surprised. Any help appreciated... http://pastie.org/265790 |
| 18:05 | arkh | troll? |
| 18:05 | clojurebot | according to troll lore living beings move backwards through time |
| 18:06 | hiredman | ~botsnack |
| 18:06 | clojurebot | Thanks, but I prefer chocolate |
| 18:06 | hiredman | clojurebot: jerk |
| 18:06 | clojurebot | Excuse me? |
| 18:06 | hiredman | clojurebot: you heard me |
| 18:06 | clojurebot | hiredman: I'm just giving you a second chance |
| 18:06 | hiredman | clojurebot: why I oughtta! |
| 18:06 | clojurebot | Titim gan éirí ort. |
| 18:08 | lpetit | the IRC version of SIRI ! |
| 18:09 | ibdknox | lol |
| 18:13 | srid | this way of looping through a structure to find something looks complicated, https://gist.github.com/1271458 - can it be simplified? |
| 18:13 | srid | the argument to loop, especially |
| 18:14 | amalloy | blurrrrgh |
| 18:14 | amalloy | can't you just use filter to get out the thing you want, and then call calculatesomething on it? |
| 18:14 | srid | why filter? i'm looking for that *one* item, not a subset of items |
| 18:14 | amalloy | (first (filter...)) |
| 18:15 | amalloy | &(inc (first (filter even? (range 11 20 3)))) |
| 18:15 | lazybot | ⇒ 15 |
| 18:16 | amalloy | &(* 2 (first (filter #{17} (range 11 20 3)))) ;; just that one item |
| 18:16 | lazybot | ⇒ 34 |
| 18:18 | srid | amalloy: ok that works |
| 18:19 | srid | here's the final version: https://gist.github.com/1271472 |
| 18:28 | tsdh | Hi. I have a seq like [:a [1 2] :b [4 5]] and want to calculate a seq of maps like [{:a 1 :b 4} {:a 1 :b 5} {:a 2 :b 4} {:a 2 :b 5}]. How do I do so? |
| 18:30 | tsdh | Basically I have some kind of binding vector at runtime and want to do something like `for': create a seq of bindings where each binding is represented as a map. |
| 18:32 | amalloy | tsdh: i think you want `combinations` (which is in contrib somewhere) and `zipmap` |
| 18:32 | amalloy | or i guess it's less like combinations and more like cartesian product |
| 18:33 | amalloy | ie, take a/b out entirely till you have [[1 2] [4 5]], compute the cartesian product, and then reintroduce a/b with a zipmap |
| 18:34 | tsdh | amalloy: Ok, I'll have a look. |
| 18:38 | tsdh | amalloy: Cool, cartesian-product does the trick. :-) |
| 18:40 | tsdh | amalloy: Mission completed: (map #(zipmap [:a :b] %) (cartesian-product [1 2 3] [4 5 6])) |
| 18:40 | amalloy | yep |
| 18:40 | tsdh | :-) |
| 20:18 | cgray | how do i replace the nth element of a vector? |
| 20:20 | amalloy | &(doc assoc) |
| 20:20 | lazybot | ⇒ "([map key val] [map key val & kvs]); assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector)." |
| 20:20 | cgray | cool, thanks. I thought that was only for maps |
| 20:46 | rimmjob | is there a good book on understanding jvm internals? |
| 20:46 | rimmjob | everything i find is about java lang :< |
| 20:47 | rimmjob | nvm i found http://www.amazon.com/Java-Virtual-Machine-Specification-2nd/dp/0201432943/ref=cm_lmf_tit_17 |
| 21:12 | khaliG | http://www.h3rald.com/articles/10-programming-languages/ <- i like how only one of the cool language has examples of apps written in it |
| 21:19 | amalloy | khaliG: i have to wonder which one you think that is? i see examples for squeak, clojure, and erlang at least |
| 21:21 | khaliG | amalloy, i was thinking Erlang |