2012-03-16
| 00:15 | jayunit100 | heyloo |
| 00:16 | johnmn3 | but I can't figure out to add an icon to a seesaw.core/dialog |
| 00:16 | jayunit100 | is there a spec somewhere for the clojure doc function? |
| 00:17 | jayunit100 | I notice there are different syntaxes (* & "seq-exprs" ...) ... |
| 00:17 | jayunit100 | so sometimes (doc foo) is not as revealing as i would like it to be. Maybe there is a methodology for interpreting clojure docs that im missing. |
| 00:20 | jmalone | to johnmn the :content on the seesaw.core/dialog can a component or a panel which you could put the icon in |
| 00:22 | johnmn3 | I have a vertical-panel but it doesn't accept an :icon key. |
| 00:23 | johnmn3 | Which panel might work? |
| 00:24 | johnmn3 | I want to get a hold of the frame of the dialog window |
| 00:26 | johnmn3 | Which I think is something like (config! (to-root my-dialog) :icon (seesaw.icon/icon ... |
| 00:26 | jmalone | hmm |
| 00:27 | johnmn3 | But my-dialog is a function |
| 00:27 | jmalone | well i can get icons to load on the dialog if the :content is an icon |
| 00:27 | jmalone | for example |
| 00:27 | johnmn3 | because that's how menu wants it |
| 00:27 | johnmn3 | I can get icons in the dialog.. but the title of the dialog window... |
| 00:28 | jmalone | (dialog :content (icon "http://i.imgur.com/89BC9.jpg"))) |
| 00:28 | jmalone | oh the title of the dialog window? |
| 00:28 | johnmn3 | yea |
| 00:28 | johnmn3 | it's still a java cup |
| 00:29 | johnmn3 | so I think you gotta get at the root with to-root |
| 00:29 | johnmn3 | the root frame of the dialog window |
| 00:29 | jmalone | that might be right |
| 00:29 | johnmn3 | but my-dialog is a function that returns a new dialog frame each time it's run |
| 00:30 | johnmn3 | I need to (def a-dialog (my-dialog)) |
| 00:30 | johnmn3 | so that I can (config! (to-root a-dialog) ... |
| 00:32 | johnmn3 | but its a button in the menu, which expects a function for its :handler |
| 00:34 | groovemonkey | hi guys, I'm doing (.listfile (java.io.File. filepath)) where filepath is a string with a path to the folder containing the files I want to list |
| 00:34 | jmalone | there is a custom-dialog function that takes default & frame options |
| 00:35 | groovemonkey | but I'm getting an IllegalArgumentException "no matching field found -- listfile for class java.io.File" |
| 00:37 | groovemonkey | any ideas? |
| 00:38 | groovemonkey | user=> (.listfile (java.io.File. filepath)) |
| 00:38 | groovemonkey | IllegalArgumentException No matching field found: listfile for class java.io.File clojure.lang.Reflector.getInstanceField (Reflector.java:289) |
| 00:38 | jmalone | isn't it listFiles? |
| 00:40 | groovemonkey | jmalone, same error. |
| 00:42 | groovemonkey | user=> (.listfiles (java.io.File. filepath)) |
| 00:42 | groovemonkey | IllegalArgumentException No matching field found: listfiles for class java.io.File clojure.lang.Reflector.getInstanceField (Reflector.java:289) |
| 00:42 | jmalone | capatlize the F |
| 00:43 | stirfoo | I think this is a bug in the reader "\41q". It hangs when it should return "!q". Can someone confirm this please. |
| 00:51 | jmalone | http://stackoverflow.com/questions/8566531/listing-files-in-a-directory-in-clojure |
| 00:52 | johnmn3 | jmalone: thanks. I tried (costum-dialog :parent my-frame :content (etc... |
| 00:52 | johnmn3 | but that didn't give it the icon in the title |
| 00:53 | johnmn3 | oh wait |
| 00:53 | johnmn3 | I could just juse frame instead of dialog, right? |
| 00:53 | jmalone | yeah |
| 00:53 | johnmn3 | it's basically just an alert box |
| 00:53 | johnmn3 | I just want that new frame to close when the user clicks a button (OK) |
| 00:55 | jmalone | set a listener and that triggers dispose! |
| 00:55 | jmalone | not sure about the dispose! |
| 00:56 | jmalone | im looking at the docs now |
| 01:18 | johnmn3 | jmalone: I got it. I'm just making the user X the window to close |
| 01:30 | sorenmacbeth | Is there a way that I can pass a method name as a string to a Java object |
| 01:30 | sorenmacbeth | something like (. "methodName" (String.)) |
| 01:30 | sorenmacbeth | (. (symbol "methodName") (String.)) doesn't work |
| 01:31 | wmealing | does the java object accept a string arg ? (obvious question) |
| 01:31 | wmealing | im no java programmer... just wondering |
| 01:33 | wmealing | just sounds like an odd way to do it. |
| 01:34 | carlo_au | Java doesn't have an eval() does it? (another non-Java programmer here) |
| 01:34 | wmealing | i think you maybe can do "apply" to do something similar carlo_au . |
| 01:34 | sorenmacbeth | what I want to do is create that method name call in a macro |
| 01:35 | carlo_au | wmealing: you mean Clojure's 'apply'? |
| 01:35 | wmealing | i mean apply, like it runs functions based on strings |
| 01:36 | wmealing | like in erlang apply(Module,Function, Args) |
| 01:36 | wmealing | not really an eval so to speak |
| 01:36 | wmealing | but it still runs the code that you specify. |
| 01:36 | jmalone | the tilde ~ unquotes things im not sure if thats what you are looking for though |
| 01:38 | muhoo | well clojure west tomorrow. preparing to drink from the firehose. |
| 01:53 | spn | @sorenmacbeth I believe you can use Java reflection. It would look something like: |
| 01:53 | spn | Bank.getMethod("deposit").invoke(obj) |
| 01:54 | spn | Bank.getMethod("deposit").invoke(obj, 300) i meant |
| 01:54 | sorenmacbeth | spn: thanks, I'll try that |
| 02:19 | muhoo | i'm looking at this example from the joy of clojure book, and it's making me go, ugh, is this really the most clear way to do this? https://refheap.com/paste/1092 |
| 02:19 | muhoo | (vec (map #(vec |
| 02:20 | muhoo | then a for inside of that |
| 02:20 | muhoo | took me like 15 minutes to figure out wtf it does |
| 02:20 | technomancy | ibdknox: http://allrecipes.com/recipe/chicken-korma-ii/ is second place when I search for korma now |
| 02:20 | technomancy | looks like you're slipping =O |
| 02:23 | muhoo | where did you go for korma, and was it good? |
| 02:27 | technomancy | Tandoori Oven; it was pretty good |
| 02:30 | cemerick | muhoo: ^^ seconded; very good Indian there. |
| 02:30 | clojurebot | I don't understand. |
| 02:31 | muhoo | thanks |
| 03:54 | raek | muhoo: I would write that piece of code like this: https://refheap.com/paste/1094 |
| 03:54 | tsdh | I get Error 310 (net::ERR_TOO_MANY_REDIRECTS) when trying to browse www.clojure.org. Do you see that, too? |
| 03:56 | raek | 'map' + anonymous function and 'for' can be used interchangeably here, but I don't see any reason to mim them here |
| 03:56 | raek | *to mix |
| 04:05 | dsabanin | hi guys! |
| 04:07 | dsabanin | I'm just starting with clojure, but have this weird understanding issue with a really simple function |
| 04:10 | dsabanin | I have a function like this: http://pastie.org/3606636 |
| 04:10 | dsabanin | I have a function like this: http://pastie.org/3606636 |
| 04:10 | dsabanin | I have a function like this: http://pastie.org/3606636 |
| 04:11 | dsabanin | I've a function like this http://pastie.org/3606636 |
| 04:11 | dsabanin | http://pastie.org/3606636 |
| 04:12 | dsabanin | I can't post here for some reason |
| 04:12 | dsabanin | hmm |
| 04:12 | dsabanin | http://pastie.org/3606636 |
| 04:12 | dsabanin | for some reason pastie URL isn't getting posted http://pastie.org/3606636 |
| 04:12 | raek | dsabanin: you have posted the same line six times |
| 04:12 | dsabanin | really? |
| 04:12 | dsabanin | I'm very sorry |
| 04:12 | dsabanin | my IRC client seems to be broken |
| 04:12 | raek | anyway, the problem is at line 4 |
| 04:12 | dsabanin | stupid thing |
| 04:13 | raek | dsabanin: do you see what happens with the result of thr set-connection! call? |
| 04:13 | raek | *the |
| 04:13 | dsabanin | oh damn :) |
| 04:13 | dsabanin | thank you! |
| 04:14 | dsabanin | it works! :) |
| 04:14 | dsabanin | I don't know how it got there.. |
| 04:14 | dsabanin | I guess I tuned out parantheses way too early :D |
| 04:15 | raek | the code was loaded through a require call and not entered through the repl, you should get line numbers in the stacktrace |
| 04:15 | raek | *if the code |
| 04:16 | dsabanin | to be honest, coming from ruby, the stacktraces are somewhat confusing in clojure, have to get used to them |
| 04:22 | raek | dsabanin: what are the biggest differences between ruby and clojure stacktraces? |
| 04:23 | tsdh | Interop question: Is there a way to specify a java method that should get a (clj) function of arity 2, instantiate it with 2 args, and call it? (Well, without using IFn directly, I mean.) |
| 04:25 | tsdh | I could create a java Function interface and reify it from clojure, I guess... |
| 04:26 | raek | why not use IFn direclty? |
| 04:27 | raek | void fooMethod(IFn clojureFunction) { ... clojureFunction.invoke(arg1, arg2); ...} |
| 04:27 | raek | and what do you mean by "instantiate"? |
| 04:27 | tsdh | raek: We don't want a clojure dependency in the java project. |
| 04:29 | tsdh | raek: My intent is to be able to fiddle with internal fields. So I'd like to have a method on the java side that gets a function of 2 args and then does new Function(internal1, internal2).call(); or something like that. |
| 04:29 | raek | then it recevides a class? |
| 04:31 | raek | I think you have to introduce a new function abstraction if you really cannot reuse the clojure one |
| 04:31 | tsdh | Hm, well, basically I don't care too much. If it gets a FooFoo object and then calls myFooFoo.call(internal1, internal2) that's fine as well. |
| 04:32 | raek | the second approach is how I would have done it |
| 04:32 | raek | then you don't need to use reflection to find the cnstructor, etc |
| 04:33 | tsdh | Ok, so an OnInternalField interface in java land that I can reify from clojure, right? |
| 04:33 | raek | that should be simple from both java and clojure |
| 04:33 | tsdh | Great, thanks. |
| 05:26 | stirfoo | Can someone put "\41q" in their repl? That's a *single* backslash. It might hang... |
| 05:36 | clgv | stirfoo: java.lang.IllegalArgumentException: Invalid digit: q |
| 05:37 | clgv | stirfoo: backslash via "\\" like ##(print "\\") |
| 05:37 | lazybot | ⇒ \nil |
| 05:37 | stirfoo | clgv: did you type in the quotes as well (a literal string with an octal escape) |
| 05:37 | clgv | yes, I did |
| 05:37 | amalloy | stirfoo: what character are you hoping that will be? |
| 05:37 | stirfoo | amalloy: I think it's a bug in the reader |
| 05:37 | amalloy | i doubt it, and you didn't answer my question |
| 05:38 | stirfoo | an octal escape can be specified by \ followed by 1, 2, or 3 octal digits |
| 05:38 | stirfoo | amalloy: it should output "!q" to the repl |
| 05:38 | clgv | ,(println "\41") |
| 05:38 | clojurebot | ! |
| 05:39 | stirfoo | now put a q after the 1 |
| 05:39 | clgv | ,(.println System/out "\41q") |
| 05:39 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Invalid digit: q> |
| 05:39 | stirfoo | I was going to do that but I dont want to lock up someones bot |
| 05:40 | stirfoo | see, I think it *is* a bug in the reader |
| 05:40 | clgv | seems more like a bug in java |
| 05:40 | stirfoo | no, there is a variable called exact that gets set to null, and it's not checked in an inner loop, only after the loop has terminated |
| 05:41 | stirfoo | s/null/false/ |
| 05:42 | clgv | hm ok., read-string cant cope with it: ##(read-string "\41q") |
| 05:42 | clgv | ,(read-string "\41q") |
| 05:42 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Invalid digit: q> |
| 05:43 | stirfoo | the code tries to evaluate the q as an octal digit, when it should push it back into the stream and return ! |
| 05:43 | stirfoo | but it's not checking the exact parameter |
| 05:43 | clgv | make an issue and patch it^^ |
| 05:44 | stirfoo | clgv, thanks for verifying it |
| 05:44 | clgv | stirfoo: do you have the link to the source at hand? |
| 05:45 | stirfoo | no, I have a local copy |
| 05:45 | amalloy | stirfoo: include a mention of the relevant section of the JLS, 3.10.6 |
| 05:45 | amalloy | (and probably also mention that the reader claims standard java escapes are supported) |
| 05:46 | stirfoo | are three digits required in java? |
| 05:46 | clgv | I wonder why it doesnt use java's implementation for these escapes... |
| 05:46 | amalloy | stirfoo: no |
| 05:46 | amalloy | clgv: because that would be really hard? and require a jdk to run clojure? |
| 05:47 | clgv | a what? |
| 05:47 | amalloy | $google jdk |
| 05:47 | lazybot | [Java SE Downloads] http://www.oracle.com/technetwork/java/javase/downloads/index.html |
| 05:48 | clgv | ah right. thats a compiler thing and no runtime interpretation |
| 05:48 | clgv | s/a/erm/ |
| 05:48 | clgv | ;) |
| 06:15 | stirfoo | is google's clojure-dev group read-only, invite-only, gtfo-my-lawn only? ;) |
| 06:31 | tsdh | How can I call (Arrays/copyOfRange ary 0 idx) non-reflectively? Hinting ary as ^objects doesn't help... |
| 06:33 | tsdh | Ah, got it. I need to wrap the indices in (int ...). |
| 06:49 | casperc | I have been wondering, why does the clojure compiler not check the number of arguments for function calls when possible? |
| 06:50 | casperc | it would seem that it is quite possible to do in most cases (defining a function and then calling it) |
| 06:50 | bsteuber | casperc: in theory it is possible that the fn gets exchanged at run time |
| 06:51 | bsteuber | but yes, should at least give a warning ^^ |
| 06:51 | casperc | maybe some strict compilation switch |
| 06:52 | stirfoo | "\41q" fix => http://paste.lisp.org/display/128373 |
| 06:52 | casperc | thing is, the wrong number of argument error is hard to avoid, even in production unless you are sure every code patch has been hit beforehand, which is hard to ensure |
| 06:54 | bsteuber | unit tests ^^ |
| 06:54 | bsteuber | but sure |
| 07:13 | clgv | casperc: that could be an external IDE feature |
| 07:40 | jaley | what should one extend to add an implementation of some protocol to clojure maps? hopefully not PersistentHashMap, PersistentArrayMap, etc all seperately...? |
| 07:43 | bsteuber | jaley: you can extend protocols on interfaces, but.. |
| 07:43 | bsteuber | when two interfaces match there seems to be no guarantee which one will be called |
| 07:44 | bsteuber | even if one inherits from the other |
| 07:45 | jaley | bsteuber: ok. so is there some common interface that all the maps implement>? |
| 07:49 | _ato | jaley: clojure.lang.Associative |
| 07:49 | jaley | _ato: cool! thanks! |
| 07:52 | llasram | That might work, but IPersistentMap is probably closer |
| 07:52 | _ato | yeah depends on how strictly map like you want |
| 07:52 | _ato | Associative covers vectors too as they can treated like a map |
| 07:53 | _ato | ILookup -> Associative -> IPersistentMap |
| 07:53 | bsteuber | jaley: ah maybe you should use APersistentMap instead of the interface |
| 07:54 | bsteuber | then even overlapping classes will be fine later |
| 07:54 | jaley | bsteuber: ah that's a good idea |
| 07:54 | jaley | _ato, bsteuber thanks for the help guys |
| 08:17 | jaley | ok... what am I doing wrong with extend-type? https://refheap.com/paste/1095 |
| 08:21 | raek | old implementations of the protocol, perhaps? |
| 08:21 | raek | jaley: does it work if you reload the namespace? |
| 08:22 | jaley | raek: hmm well I did already try killing swank and reconnecting. is there something else i can do to make sure? |
| 08:25 | raek | jaley: it worked in my repl |
| 08:26 | llasram | If you're doing any AOT compilation, make sure that you don't have stale class files for the protocol interface sitting around |
| 08:26 | raek | are you sure you restarted the swank server? |
| 08:26 | llasram | Otherwise, like raek it also works in my fresh REPL |
| 08:26 | raek | llasram: good point! |
| 08:26 | jaley | raek: well i just re-ran jack-in and it asked to terminate the old session |
| 08:26 | jaley | llasram: ok cool, must be soemthing stale somewhere. i'll try lein clean |
| 08:28 | jaley | llasram: ah yeah... somewhere in my code there's a gen-class |
| 08:29 | llasram | Kill it! Kill it with fire! |
| 08:29 | raek | interactive development + AOT compilation = :( |
| 08:30 | jaley | raek: I possibly don't need it any more actually |
| 08:30 | llasram | If deftype supported specifying alternate constructors, I could drop my every remaining use of gen-class |
| 08:30 | llasram | That would make me so very happy |
| 08:31 | jaley | llasram: does lein's :main attribute cause AOT to occur? |
| 08:32 | raek | jaley: yes |
| 08:32 | llasram | You can disable that though |
| 08:32 | raek | but I only think it performs the compilation when you run "lein run", or "lein jar" |
| 08:33 | jaley | raek: ok that shouldn't get in the way of my slime evals then? |
| 08:34 | llasram | It's probably documented elsewhere too, but in the lein sample.project.clj, it notes that you can set the {:skip-aot true} metadata on the symbol provided for :main to prevent AOT compilation of the namespace |
| 08:34 | raek | jaley: not sure. but previous run/jar runs still leave files in classes/ though |
| 08:34 | jaley | llasram: ah ok cool, thanks |
| 08:34 | raek | I find lein javac useful for interfacing with Java |
| 08:35 | raek | implement the class that the java code needs in java, and let the clojure code reify an interface |
| 08:36 | Hali_303 | hi! when I get an exception during a use :reload-all, how do I know which line is causing the problem? |
| 08:37 | Hali_303 | I see the backtrace in the emacs buffer, but how do I find out where is the problem? |
| 08:37 | Hali_303 | the backtrace itself is full of clojure.core stuff without any locals as a hint |
| 08:39 | raek | what does the exception message say? |
| 08:39 | raek | compile time exceptions are often much harder to read |
| 08:42 | Hali_303 | raek: it said sg like cannot convert from a Boolean to a Symbol |
| 08:42 | Hali_303 | and the problem was, that I've messed up my use/require statements |
| 09:17 | jweiss | Raynes: just saw lazybot's new refheap pasting - nice! just noticed a minor issue on refheap: "Throw some text in that big white box over on the left" but the box is black :) |
| 09:18 | jweiss | oh, i can just add a github issue :) |
| 10:43 | ibdknox | technomancy: oh no's! the FOOD IS WINNING. |
| 10:43 | ibdknox | totally unacceptable |
| 11:00 | jodaro | aww yeah |
| 11:00 | jodaro | south to west |
| 11:00 | jodaro | clojure west, that is |
| 11:02 | joly | the Conj was wonderful. Wish I could have made West |
| 11:02 | dabd | to find the appropriate leiningen dependencies for the new contrib modules should I use 'lein search <namespace>'? |
| 11:03 | TimMc | ibdknox: Are you backchanneling from Clojure/West? |
| 11:06 | raek | dabd: yes, that's probably the easiest way (once the maven indexes are downloaded) |
| 11:07 | raek | artifact names (but not versions) are listed here: http://dev.clojure.org/display/doc/Clojure+Contrib |
| 11:09 | raek | so "lein search java.jdbc" finds [org.clojure/java.jdbc "0.1.1"] and other versions, but you won't find anything with "lein search clojure.contrib.sql" |
| 11:10 | dabd | raek: that means I can search for the new namespaces only? thx |
| 11:12 | clgv | dabd: new libraries not namespaces |
| 11:12 | raek | dabd: technically, you don't search for the namespace name. you search for the new project name. |
| 11:13 | raek | dabd: see this page for a mapping from old namespace to new libraries: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 11:16 | choffstein | Hey all. Anyone have any experience using congomongo in conjunction with another mongo wrapper from another language, like Mongoid? I am using embedded documents in mongoid and can't seem to find any tutorials about how to update / create / destroy them in congomongo |
| 11:32 | dabd | i tried 'lein search combinatorics' but it didn't find anything. I was expecting it to find clojure.math.combinatorics |
| 11:33 | ibdknox | dabd: I think lein search only looks at clojars, and the contrib libs go to maven central |
| 11:35 | clgv | dabd: I think you have to search for the entire artifact name - I guess it's clojure.math.combinatorics |
| 11:37 | geoffeg_c | this conference does not have the stickers i wanted |
| 11:40 | TimMc | ibdknox: Pertty sure it searches central as well. |
| 11:43 | technomancy | TimMc: true. if it doesn't catch combinatorics it's probably tokenization |
| 11:56 | clgv | geoffeg_c: lol what do you mean? :P |
| 11:57 | geoffeg_c | clgv: well, i found the clojure sticker but the github sticker is not what i had wanted.. i wanted a plain github sticker.. also.. i want a heroku sticker :) |
| 11:57 | clgv | hehe. how is the conference so far? |
| 11:58 | xeqi | clgv: technomancy had some heroku stickers last night |
| 11:58 | xeqi | geoffeg_c: ^ |
| 11:58 | clgv | oh wait. it is a just about to start, right? |
| 11:58 | geoffeg_c | right |
| 11:58 | geoffeg_c | best part so far: power strips under the tables |
| 12:02 | raek | ibdknox: lein search looks in maven centeral too |
| 12:02 | dnolen | are folks watching the Clojure/west keynote? |
| 12:02 | clgv | is there a livestream? |
| 12:03 | raek | oh, TimMc already said that |
| 12:03 | dnolen | jonasen: I'm planning on looking into how to fix the anon fn rules - should give you a starting point for designing more complex rules for Kibit |
| 12:06 | ibdknox | TimMc: I am :) |
| 12:06 | ibdknox | raek: TimMc: I stand corrected. |
| 12:06 | gozala | Hi folks I'm trying to figure out what's a diff between defrecord and deftype if any |
| 12:07 | gozala | do you know any good pointers to read about this ? |
| 12:08 | dnolen | gozala: defrecord work as maps |
| 12:08 | TimMc | gozala: cemerick has a flowchart of this |
| 12:08 | clgv | gozala: deftype creates a plain java class with the methods you implement. defrecord adds a full map implementation to that |
| 12:09 | gozala | so defrecord is more like an instantiation ? |
| 12:10 | technomancy | deftype is for if you are implementing Clojure |
| 12:10 | uvtc | this looks like the link to that flowchart: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/ |
| 12:10 | dnolen | gozala: no, defrecord is like deftype with a lot of things defined for you - specifically map-like stuff |
| 12:11 | technomancy | defrecord is for if you think maps are too slow but don't have a good understanding of profiling and bottlenecks. =D |
| 12:11 | ibdknox | lol |
| 12:11 | clgv | gozala: defrecord is (almost completely) like a clojure map but you can implement protocols for it |
| 12:11 | gozala | technomancy: what if I'd like to create my own abstraction |
| 12:11 | technomancy | probably defn |
| 12:11 | ibdknox | gozala: abstraction over what? |
| 12:11 | gozala | I guess I need to use deftype for that unless it's map like thing ? |
| 12:12 | ibdknox | you mean your own datatype? |
| 12:12 | ibdknox | er, datastructure, rather? |
| 12:12 | gozala | I'm trying to define eventual value abstraction |
| 12:12 | gozala | which I'd like to implement for all existing datatypes |
| 12:13 | gozala | and have my own special type |
| 12:13 | dnolen | gozala: you can define your own abstractions with maps + multimethods, and it will be more portable across Clojure implementations. |
| 12:13 | gozala | that handles it differently |
| 12:14 | ibdknox | eventual value? like a delay? |
| 12:14 | ibdknox | ,(doc delay) |
| 12:14 | ibdknox | &(doc delay) |
| 12:14 | lazybot | ⇒ "Macro ([& body]); Takes a body of expressions and yields a Delay object that will invoke the body only the first time it is forced (with force or deref/@), and will cache the result and return it on all subsequent force calls. See also - realized?" |
| 12:15 | ibdknox | hm |
| 12:15 | ibdknox | just slow |
| 12:15 | uvtc | I like how lazybot "delayed" that response... |
| 12:15 | gozala | ibdknox: sort of but |
| 12:15 | gozala | more like promises |
| 12:15 | dnolen | gozala: Clojure has promises |
| 12:15 | gozala | but promises in clojure don't seem to suite cljs very well |
| 12:15 | ibdknox | ,(doc promise) |
| 12:15 | dnolen | gozala: that is true. |
| 12:16 | ibdknox | you should've said you wanted to use cljs :p |
| 12:16 | gozala | so I'd like to do non-blocking promises for cljs |
| 12:16 | ibdknox | how would that work? |
| 12:16 | gozala | the way it works in js |
| 12:16 | AWizzArd | That is more like a future. |
| 12:16 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class clojure.lang.RT> |
| 12:16 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class clojure.lang.RT> |
| 12:16 | gozala | using event loop and listeners |
| 12:16 | seancorfield | clojurebot is sick :( |
| 12:17 | ibdknox | hiredman: ^ |
| 12:17 | gozala | but that's more like a learning experience to me |
| 12:19 | jaley | what am i doing wrong? I have a quoted var pointing at a function, and i want the function. unquote is apparently not what i want? |
| 12:20 | ibdknox | jaley: deref |
| 12:20 | ibdknox | jaley: or @ |
| 12:20 | technomancy | or just use the var |
| 12:20 | ibdknox | or that |
| 12:20 | clgv | jaley: var-get gets you the value |
| 12:20 | mdeboard | god dammit comcast has been sucking ass lately |
| 12:21 | mdeboard | whoops |
| 12:21 | mdeboard | wrong window, sorry |
| 12:21 | mdeboard | s/window/buffer |
| 12:21 | jaley | errr.. cannot cast symbol to var. seems I have a symbol. sorry |
| 12:21 | clgv | jaley: you can 'resolve that symbol |
| 12:22 | jaley | clgv: and then deref? |
| 12:22 | jaley | got it. thanks all! |
| 12:41 | gfredericks | &'ping |
| 12:41 | lazybot | ⇒ ping |
| 12:43 | duck1123 | has anyone been having issues with lein 1.7.0 not finishing the compile step? It may just be something with my code, but I'm not sure |
| 12:43 | clgv | duck1123: lein 1.7 needs a lot of time here for cleaning the "classes" folder. I help it by deleting it first^^ |
| 12:45 | mk270 | is there an abbreviation for (list foo bar baz) ... i seem to have a lot of "(list " in my code and it doesn't feel right |
| 12:45 | clgv | '(foo bar baz) |
| 12:46 | mk270 | i'm not sure i wanted to quote everything - is that the same? |
| 12:46 | clgv | yes that is a list without the 'list at the beginning |
| 12:46 | raek | mk270: you often uses vectors for sequence literals |
| 12:47 | raek | it is considered ideomatic to write [foo bar baz] instead of (list foo bar baz), assuming just need a sequence of some sort |
| 12:48 | mk270 | ah thanks. i shall do it that way :) |
| 12:49 | duck1123 | clgv: I usually do "lein clean, deps, compile, midje, run" and it stops just after the compile step. It's probably something in my code that's starting at compile time, but I wanted to see if it was a known problem |
| 12:50 | clgv | oh |
| 12:50 | raek | duck1123: I heard the folks in #leiningen talking about something that sounds a lot like your problem |
| 12:50 | technomancy | raek: yeah, someone reported a bug where a GC in clean added for Windows compatibility makes it unbelievably slow on projects with lots of AOT |
| 12:51 | seancorfield | AOT bad :) |
| 12:51 | ibdknox | lein run does it by default :p |
| 12:51 | technomancy | seancorfield: ...two legs good! |
| 12:51 | jonasen | dnolen: That'll be very interesting. |
| 12:51 | technomancy | ibdknox: you can use lein run -m |
| 12:51 | technomancy | or set :skip-aot |
| 12:51 | duck1123 | AOT is bad, but if you are trying for interop with a library that scans the classpath for class files that implement an interface... |
| 12:52 | ibdknox | technomancy: I added ^{:skip-aot true} for everything |
| 12:52 | ibdknox | :) |
| 12:52 | technomancy | ibdknox: partial aliases can address that to |
| 12:52 | ibdknox | oh? |
| 12:52 | technomancy | lein launch -> lein run -m myproject.web |
| 12:52 | ibdknox | ah |
| 12:53 | ibdknox | I assume there's some fix we can do for the GC call |
| 12:54 | dnolen | jonasen: we'll see, hopefully it'll let you guys get to the next level with what type of rules you can specify. |
| 12:54 | technomancy | ibdknox: depends on whether you want to run from source |
| 12:55 | ibdknox | technomancy: ah, it's already fixed then? |
| 12:55 | technomancy | well |
| 12:55 | clgv | technomancy: in my project the jars main file draws in a low for AOT transitively |
| 12:55 | technomancy | ibdknox: it's easy enough to comment out the GC call |
| 12:55 | ibdknox | oh haha :) |
| 12:55 | technomancy | or maybe wrap it in a (when (windows?) ...) |
| 12:56 | technomancy | actually if someone could confirm that fixes it that would be super |
| 12:56 | clgv | technomancy: is there a possibility to avoid that transitive AOT? |
| 12:56 | duck1123 | was this just recently added? Would it be worth it to try downgrading my lein? |
| 12:56 | xeqi | technomancy: I can confirm removing the gc call makes lein faster |
| 12:57 | technomancy | duck1123: I think it's new in 1.7.0 |
| 12:57 | xeqi | the gc call forces FullGCs each time on my ubuntu/vagrant box |
| 12:57 | technomancy | xeqi: thanks |
| 12:57 | technomancy | yeesh |
| 12:57 | xeqi | "forces" as in the jvm decides to do it |
| 12:57 | technomancy | clgv: you can use runtime require/refer in your main ns |
| 12:58 | duck1123 | it has been getting very much slower, but I've been blaming myself for that |
| 12:58 | technomancy | now you can blame windows! |
| 12:58 | ibdknox | screw windows :p |
| 12:59 | clgv | technomancy: ah ok thanks. |
| 12:59 | dnolen | romanandreg: nice looking patch - but it causes some CLJS tests to fail. if you can address that we can merge in your patch. |
| 12:59 | TimMc | clgv: Wait, you're just trying to avoid AOT? |
| 12:59 | clgv | technomancy: and why did the "lein clean" get so slow? is that the windows bug you are currently talking about? |
| 13:00 | romanandreg | dnolen: oh… right, tests! ups hehe, going to check those out for sure later in the day, thanks for the feedback |
| 13:00 | technomancy | clgv: yeah, apparently without it Windows doesn't release file handles or something |
| 13:00 | dnolen | romanandreg: np |
| 13:00 | clgv | TimMc: yeah. my jars main draws in almost all of my code for AOT |
| 13:00 | clgv | ah ok |
| 13:00 | technomancy | clgv: oh man; you are in luck |
| 13:00 | technomancy | TimMc has just the thing for you |
| 13:01 | TimMc | clgv: lein-otf |
| 13:01 | seancorfield | clgv: consider AOT compile for main only and dynamically resolve everything else |
| 13:02 | clgv | TimMc: interesting. have to try that one |
| 13:02 | duck1123 | this won't work for gen-class that pulls in everything, will it? |
| 13:03 | seancorfield | we AOT compile our log4j appender but it resolves a call to the main logic at runtime - so no AOT explosion |
| 13:03 | seancorfield | time to switch rooms at clojure/west... back online later |
| 13:16 | TimMc | Yeah, lein-otf only helps you avoid AOT infection from the -main of an uberjar. |
| 13:16 | TimMc | But you can use the same technique directly. |
| 13:34 | jonasen | dnolen: I'm constantly looking for more ways to use core.logic. For example https://github.com/jonase/kibit/commit/fa2539b524ce1d10415a938b54735f09baef83aa |
| 13:35 | jonasen | dnolen: one line of logic can achieve much :) |
| 13:37 | dnolen | jonasen: so true! glad you're digging in with such a cool tool :) |
| 13:43 | ieure | (doc first) -> Unable to resolve symbol: doc in this context |
| 13:43 | ieure | Did this change in 1.3 or something? |
| 13:43 | clojurebot | "([coll]); Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil." |
| 13:43 | duck1123 | doc moved to clojure.repl, so you'll have to use that first |
| 13:43 | jodaro | ieure: (use 'clojure.repl) |
| 13:44 | ieure | Thanks. |
| 13:44 | technomancy | ieure: or C-c C-d C-d |
| 13:44 | choffstein | Hmmm, anyone know why a macroexpand-1 can expand a macro exactly how I want, but on compilation I get "Don't know how to create ISeq from: clojure.lang.Symbol"? |
| 13:44 | ieure | choffstein, Because macroexpand doesn't evaluate the expansion. |
| 13:45 | choffstein | Here's a gist: https://gist.github.com/2051381 |
| 13:45 | choffstein | (macroexpand-1 '(enqueue-job-m "test" "expanded-name" "job-id" ["arg1" "arg2"])) => (resque-clojure.core/enqueue "test" "expanded-name" "job-id" "arg1" "arg2"), which is exactly what I want... |
| 13:46 | ieure | choffstein, What happens if you eval the expansion? |
| 13:46 | choffstein | Ah, same error. Gotcha. |
| 13:48 | choffstein | Except just calling (resque-clojure.core/enqueue "test" "expanded-name" "job-id" "arg1" "arg2") from my repl works |
| 13:48 | choffstein | Which is just confusing as hell for me |
| 13:49 | jodaro | i mostly go to conferences for the bottomless cup of coffee |
| 13:54 | rlb | is clojure.contrib.core seqable? still the preferred source for that test? |
| 13:55 | dnolen | HOLY MOLY |
| 13:55 | dnolen | Clojure/core got accepted to GSoC 2012! |
| 13:55 | choffstein | The issue seems to be in ~@, since I don't have & args in the arg list. |
| 13:56 | choffstein | If I know an input will be a vector or list for a macro, can I splat it with ~@? |
| 13:57 | TimMc | dnolen: Way cool. |
| 13:58 | TimMc | choffstein: ##`(1 2 3 ~@[4 5 6]) |
| 13:58 | lazybot | ⇒ (1 2 3 4 5 6) |
| 13:58 | choffstein | Yeah, that's what I thought. This is just weird. |
| 13:59 | TimMc | &'ping |
| 13:59 | lazybot | ⇒ ping |
| 13:59 | choffstein | TimMc: Mind taking a look at this gist (https://gist.github.com/2051381) and see if there is anything obvious as to why ~@ is causing a compilation error? |
| 13:59 | TimMc | &`(1 2 3 ~@(range 4 7)]) |
| 13:59 | lazybot | java.lang.RuntimeException: Unmatched delimiter: ] |
| 13:59 | TimMc | &`(1 2 3 ~@(range 4 7)) |
| 13:59 | lazybot | ⇒ (1 2 3 4 5 6) |
| 14:00 | TimMc | choffstein: Is enqueue a macro? |
| 14:01 | choffstein | ...I actually don't know |
| 14:01 | choffstein | it's another library |
| 14:01 | TimMc | If it's a fn, use apply instead of making a splicing macro. |
| 14:01 | jaen | dnolen: was it? i'm still stalking the gsoc page |
| 14:06 | dabd | lein search downloaded the maven central index so I guess it searches it too |
| 14:07 | dabd | searching for the entire artifact name doesn't work either |
| 14:08 | dabd | 'lein search math' also does not find it. Who can fix lein search? |
| 14:10 | dabd | looking at the implementation the search function seems to use Lucene so it is strange that it does not work |
| 14:16 | dabd | technomancy: I opened an issue on leiningen github about lein search failing. thx |
| 14:18 | raek | dabd: I think you need to add a wildcard for inexact searches |
| 14:18 | raek | dabd: have you tried this? lein search 'math*' |
| 14:19 | raek | (I'm not familiar with the lucene query syntax) |
| 14:24 | dabd | raek: I am updating the index and will try the search with wildcards when it finishes. Does it work for you? |
| 14:27 | raek | it finds math.numeric-tower, math.combinatorics and some others for me |
| 14:31 | jaen | raek: unfortunately it doesn't seem to allow *math* as a valid query as per http://lucene.apache.org/core/old_versioned_docs/versions/3_0_0/queryparsersyntax.html |
| 14:34 | choffstein | is there a way with moustache to change the response type? |
| 14:35 | raek | choffstein: what do you mean by response type? |
| 14:35 | raek | content-type? |
| 14:36 | choffstein | well, it seems like I can do [""] {:get "ok"}, but if I do [""] {:get {:status 200 :body "ok"}}, it breaks -- which makes total sense, but I need to be able to return json data and tell the browser it is json data through the header. |
| 14:38 | raek | I usually do those things in the handler function or in middleware |
| 14:38 | dabd | lein search 'math*' works |
| 14:38 | choffstein | Oh, it seems like if I wrap it with a fn that takes a single arg (the req), I can do it... |
| 14:39 | raek | but you should be able to construct the response inline too |
| 14:39 | raek | a map does not mean response in all positions in moustache |
| 14:39 | choffstein | Yeah. Looks like I needed {:get (fn [req] {:status 200 :body "ok"})} |
| 14:40 | raek | there is a shorthand too |
| 14:40 | choffstein | I guess that makes a decent amount of sense, since moustache is asking for a handler |
| 14:40 | raek | maybe you need to wrap the innermost map in []s |
| 14:40 | raek | ok, a "handler-main" can be a literal ring response map |
| 14:41 | raek | the value in a method-dispatch map is a "shorthand-or-handler" |
| 14:41 | raek | ah, and a map is treated as a method-disptach there |
| 14:42 | raek | choffstein: this should work: [""] {:get [{:status 200 :body "ok"}]} |
| 14:42 | choffstein | I just tried that. Didn't like it... |
| 14:43 | raek | hrm |
| 14:43 | choffstein | Op .. it does! |
| 14:43 | choffstein | That was strange |
| 14:44 | raek | http://moustache.cgrand.net/syntax.html |
| 14:44 | choffstein | ah, nice. thanks |
| 14:44 | raek | implicitly, it's all there ;-) |
| 15:03 | rpt | Hi everyone, can anyone tell me what is wrong with this? http://cljbin.com/paste/4f638e38e4b0b0541f4c83dc |
| 15:04 | rpt | (a function meant to remove consecutive duplicates) |
| 15:04 | dnolen | it's official folks, http://www.google-melange.com/gsoc/accepted_orgs/google/gsoc2012 |
| 15:05 | mdeboard | rpt: What output do you expect and what do you get? What's sample input? |
| 15:06 | rpt | mdeboard: sample input [1 2 2 3 2 4 4], sample output [1 2 3 2 4] |
| 15:08 | mdeboard | Well the main problem I see is that you're just returning s |
| 15:08 | mdeboard | your final expression is the input |
| 15:08 | rpt | mdeboard: but s will only be returned if s has less than two elements? |
| 15:09 | mdeboard | Not in that code |
| 15:09 | rpt | mdeboard: (ie when (second s) is nil) |
| 15:12 | hhutch | dnolen: great news! |
| 15:12 | rpt | mdeboard: ah OK, got it |
| 15:12 | dnolen | hhutch: yes! |
| 15:12 | jaen | incidentally, how hard would it be to get into gdoc given you haven't done any open source work to date? |
| 15:14 | dnolen | jaen: now is a good time as any. |
| 15:14 | mdeboard | rpt: I assume this is just for a programming exercise, not an actual problem you're trying to solve |
| 15:14 | mdeboard | like production problem |
| 15:14 | rpt | mdeboard: yup, 4clojure probb |
| 15:14 | mdeboard | thought so! |
| 15:15 | rpt | mdeboard: what would you use in real life? |
| 15:15 | mdeboard | what number? |
| 15:15 | rpt | mdeboard: #30 |
| 15:15 | rpt | mdeboard: gotta go, tx for the help |
| 15:15 | jaen | dnolen: sounds half-encouraging, since I'm learning Clojure to write my neural networks assignment for univeristy and since Clojure got into gsoc, it looks like a good opportunity |
| 15:15 | mdeboard | gl;dd |
| 15:22 | georgek | hi, I'm trying to include a js library in a cljs project, using :foreign-libs [{:file "full/path/to/file" :provides ["namespace"]}], and then :require [namespace :as foo] in the cljs file, but when I load the page I get' Uncaught Error: Undefined nameToPath for ut.core' (ut.core being my namespace) |
| 15:23 | georgek | does foreign-libs only matter for advanced compilation? I'm working in development mode in cljs one |
| 15:25 | fliebel | How do you do integer division? Like the other part of the remainder. |
| 15:26 | Wild_Cat | fliebel: % ? |
| 15:26 | fliebel | &(% 10 4) |
| 15:26 | lazybot | java.lang.RuntimeException: Unable to resolve symbol: % in this context |
| 15:26 | fliebel | &(rem 10 4) |
| 15:26 | lazybot | ⇒ 2 |
| 15:27 | fliebel | But want I want is more like ##(int (/ 10 4)) |
| 15:27 | lazybot | ⇒ 2 |
| 15:28 | Wild_Cat | fliebel: sorry, mod |
| 15:28 | Wild_Cat | ?(mod 4 3) |
| 15:28 | Wild_Cat | ,(mod 4 3) |
| 15:28 | clojurebot | 1 |
| 15:28 | dnolen | fliebel: quot |
| 15:28 | dnolen | ,(quot 4 3) |
| 15:28 | clojurebot | 1 |
| 15:28 | dnolen | ,(quot 10 2) |
| 15:28 | clojurebot | 5 |
| 15:28 | fliebel | dnolen: thanks. |
| 15:42 | mk270 | gday - i don't understand map/apply in clojure. why does (apply println ["a" "b"]) put everything on the same line |
| 15:42 | mk270 | (what i want is the equiv of ocaml's List.iter print_endline ["a";"b";] |
| 15:44 | uvtc | mk270, apply unpacks the the 2nd arg and passes all of the items at once to the first arg (a fn). |
| 15:44 | Vinzent | mk270, because (println "a" "b") prints ab\newline |
| 15:44 | uvtc | mk270, map calls the fn on each item one at a time. |
| 15:45 | Vinzent | mk270, also, don't forget about lazyness: you should use either dorun with map or doseq |
| 15:45 | Vinzent | (in order to get your side-effects immediately) |
| 15:45 | mk270 | ok thank you both :) i shall now digest that |
| 15:46 | mk270 | what is lazyness? |
| 15:46 | mk270 | that surely isn't lazy evaluation a la haskell? |
| 15:47 | Vinzent | mk270, language itself isn't lazy, but sequences are |
| 15:47 | dnolen | mk270: many sequence operations in Clojure are lazy, to counter the lack of TCO on the JVM. |
| 15:47 | mk270 | ok |
| 15:48 | uvtc | mk270, lazyness is when you have a list, but the elements aren't figured out ahead of time. Clojure computes them as you ask for them. |
| 15:49 | uvtc | mk270, That way, you can have, say, a list "containing" an infinite list of even numbers, but it's not really infinite, because Clojure just figures out the *next* even only when you ask for it. |
| 15:49 | mk270 | ok - yes, it is what i thought it is |
| 15:49 | mk270 | i just didn't realise sequences were lazy |
| 15:50 | mk270 | all is now clear. fair enough. thank you |
| 15:51 | uvtc | mk270, Not all of them are. You can create them lazy in a number of ways, but working on them in certain ways will force them to be ... |
| 15:51 | uvtc | non-lazy. |
| 15:52 | uvtc | "fully-realized". Not sure what the correct term is. |
| 15:53 | fdaoud | hi everyone |
| 15:53 | fliebel | dnolen: How can I use an intermediate variable in a fd goal? Do I need to expose it, and let the caller specify a domain for it? |
| 15:53 | jmalone | hello |
| 15:53 | fdaoud | I have a "there's gotta be a better way" question.. |
| 15:54 | mk270 | uvtc: cheers |
| 15:54 | fdaoud | in a ring handler, I want to add a param to request :params. I have (handler (assoc request :params (merge (request :params) {:myaddkey "myaddvalue"}))) |
| 15:55 | fdaoud | is there a nicer way to do that? |
| 15:55 | Vinzent | fdaoud, update-in |
| 15:55 | dnolen | fliebel: not sure what you mean. |
| 15:56 | weavejester | ,(update-in {} [:params :myaddkey] "myaddvalue") |
| 15:56 | clojurebot | #<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn> |
| 15:56 | weavejester | Oh, assoc-in |
| 15:56 | weavejester | ,(assoc-in {} [:params :myaddkey] "myaddvalue") |
| 15:56 | clojurebot | {:params {:myaddkey "myaddvalue"}} |
| 15:56 | Vinzent | um, right! |
| 15:56 | fliebel | dnolen: (lambda (x y) (fresh (z) (goalfd x y z))) -> Constrained variable ~s without domain with irritant |
| 15:57 | Vinzent | btw, where is 'dissoc-in'? |
| 15:57 | weavejester | Vinzent: Not in clojure.core, but I believe I saw it in core.incubator |
| 15:57 | Vinzent | weavejester, oh, so it'll be in 1.4 |
| 15:58 | fdaoud | ,(let [req {:params {:a 5 :b 8}}] (assoc-in req [:params :c] 42)) |
| 15:58 | clojurebot | {:params {:c 42, :a 5, :b 8}} |
| 15:58 | weavejester | Vinzent: Maybe. I'm not sure that everything in incubator will be in 1.4. |
| 15:58 | fdaoud | fantastic! thanks weavejester and Vinzent! |
| 15:59 | dabd | I am migrating some 1.2 code to 1.3 but it is difficult to find where the contrib functions are. Ex: read-lines was in duck-streams now it is in monadic-io-streams. Is there an up to date search facility for clojure functions? |
| 15:59 | dabd | clojuredocs is outdated |
| 15:59 | mdeboard | dabd: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go |
| 16:00 | fdaoud | weavejester: btw thanks for compojure et. al., loving it |
| 16:01 | dnolen | fliebel: I see what you mean, you have an intermediate var which doesn't not have a domain. yes I think the caller should specify it. |
| 16:02 | dnolen | fliebel: I think some sort of domain inference would be nice, but that would complicate Scheme cKanren. Certainly something to consider for Clojure cKanren |
| 16:03 | fdaoud | one day I'd like to write a clojure web development book.. and hopefully it would get as good reviews as the stripes book |
| 16:03 | dabd | mdeboard: that's what I am following but it does not have a search facility |
| 16:03 | ibdknox | dnolen: the GSOC thing is awesome! |
| 16:03 | dnolen | ibdknox: totally! |
| 16:03 | fdaoud | things are moving just a little too fast now though |
| 16:04 | fdaoud | ring, compojure, noir, clojurescript.. |
| 16:04 | ibdknox | yeah |
| 16:04 | ibdknox | I don't think now is the right time for a book on this stuff |
| 16:04 | ibdknox | it'll be wrong by the time you finish writing a single chapter ;) |
| 16:04 | fdaoud | yeah |
| 16:05 | fliebel | dnolen: I think the inferred domain could grow unwieldy pretty quickly. (infd x y (range 0 10)) (plusfd x y z). Z now has a domain of all possible sums of x and y. |
| 16:05 | mefesto | i'm lovin stencil with clojure web dev :) |
| 16:05 | fdaoud | sure is a lot of fun to explore though |
| 16:05 | ibdknox | it'll only get better |
| 16:05 | mefesto | i was using hiccup but i guess im so used to using snippets of html that i can't break away |
| 16:05 | ibdknox | I have lots of things up my sleeve still |
| 16:06 | fdaoud | :) |
| 16:06 | ibdknox | mefesto: totally, it's not for everyone |
| 16:06 | fdaoud | gonna try your db stuff next |
| 16:06 | dnolen | fliebel: I don't see why that's a problem. |
| 16:06 | fdaoud | um.. |
| 16:06 | fdaoud | the name escapes me |
| 16:06 | mdeboard | dabd: I see. Apparently not. |
| 16:06 | fdaoud | karma? |
| 16:06 | ibdknox | korma |
| 16:06 | joly | fliebel: dnolen: especially in this case where you could just use the min and max of x and y to get the range for z (0 to 20) |
| 16:06 | fdaoud | yes |
| 16:06 | ibdknox | http://sqlkorma.com |
| 16:06 | dabd | if a namespace has not been migrated to a module (bc no one volunteered) to use it do i need to add the whole clojure.contrib dependency for 1.2.0? Example: clojure.contrib.monadic-io-stream |
| 16:07 | fliebel | dnolen: Okay, then I love domain inference already. |
| 16:07 | fdaoud | screencasts are another possibility |
| 16:07 | ibdknox | dnolen: out of curiosity have you used core.logic in production? It's hard for me to wrap my head around how fast it could really be in real world situations |
| 16:07 | fdaoud | you learn this stuff and you love it, you want to share the joy |
| 16:08 | ibdknox | dnolen: which is not to say it isn't, just curious if you know of uses out in the wild |
| 16:10 | fdaoud | at the current rate, you find a tutorial on a blog from a year and a half ago and it's already outdated |
| 16:11 | jodaro | a year and a half |
| 16:11 | dnolen | ibdknox: some folks at relevance have used it, some folks at revelytix have used it. |
| 16:11 | jodaro | or, like, a week |
| 16:11 | uvtc | fdaoud, my 2 cents is to (A) link to your doc from the wiki http://en.wikibooks.org/wiki/Clojure_Programming and (B) make sure you put a date at the top of your tutorial. |
| 16:12 | fdaoud | uvtc: good points |
| 16:12 | uvtc | fdaoud, That way, the links at the wiki can be curated, and the older ones removed (or moved to an "possibly out of date" section). |
| 16:12 | dnolen | ibdknox: i believe there's a real world presentation about it at Clojure/west |
| 16:12 | dnolen | ibdknox: also I have a feeling a lot of people will use it in the real world w/ the kibit linter :) |
| 16:12 | ibdknox | dnolen: yeah, definitely going to it, I think it's one of the guys from revelytix, but I know in their case it's in something that can take as long as it needs |
| 16:12 | uvtc | fdaoud, I created an "external articles" sub-page at that wiki. Hopefully it will start to fill up. |
| 16:13 | ibdknox | dnolen: absolutely, I was looking at it for some interesting code pattern matching stuff. Though I think starting from the analyzer would be better |
| 16:13 | dnolen | ibdknox: exactly, I would use where it solves the problem in a cleaner simple way - where performance is not of the utmost concern. |
| 16:13 | ibdknox | dnolen: got it |
| 16:14 | dnolen | ibdknox: I've definitely got ideas on how to make it a lot faster - but those are very long term goals. |
| 16:15 | joly | dnolen: is work currently happening on cKanren in core.logic? I've been feeling an urge to give it a try, but I don't want to duplicate effort |
| 16:15 | ibdknox | dnolen: it's very cool stuff, I still haven't really internalized how to express my problems as constraints, but if I could, it would obviously be awesome |
| 16:16 | dnolen | joly: I started in a half-assed way but I got busy with other stuff. No one's said they want to take it on. If you want to that's cool w/ me. I do have some pointers on how I think it should be done. |
| 16:17 | dnolen | ibdknox: nor have I but I think people will come up w/ more and more cool stuff as time goes on. |
| 16:18 | joly | dnolen: I'd be very interested in hearing your ideas on it |
| 16:18 | dnolen | joly: did you look at the cKanren paper? |
| 16:20 | fliebel | dnolen: aww, there is no way to write a proper recursive goal with finite domains, this hurts a bit. |
| 16:20 | joly | dnolen: yes. We talked a little about it at the Conj, but I was working on my own, separate FD constraint thing at the time. Makes more sense to have it in core.logic |
| 16:22 | dnolen | fliebel: why? I've written recursive goals. |
| 16:23 | fliebel | dnolen: well, as soon as you use fresh, you are in trouble. |
| 16:23 | dnolen | joly: the cKanren paper is very good, but there are lot of obvious perf optimizations we can make. |
| 16:24 | joly | dnolen: Yeah, I was think of hash lookups for domains and constraints at the very least |
| 16:24 | dnolen | fliebel: i don't follow, http://dosync.posterous.com/another-taste-of-ckanren |
| 16:25 | joly | thinking* |
| 16:25 | dnolen | joly: in cKanren there's a domain store, I don't think this necessary. Also we can pick better reps for our domains than lists. |
| 16:27 | joly | dnolen: interesting if a domain store isn't needed. I was hoping for a few domain representations to be usable. Storing [min, max] ranges is very common for FD constraints, and lists of such ranges can be effective as well |
| 16:28 | fliebel | dnolen: Ah, you pass around n, to create a domain while recurring. I'm back to the drawing board. |
| 16:29 | dnolen | joly: the domain store is just about associating logic vars to domains. I don't think we need that, we already have a substitutions map. |
| 16:30 | dnolen | fliebel: yep |
| 16:31 | joly | dnolen: interesting, I'd have to think about that some more. I'm more up on the FD side, less on the general constraints and unification side |
| 16:32 | fdaoud | good weekend all |
| 16:35 | dabd | how do i use clojure.contrib.monadic-io-streams with 1.3.0? It was not ported to the new modules |
| 16:35 | fliebel | joly: So are you going to do cKanren for GSOC? |
| 16:35 | joly | fliebel: sadly I don't think I qualify for GSoC |
| 16:36 | TimMc | dabd: You could try forking it and upgrading it to work with 1.3 |
| 16:36 | mdeboard | Which raises the question of why clojuredocs.org is out of date, is it something that more manpower can fix |
| 16:37 | fliebel | joly: Me neither. I think it would have been nice to apply with cKanren tough. |
| 16:37 | joly | fliebel: yeah |
| 16:40 | fliebel | > (run 1 (q) (fresh (x) (infd q x (range 0 100)) (divfd q 10 1 3 x))) |
| 16:40 | fliebel | (3) |
| 16:41 | dnolen | fliebel: excellent |
| 16:42 | dnolen | fliebel: I hear that Dan & Will might be working on CLP(R) |
| 16:44 | fliebel | dnolen: Insane... Does that just mean you get to do (infd x y (range 1 10 0.5))? |
| 16:49 | dnolen | fliebel: I don't think you need to specify an increment. I haven't looked at CLP(R) too closely. |
| 16:50 | joly | fliebel: I would expect it to keep and operate on ranges, not make it into a finite domain |
| 18:09 | yoklov | oh huh. clojure/core is part of google summer of code. |
| 18:09 | yoklov | looks what i know what i'm going to try to do this summer. |
| 18:23 | _ulises | evening |
| 18:24 | _ulises | is anybody doing the NLP stanford course? If so, have you got a clojure skeleton for submitting the course work? |
| 18:28 | mayanks43 | _ulises spamlord?? |
| 18:28 | lazybot | mayanks43: Definitely not. |
| 18:28 | _ulises | mayanks43: yes |
| 18:29 | jaen | _ulises: is that course polyglot then? |
| 18:29 | _ulises | jaen: I don't think so; I'm hoping I can write the solutions in clojure and submit the .class files |
| 18:29 | jaen | so it's Java then? |
| 18:29 | _ulises | Java/Python |
| 18:31 | jaen | Okay, Python at least sounds reasonable, I feel weird without the ability to be somewhat FPy |
| 18:31 | jaen | At the very least |
| 18:31 | _ulises | hum, I just checked out Submit.java and it will try to submit SpamLord.java; clojure won't be an option :/ |
| 18:32 | _ulises | and in any case, it wouldn't have been enough to generate .class files anyway as one would need the rest of clojure to make it work |
| 18:32 | _ulises | it'll have to be Python I guess |
| 19:00 | ashafa | hello |
| 19:00 | ashafa | how's clojurewest? |
| 19:01 | ashafa | Can I bother anybody with some problem with the clojurescript compiler that I have? |
| 19:03 | ashafa | basically (.in some-obj "x") compiles to some-obj.in$("x") in cljs |
| 19:03 | ashafa | notice the in$ |
| 19:04 | ashafa | what I'm I doing wrong? |
| 19:04 | ashafa | am I* |
| 19:17 | prasad | I was to define a map of regex and a function (without a name), how can I define it? |
| 19:17 | qbg | {#"foo" (fn [x] (+ x 1)), #"bar" (fn [x] (- x 1))} |
| 19:17 | qbg | ? |
| 19:18 | prasad | qpg, thnks |
| 19:21 | ashafa | Anyone know why the 'in$' in clojurescript? |
| 19:22 | septomin | probably because "in" is a keyword? |
| 19:23 | ashafa | i was searching for in the api docs but couldnt find it |
| 19:24 | septomin | https://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words |
| 19:25 | ashafa | ah javascript reserved keyword |
| 19:55 | prasad | may be a very basic question, but not able to find an answer in a quick glance through documentation, how do I access the key of the hashmap, anonymously? just pick the key, whatever it is |
| 19:55 | qbg | You mean get the keys? |
| 19:55 | qbg | &(keys {:a 1, :b 2, :c 3}) |
| 19:55 | lazybot | ⇒ (:a :c :b) |
| 19:59 | prasad | ok I was trying to do it a wrong way, I wanted to iterate over the keys and apply certain function say x, on the keys, and then use the result of that function x to pass to functions that are stored as corresponding value for those keys |
| 20:00 | prasad | do I need to use map here |
| 20:00 | prasad | ? i was trying to achieve that using doseq somehow |
| 20:02 | tmciver | prasad: Are you starting with a map or trying to build one? |
| 20:02 | prasad | I am starting with a hashmap |
| 20:02 | qbg | &(let [x {:a 1, :b 2}] (zipmap (keys x) (map inc (vals x)))) |
| 20:02 | lazybot | ⇒ {:b 3, :a 2} |
| 20:03 | prasad | its a map of regex and some function that I would like to apply on the matched result |
| 20:08 | prasad | does that sound valid? |
| 20:08 | prasad | (defn apply-regex-rules [rulesMap file] (let [apply-rule? (fn [rule] (re-seq rule file))] (map (apply-rule? %) &(keys rulesMap)))) |
| 20:09 | qbg | Do you mean #(apply-rule? %)? |
| 20:10 | prasad | ya, #(apply-rule? .. |
| 20:10 | qbg | Which is equivalent to just apply-rule? |
| 20:10 | prasad | aah |
| 20:11 | qbg | I assume you don't mean the & in &(keys rulesMap) |
| 20:11 | prasad | I just want the map to be work on every key of the rulesMap |
| 20:11 | qbg | It would be (keys rulesMap) then |
| 20:12 | qbg | (Lazybot evals expressions that start with &) |
| 20:12 | qbg | (probably your confusion there) |
| 20:12 | prasad | aah, ok, thnkx |
| 20:12 | qbg | (+ 1 2) ;; doesn't eval |
| 20:12 | clojurebot | 3 |
| 20:12 | prasad | atleast got it to compile |
| 20:12 | qbg | I guess clojure bot does in that case :p |
| 20:13 | qbg | Also, camelCase is not commonly used for locals in Clojure |
| 20:13 | qbg | So rules-map instead of rulesMap |
| 20:14 | prasad | aah, coming from java background, functional paradigm just giving me kicks, learning.. |
| 20:14 | qbg | Our names can include - :) |
| 20:15 | tmciver | prasad: also, I assume your 'rule' is the regex? It looks like your not using the vals in your rules-map. |
| 20:15 | qbg | Personally, I would call apply-rule? rule-applies? |
| 20:15 | tmciver | s/your/you're |
| 20:16 | prasad | tmciver, thats rite, rule is the regex and I am still trying to get around, applying the result of the regex to the function which is actually the value of the map |
| 20:16 | prasad | the intension is something like |
| 20:17 | prasad | (def regexMap {#"\w[.\w+]*@\w+\.\w+" (fn [x] (x))} ) (defn apply-regex-rules [rulesMap file] (let [apply-rule? (fn [rule] (re-seq rule file))] (map #(apply-rule? %) (keys rulesMap)))) (apply-regex-rules regexMap "inputfile.txt") |
| 20:17 | tmciver | prasad: might have to reheap that instead ;) |
| 20:18 | prasad | (def regexMap {#"\w[.\w+]*@\w+\.\w+" (fn [x] (x))} ) |
| 20:18 | prasad | (defn apply-regex-rules [rulesMap file] (let [apply-rule? (fn [rule] (re-seq rule file))] (map #(apply-rule? %) (keys rulesMap)))) |
| 20:18 | prasad | (apply-regex-rules regexMap "inputfile.txt") |
| 20:19 | prasad | and bingo, i forgot to slurp the file |
| 20:19 | qbg | Take this with you; it is dangerous to go alone: https://refheap.com/paste |
| 20:19 | prasad | ohh my god it worked. |
| 20:19 | prasad | qbg, thnks |
| 20:22 | tmciver | prasad: another thought: you could make your apply-rule function take both the key and value from the map and use them both inside, rather than operating only on the keys initially. |
| 20:22 | prasad | tmcviewer, how do I fetch the entry? |
| 20:23 | prasad | *tmciver |
| 20:23 | prasad | ( ;) ) |
| 20:23 | tmciver | (map (fn [[key val]] (dosomething key val)) some-map) |
| 20:24 | tmciver | or ... |
| 20:24 | tmciver | (map (fn [[regex func]] (func (some-fun regex)) some-map) |
| 20:25 | tmciver | prasad: I think that's what you said earlier: that you wanted to call a function on the regex and then use the result of that as an argument of the function that was a val in the regex map. |
| 20:26 | prasad | tmciver, thats right |
| 20:26 | tmciver | prasad: something like the above should allow you to do that in one step. |
| 20:27 | tmciver | prasad: the some-fun part would be your apply-rule? function, I guess. |
| 20:30 | Frozenlock | Is it possible to import a .java file? |
| 20:31 | qbg | You need to compile it first |
| 20:31 | qbg | And then have the resulting class on the classpath |
| 20:31 | qbg | (or use classloader trickery) |
| 20:32 | Frozenlock | :( |
| 20:32 | Frozenlock | Thanks |
| 20:32 | qbg | Leiningen can compile your java files for you and make them available |
| 20:33 | Frozenlock | Oh? I do have leiningen... |
| 20:33 | prasad | tmciver: seems to work |
| 20:33 | qbg | there is a javac task |
| 20:33 | prasad | thnkx |
| 20:34 | Frozenlock | Thanks, I'll check the leiningen Doc! |
| 20:46 | archaic | Looking for ideas to cut down the boilerplate around static fields, here is an example of a fn call: (.register path watcher StandardWatchEventKinds/ENTRY_CREATE StandardWatchEventKinds/ENTRY_DELETE StandardWatchEventKinds/ENTRY_MODIFY) |
| 20:50 | amalloy | archaic: you want to talk to TimMc |
| 20:50 | amalloy | pretty sure he's into a project like that already |
| 20:51 | archaic | alright |
| 21:01 | prasad | how can I concat sequence of strings in one big string |
| 21:02 | xeqi | ,(apply str ["asdf "fdsa"]) |
| 21:02 | clojurebot | #<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading string> |
| 21:02 | xeqi | ,(apply str ["asdf" "fdsa"]) |
| 21:02 | clojurebot | "asdffdsa" |
| 21:03 | prasad | thnkx |
| 21:03 | qbg | You can also checkout clojure.string/join |
| 21:04 | qbg | Especially useful if you need to interleave something between the parts |
| 21:05 | prasad | qbg, re-seq returns a sequence rite? seen as ("matched stuff"), I just want to do some string operations on this |
| 21:06 | prasad | say, replace stuff with bang |
| 21:06 | prasad | (fn [x] (replace-str "stuff" "bang" x)) |
| 21:06 | qbg | &(.replaceAll "matched stuff" "stuff" "bang") |
| 21:06 | lazybot | ⇒ "matched bang" |
| 21:07 | qbg | That's an easy way :p |
| 21:08 | prasad | i think this is more specific about applying func to the result of regex which is a sequence () |
| 21:34 | TimMc | archaic: org.baznex/imports |
| 21:36 | TimMc | archaic: You probably want the rename function, so you'd get (e.g.) Watch/ENTRY_DELETE |
| 21:36 | archaic | exactly what I wanted, thanks |
| 21:36 | TimMc | If you have any suggestions for an even fancier API, I'm open to suggestions. |
| 21:44 | prasad | Can some one help to debug why this is throwing #<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args (2) passed to: regex-matcher$fn> |
| 21:44 | prasad | https://refheap.com/paste/1099 |
| 21:54 | stirfoo | prasad: you wouldn't be a spammer now would you? |
| 21:54 | prasad | I am not |
| 21:56 | prasad | stirfoo, was that about the link posted? or the stuff in the link? |
| 21:58 | stirfoo | prasad: well, it looks like you are trying to assemble email addresses from folks that use the: foo AT bar DOT com method of email obfuscation. Don't take it personally. It's just an observation. |
| 21:59 | prasad | stirfoo, yes you spotted correctly, just working on some nlp assignment, info extraction they call it. trying out clojure for the first time today |
| 22:01 | prasad | it seems like, if it finds two matches of any regex match, it throws "IllegalArgumentException: wrong number of args (2) passed to: regex-matcher$fn" not too sure why |
| 22:02 | qbg | &(re-seq #"h(ello)" "hello world, hello") |
| 22:02 | lazybot | ⇒ (["hello" "ello"] ["hello" "ello"]) |
| 22:03 | prasad | qbg, i have added a "?:" that turns off the grabbing |
| 22:04 | prasad | &(re-seq #"h(?:ello)" "hello world, hello") |
| 22:04 | lazybot | ⇒ ("hello" "hello") |
| 22:06 | qbg | You are applying your fn to the result of re-seq |
| 22:07 | qbg | I suspect that you want (map func (apply-rule? regex)) instead of (apply func (apply-rule? regex)) |
| 22:07 | prasad | qbg, I tried to use "apply func (regex-fun?)" |
| 22:07 | prasad | so I want to apply func on every element of sequence returned by regex |
| 22:07 | qbg | Use map |
| 22:08 | qbg | (apply f [1 2 3]) == (f 1 2 3) |
| 22:08 | pyninja | Why does this happen: https://gist.github.com/1ecad17978e06b3c5e78 ? |
| 22:08 | qbg | (map f [1 2 3]) == [(f 1) (f 2) (f 3)] |
| 22:08 | prasad | aah, ok, rite |
| 22:09 | prasad | qbg, thnks for pointing out |
| 22:09 | prasad | works |
| 22:10 | qbg | pyninja: Works for me at the repl |
| 22:10 | prasad | qbg, do you have better idea for applying number of replace functions on a string? |
| 22:10 | qbg | Are you using some ide? |
| 22:10 | qbg | If so, which? |
| 22:10 | pyninja | qbg: what does it say? I'm running lein repl on Mac OS X (which rlwrap installed). |
| 22:10 | pyninja | with* |
| 22:11 | qbg | I get \<that character> for the second form |
| 22:11 | qbg | I'm just running the jar directly though |
| 22:11 | qbg | Encoding issue probably? |
| 22:12 | pyninja | Hm, I guess. But it's clearly capable of displaying unicode characters so I don't understand what's wrong... |
| 22:12 | qbg | I see the same thing with lein repl |
| 22:12 | qbg | I think lein repl is broken |
| 22:13 | qbg | Try printing out x |
| 22:13 | qbg | It didn't like that string very much |
| 22:13 | pyninja | that works for me |
| 22:13 | gtuckerkellogg | qbg, perhaps the encodin on the terminal |
| 22:14 | pyninja | the terminal encoding appears to be fine |
| 22:14 | qbg | It works at my terminal just running the jar |
| 22:14 | qbg | Leiningen 1.7.0 on Java 1.6.0_23 OpenJDK 64-Bit Server VM |
| 22:14 | gtuckerkellogg | for me i get both behaviors |
| 22:14 | gtuckerkellogg | it work find in emacs swank repl |
| 22:14 | qbg | I don't have rlwrap, so I think it is dropping back to jline |
| 22:15 | pyninja | yeah |
| 22:15 | gtuckerkellogg | but under the terminal it doesn't |
| 22:15 | qbg | prasad: Use reduce and .replaceAll? |
| 22:17 | qbg | &(reduce (fn [s [regex rep]] (.replaceAll s regex rep)) "hello, beautiful world!" {"beautiful" "ugly", "hello" "bye"}) |
| 22:17 | lazybot | ⇒ "bye, ugly world!" |
| 22:17 | prasad | qbg, beauty. |
| 22:19 | prasad | a language design related question, do these map and reduce are executed in parallel internally? or is there a way to make them run in parallel? |
| 22:19 | qbg | You mean concurrent execution? |
| 22:19 | prasad | yes |
| 22:19 | qbg | There is pmap |
| 22:19 | qbg | But that has some overhead |
| 22:19 | qbg | &(doc pmap) |
| 22:19 | lazybot | java.lang.SecurityException: You tripped the alarm! pmap is bad! |
| 22:19 | prasad | but i mean parallel, if run on multicores |
| 22:19 | qbg | ,(doc pmap) |
| 22:19 | clojurebot | "([f coll] [f coll & colls]); Like map, except f is applied in parallel. Semi-lazy in that the parallel computation stays ahead of the consumption, but doesn't realize the entire result unless required. Only useful for computationally intensive functions where the time of f dominates the coordination overhead." |
| 22:20 | prasad | thnk |
| 22:21 | jtoy | what is the proper way to convert a map to a vector? |
| 22:21 | qbg | jtoy: what do you want the vector to look like? |
| 22:21 | qbg | prasad: normal map is lazy, so the values are computed on demand |
| 22:22 | jtoy | qbg: a => val, b => val , I'm pretty new to clojure, so trying to get a program running |
| 22:22 | qbg | So {:a 1, :b 2} becomes [:a => 1 :b => 2] ? |
| 22:23 | jtoy | qbg: yes |
| 22:23 | qbg | &(vec {:a 1, :b 2}) |
| 22:23 | lazybot | ⇒ [[:a 1] [:b 2]] |
| 22:24 | jtoy | qbg: what does & mean there? is that just for lazybot ? |
| 22:24 | jtoy | &(+ 1 2) |
| 22:24 | lazybot | ⇒ 3 |
| 22:24 | qbg | Yes, for lazybot |
| 22:24 | jtoy | yes |
| 22:24 | qbg | &(vec (mapcat (fn [[k v]] [k '=> v]) {:a 1, :b 2})) |
| 22:24 | lazybot | ⇒ [:a => 1 :b => 2] |
| 22:25 | jtoy | qbg: ok ,so that just converts a whole vector, I'll try doing that for now |
| 22:25 | qbg | Why do you need to convert a map to a vector? |
| 22:26 | qbg | Maps are already seqable |
| 22:26 | jtoy | qbg: I'm trying to make this work: http://groups.google.com/group/cascalog-user/browse_frm/thread/fb212cd71ca19329# |
| 22:26 | jtoy | nevermind, I see it now. The problem is with (json/parse-string ..), which is returning a map. You need to return a vector. |
| 22:31 | qbg | I haven't used Cascalog, but using vec there might be what you need to do |
| 22:41 | jtoy | qbg: k thanks, still trying to figure it out |
| 22:42 | Frozenlock | I'm using a frame from seesaw. However, when I close it, my java process doesn't stop. Is there a command I need to do in order to make it -terminate-? |
| 22:44 | qbg | Here is how you do in straight Java: http://docs.oracle.com/javase/6/docs/api/javax/swing/JFrame.html#setDefaultCloseOperation%28int%29 |
| 22:46 | Frozenlock | Thanks! (frame :title "My frame" :on-close :exit) works perfectly! |
| 22:55 | jtoy | nice ,got it to work ,although not sure why :) |
| 23:00 | jtoy | how do I make this general so I can pass the names of the columns I want to extract from the args of follow_parse? (defn follow_parser |
| 23:00 | jtoy | [line] |
| 23:00 | jtoy | (map (json/parse-string line) ["a_id" "b_id"])) |
| 23:58 | uvtc | Can anyone point me to documentation or a blog article that explains the lifecycle of a how Clojure code gets compiled and run? |