#clojure logs

2012-03-16

00:15jayunit100heyloo
00:16johnmn3but I can't figure out to add an icon to a seesaw.core/dialog
00:16jayunit100is there a spec somewhere for the clojure doc function?
00:17jayunit100I notice there are different syntaxes (* & "seq-exprs" ...) ...
00:17jayunit100so 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:20jmaloneto johnmn the :content on the seesaw.core/dialog can a component or a panel which you could put the icon in
00:22johnmn3I have a vertical-panel but it doesn't accept an :icon key.
00:23johnmn3Which panel might work?
00:24johnmn3I want to get a hold of the frame of the dialog window
00:26johnmn3Which I think is something like (config! (to-root my-dialog) :icon (seesaw.icon/icon ...
00:26jmalonehmm
00:27johnmn3But my-dialog is a function
00:27jmalonewell i can get icons to load on the dialog if the :content is an icon
00:27jmalonefor example
00:27johnmn3because that's how menu wants it
00:27johnmn3I can get icons in the dialog.. but the title of the dialog window...
00:28jmalone(dialog :content (icon "http://i.imgur.com/89BC9.jpg")))
00:28jmaloneoh the title of the dialog window?
00:28johnmn3yea
00:28johnmn3it's still a java cup
00:29johnmn3so I think you gotta get at the root with to-root
00:29johnmn3the root frame of the dialog window
00:29jmalonethat might be right
00:29johnmn3but my-dialog is a function that returns a new dialog frame each time it's run
00:30johnmn3I need to (def a-dialog (my-dialog))
00:30johnmn3so that I can (config! (to-root a-dialog) ...
00:32johnmn3but its a button in the menu, which expects a function for its :handler
00:34groovemonkeyhi 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:34jmalonethere is a custom-dialog function that takes default & frame options
00:35groovemonkeybut I'm getting an IllegalArgumentException "no matching field found -- listfile for class java.io.File"
00:37groovemonkeyany ideas?
00:38groovemonkeyuser=> (.listfile (java.io.File. filepath))
00:38groovemonkeyIllegalArgumentException No matching field found: listfile for class java.io.File clojure.lang.Reflector.getInstanceField (Reflector.java:289)
00:38jmaloneisn't it listFiles?
00:40groovemonkeyjmalone, same error.
00:42groovemonkeyuser=> (.listfiles (java.io.File. filepath))
00:42groovemonkeyIllegalArgumentException No matching field found: listfiles for class java.io.File clojure.lang.Reflector.getInstanceField (Reflector.java:289)
00:42jmalonecapatlize the F
00:43stirfooI think this is a bug in the reader "\41q". It hangs when it should return "!q". Can someone confirm this please.
00:51jmalonehttp://stackoverflow.com/questions/8566531/listing-files-in-a-directory-in-clojure
00:52johnmn3jmalone: thanks. I tried (costum-dialog :parent my-frame :content (etc...
00:52johnmn3but that didn't give it the icon in the title
00:53johnmn3oh wait
00:53johnmn3I could just juse frame instead of dialog, right?
00:53jmaloneyeah
00:53johnmn3it's basically just an alert box
00:53johnmn3I just want that new frame to close when the user clicks a button (OK)
00:55jmaloneset a listener and that triggers dispose!
00:55jmalonenot sure about the dispose!
00:56jmaloneim looking at the docs now
01:18johnmn3jmalone: I got it. I'm just making the user X the window to close
01:30sorenmacbethIs there a way that I can pass a method name as a string to a Java object
01:30sorenmacbethsomething like (. "methodName" (String.))
01:30sorenmacbeth(. (symbol "methodName") (String.)) doesn't work
01:31wmealingdoes the java object accept a string arg ? (obvious question)
01:31wmealingim no java programmer... just wondering
01:33wmealingjust sounds like an odd way to do it.
01:34carlo_auJava doesn't have an eval() does it? (another non-Java programmer here)
01:34wmealingi think you maybe can do "apply" to do something similar carlo_au .
01:34sorenmacbethwhat I want to do is create that method name call in a macro
01:35carlo_auwmealing: you mean Clojure's 'apply'?
01:35wmealingi mean apply, like it runs functions based on strings
01:36wmealinglike in erlang apply(Module,Function, Args)
01:36wmealingnot really an eval so to speak
01:36wmealingbut it still runs the code that you specify.
01:36jmalonethe tilde ~ unquotes things im not sure if thats what you are looking for though
01:38muhoowell clojure west tomorrow. preparing to drink from the firehose.
01:53spn@sorenmacbeth I believe you can use Java reflection. It would look something like:
01:53spnBank.getMethod("deposit").invoke(obj)
01:54spnBank.getMethod("deposit").invoke(obj, 300) i meant
01:54sorenmacbethspn: thanks, I'll try that
02:19muhooi'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:19muhoo(vec (map #(vec
02:20muhoothen a for inside of that
02:20muhootook me like 15 minutes to figure out wtf it does
02:20technomancyibdknox: http://allrecipes.com/recipe/chicken-korma-ii/ is second place when I search for korma now
02:20technomancylooks like you're slipping =O
02:23muhoowhere did you go for korma, and was it good?
02:27technomancyTandoori Oven; it was pretty good
02:30cemerickmuhoo: ^^ seconded; very good Indian there.
02:30clojurebotI don't understand.
02:31muhoothanks
03:54raekmuhoo: I would write that piece of code like this: https://refheap.com/paste/1094
03:54tsdhI get Error 310 (net::ERR_TOO_MANY_REDIRECTS) when trying to browse www.clojure.org. Do you see that, too?
03:56raek'map' + anonymous function and 'for' can be used interchangeably here, but I don't see any reason to mim them here
03:56raek*to mix
04:05dsabaninhi guys!
04:07dsabaninI'm just starting with clojure, but have this weird understanding issue with a really simple function
04:10dsabaninI have a function like this: http://pastie.org/3606636
04:10dsabaninI have a function like this: http://pastie.org/3606636
04:10dsabaninI have a function like this: http://pastie.org/3606636
04:11dsabaninI've a function like this http://pastie.org/3606636
04:11dsabaninhttp://pastie.org/3606636
04:12dsabaninI can't post here for some reason
04:12dsabaninhmm
04:12dsabaninhttp://pastie.org/3606636
04:12dsabaninfor some reason pastie URL isn't getting posted http://pastie.org/3606636
04:12raekdsabanin: you have posted the same line six times
04:12dsabaninreally?
04:12dsabaninI'm very sorry
04:12dsabaninmy IRC client seems to be broken
04:12raekanyway, the problem is at line 4
04:12dsabaninstupid thing
04:13raekdsabanin: do you see what happens with the result of thr set-connection! call?
04:13raek*the
04:13dsabaninoh damn :)
04:13dsabaninthank you!
04:14dsabaninit works! :)
04:14dsabaninI don't know how it got there..
04:14dsabaninI guess I tuned out parantheses way too early :D
04:15raekthe code was loaded through a require call and not entered through the repl, you should get line numbers in the stacktrace
04:15raek*if the code
04:16dsabaninto be honest, coming from ruby, the stacktraces are somewhat confusing in clojure, have to get used to them
04:22raekdsabanin: what are the biggest differences between ruby and clojure stacktraces?
04:23tsdhInterop 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:25tsdhI could create a java Function interface and reify it from clojure, I guess...
04:26raekwhy not use IFn direclty?
04:27raekvoid fooMethod(IFn clojureFunction) { ... clojureFunction.invoke(arg1, arg2); ...}
04:27raekand what do you mean by "instantiate"?
04:27tsdhraek: We don't want a clojure dependency in the java project.
04:29tsdhraek: 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:29raekthen it recevides a class?
04:31raekI think you have to introduce a new function abstraction if you really cannot reuse the clojure one
04:31tsdhHm, 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:32raekthe second approach is how I would have done it
04:32raekthen you don't need to use reflection to find the cnstructor, etc
04:33tsdhOk, so an OnInternalField interface in java land that I can reify from clojure, right?
04:33raekthat should be simple from both java and clojure
04:33tsdhGreat, thanks.
05:26stirfooCan someone put "\41q" in their repl? That's a *single* backslash. It might hang...
05:36clgvstirfoo: java.lang.IllegalArgumentException: Invalid digit: q
05:37clgvstirfoo: backslash via "\\" like ##(print "\\")
05:37lazybot⇒ \nil
05:37stirfooclgv: did you type in the quotes as well (a literal string with an octal escape)
05:37clgvyes, I did
05:37amalloystirfoo: what character are you hoping that will be?
05:37stirfooamalloy: I think it's a bug in the reader
05:37amalloyi doubt it, and you didn't answer my question
05:38stirfooan octal escape can be specified by \ followed by 1, 2, or 3 octal digits
05:38stirfooamalloy: it should output "!q" to the repl
05:38clgv,(println "\41")
05:38clojurebot!
05:39stirfoonow put a q after the 1
05:39clgv,(.println System/out "\41q")
05:39clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Invalid digit: q>
05:39stirfooI was going to do that but I dont want to lock up someones bot
05:40stirfoosee, I think it *is* a bug in the reader
05:40clgvseems more like a bug in java
05:40stirfoono, 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:41stirfoos/null/false/
05:42clgvhm ok., read-string cant cope with it: ##(read-string "\41q")
05:42clgv,(read-string "\41q")
05:42clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.IllegalArgumentException: Invalid digit: q>
05:43stirfoothe code tries to evaluate the q as an octal digit, when it should push it back into the stream and return !
05:43stirfoobut it's not checking the exact parameter
05:43clgvmake an issue and patch it^^
05:44stirfooclgv, thanks for verifying it
05:44clgvstirfoo: do you have the link to the source at hand?
05:45stirfoono, I have a local copy
05:45amalloystirfoo: include a mention of the relevant section of the JLS, 3.10.6
05:45amalloy(and probably also mention that the reader claims standard java escapes are supported)
05:46stirfooare three digits required in java?
05:46clgvI wonder why it doesnt use java's implementation for these escapes...
05:46amalloystirfoo: no
05:46amalloyclgv: because that would be really hard? and require a jdk to run clojure?
05:47clgva what?
05:47amalloy$google jdk
05:47lazybot[Java SE Downloads] http://www.oracle.com/technetwork/java/javase/downloads/index.html
05:48clgvah right. thats a compiler thing and no runtime interpretation
05:48clgvs/a/erm/
05:48clgv;)
06:15stirfoois google's clojure-dev group read-only, invite-only, gtfo-my-lawn only? ;)
06:31tsdhHow can I call (Arrays/copyOfRange ary 0 idx) non-reflectively? Hinting ary as ^objects doesn't help...
06:33tsdhAh, got it. I need to wrap the indices in (int ...).
06:49caspercI have been wondering, why does the clojure compiler not check the number of arguments for function calls when possible?
06:50caspercit would seem that it is quite possible to do in most cases (defining a function and then calling it)
06:50bsteubercasperc: in theory it is possible that the fn gets exchanged at run time
06:51bsteuberbut yes, should at least give a warning ^^
06:51caspercmaybe some strict compilation switch
06:52stirfoo"\41q" fix => http://paste.lisp.org/display/128373
06:52caspercthing 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:54bsteuberunit tests ^^
06:54bsteuberbut sure
07:13clgvcasperc: that could be an external IDE feature
07:40jaleywhat should one extend to add an implementation of some protocol to clojure maps? hopefully not PersistentHashMap, PersistentArrayMap, etc all seperately...?
07:43bsteuberjaley: you can extend protocols on interfaces, but..
07:43bsteuberwhen two interfaces match there seems to be no guarantee which one will be called
07:44bsteubereven if one inherits from the other
07:45jaleybsteuber: ok. so is there some common interface that all the maps implement>?
07:49_atojaley: clojure.lang.Associative
07:49jaley_ato: cool! thanks!
07:52llasramThat might work, but IPersistentMap is probably closer
07:52_atoyeah depends on how strictly map like you want
07:52_atoAssociative covers vectors too as they can treated like a map
07:53_atoILookup -> Associative -> IPersistentMap
07:53bsteuberjaley: ah maybe you should use APersistentMap instead of the interface
07:54bsteuberthen even overlapping classes will be fine later
07:54jaleybsteuber: ah that's a good idea
07:54jaley_ato, bsteuber thanks for the help guys
08:17jaleyok... what am I doing wrong with extend-type? https://refheap.com/paste/1095
08:21raekold implementations of the protocol, perhaps?
08:21raekjaley: does it work if you reload the namespace?
08:22jaleyraek: hmm well I did already try killing swank and reconnecting. is there something else i can do to make sure?
08:25raekjaley: it worked in my repl
08:26llasramIf you're doing any AOT compilation, make sure that you don't have stale class files for the protocol interface sitting around
08:26raekare you sure you restarted the swank server?
08:26llasramOtherwise, like raek it also works in my fresh REPL
08:26raekllasram: good point!
08:26jaleyraek: well i just re-ran jack-in and it asked to terminate the old session
08:26jaleyllasram: ok cool, must be soemthing stale somewhere. i'll try lein clean
08:28jaleyllasram: ah yeah... somewhere in my code there's a gen-class
08:29llasramKill it! Kill it with fire!
08:29raekinteractive development + AOT compilation = :(
08:30jaleyraek: I possibly don't need it any more actually
08:30llasramIf deftype supported specifying alternate constructors, I could drop my every remaining use of gen-class
08:30llasramThat would make me so very happy
08:31jaleyllasram: does lein's :main attribute cause AOT to occur?
08:32raekjaley: yes
08:32llasramYou can disable that though
08:32raekbut I only think it performs the compilation when you run "lein run", or "lein jar"
08:33jaleyraek: ok that shouldn't get in the way of my slime evals then?
08:34llasramIt'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:34raekjaley: not sure. but previous run/jar runs still leave files in classes/ though
08:34jaleyllasram: ah ok cool, thanks
08:34raekI find lein javac useful for interfacing with Java
08:35raekimplement the class that the java code needs in java, and let the clojure code reify an interface
08:36Hali_303hi! when I get an exception during a use :reload-all, how do I know which line is causing the problem?
08:37Hali_303I see the backtrace in the emacs buffer, but how do I find out where is the problem?
08:37Hali_303the backtrace itself is full of clojure.core stuff without any locals as a hint
08:39raekwhat does the exception message say?
08:39raekcompile time exceptions are often much harder to read
08:42Hali_303raek: it said sg like cannot convert from a Boolean to a Symbol
08:42Hali_303and the problem was, that I've messed up my use/require statements
09:17jweissRaynes: 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:18jweissoh, i can just add a github issue :)
10:43ibdknoxtechnomancy: oh no's! the FOOD IS WINNING.
10:43ibdknoxtotally unacceptable
11:00jodaroaww yeah
11:00jodarosouth to west
11:00jodaroclojure west, that is
11:02jolythe Conj was wonderful. Wish I could have made West
11:02dabdto find the appropriate leiningen dependencies for the new contrib modules should I use 'lein search <namespace>'?
11:03TimMcibdknox: Are you backchanneling from Clojure/West?
11:06raekdabd: yes, that's probably the easiest way (once the maven indexes are downloaded)
11:07raekartifact names (but not versions) are listed here: http://dev.clojure.org/display/doc/Clojure+Contrib
11:09raekso "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:10dabdraek: that means I can search for the new namespaces only? thx
11:12clgvdabd: new libraries not namespaces
11:12raekdabd: technically, you don't search for the namespace name. you search for the new project name.
11:13raekdabd: see this page for a mapping from old namespace to new libraries: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
11:16choffsteinHey 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:32dabdi tried 'lein search combinatorics' but it didn't find anything. I was expecting it to find clojure.math.combinatorics
11:33ibdknoxdabd: I think lein search only looks at clojars, and the contrib libs go to maven central
11:35clgvdabd: I think you have to search for the entire artifact name - I guess it's clojure.math.combinatorics
11:37geoffeg_cthis conference does not have the stickers i wanted
11:40TimMcibdknox: Pertty sure it searches central as well.
11:43technomancyTimMc: true. if it doesn't catch combinatorics it's probably tokenization
11:56clgvgeoffeg_c: lol what do you mean? :P
11:57geoffeg_cclgv: 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:57clgvhehe. how is the conference so far?
11:58xeqiclgv: technomancy had some heroku stickers last night
11:58xeqigeoffeg_c: ^
11:58clgvoh wait. it is a just about to start, right?
11:58geoffeg_cright
11:58geoffeg_cbest part so far: power strips under the tables
12:02raekibdknox: lein search looks in maven centeral too
12:02dnolenare folks watching the Clojure/west keynote?
12:02clgvis there a livestream?
12:03raekoh, TimMc already said that
12:03dnolenjonasen: 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:06ibdknoxTimMc: I am :)
12:06ibdknoxraek: TimMc: I stand corrected.
12:06gozalaHi folks I'm trying to figure out what's a diff between defrecord and deftype if any
12:07gozalado you know any good pointers to read about this ?
12:08dnolengozala: defrecord work as maps
12:08TimMcgozala: cemerick has a flowchart of this
12:08clgvgozala: deftype creates a plain java class with the methods you implement. defrecord adds a full map implementation to that
12:09gozalaso defrecord is more like an instantiation ?
12:10technomancydeftype is for if you are implementing Clojure
12:10uvtcthis looks like the link to that flowchart: http://cemerick.com/2011/07/05/flowchart-for-choosing-the-right-clojure-type-definition-form/
12:10dnolengozala: no, defrecord is like deftype with a lot of things defined for you - specifically map-like stuff
12:11technomancydefrecord is for if you think maps are too slow but don't have a good understanding of profiling and bottlenecks. =D
12:11ibdknoxlol
12:11clgvgozala: defrecord is (almost completely) like a clojure map but you can implement protocols for it
12:11gozalatechnomancy: what if I'd like to create my own abstraction
12:11technomancyprobably defn
12:11ibdknoxgozala: abstraction over what?
12:11gozalaI guess I need to use deftype for that unless it's map like thing ?
12:12ibdknoxyou mean your own datatype?
12:12ibdknoxer, datastructure, rather?
12:12gozalaI'm trying to define eventual value abstraction
12:12gozalawhich I'd like to implement for all existing datatypes
12:13gozalaand have my own special type
12:13dnolengozala: you can define your own abstractions with maps + multimethods, and it will be more portable across Clojure implementations.
12:13gozalathat handles it differently
12:14ibdknoxeventual value? like a delay?
12:14ibdknox,(doc delay)
12:14ibdknox&(doc delay)
12:14lazybot⇒ "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:15ibdknoxhm
12:15ibdknoxjust slow
12:15uvtcI like how lazybot "delayed" that response...
12:15gozalaibdknox: sort of but
12:15gozalamore like promises
12:15dnolengozala: Clojure has promises
12:15gozalabut promises in clojure don't seem to suite cljs very well
12:15ibdknox,(doc promise)
12:15dnolengozala: that is true.
12:16ibdknoxyou should've said you wanted to use cljs :p
12:16gozalaso I'd like to do non-blocking promises for cljs
12:16ibdknoxhow would that work?
12:16gozalathe way it works in js
12:16AWizzArdThat is more like a future.
12:16clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class clojure.lang.RT>
12:16clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.NoClassDefFoundError: Could not initialize class clojure.lang.RT>
12:16gozalausing event loop and listeners
12:16seancorfieldclojurebot is sick :(
12:17ibdknoxhiredman: ^
12:17gozalabut that's more like a learning experience to me
12:19jaleywhat 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:20ibdknoxjaley: deref
12:20ibdknoxjaley: or @
12:20technomancyor just use the var
12:20ibdknoxor that
12:20clgvjaley: var-get gets you the value
12:20mdeboardgod dammit comcast has been sucking ass lately
12:21mdeboardwhoops
12:21mdeboardwrong window, sorry
12:21mdeboards/window/buffer
12:21jaleyerrr.. cannot cast symbol to var. seems I have a symbol. sorry
12:21clgvjaley: you can 'resolve that symbol
12:22jaleyclgv: and then deref?
12:22jaleygot it. thanks all!
12:41gfredericks&'ping
12:41lazybot⇒ ping
12:43duck1123has 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:43clgvduck1123: lein 1.7 needs a lot of time here for cleaning the "classes" folder. I help it by deleting it first^^
12:45mk270is 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:45clgv'(foo bar baz)
12:46mk270i'm not sure i wanted to quote everything - is that the same?
12:46clgvyes that is a list without the 'list at the beginning
12:46raekmk270: you often uses vectors for sequence literals
12:47raekit is considered ideomatic to write [foo bar baz] instead of (list foo bar baz), assuming just need a sequence of some sort
12:48mk270ah thanks. i shall do it that way :)
12:49duck1123clgv: 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:50clgvoh
12:50raekduck1123: I heard the folks in #leiningen talking about something that sounds a lot like your problem
12:50technomancyraek: 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:51seancorfieldAOT bad :)
12:51ibdknoxlein run does it by default :p
12:51technomancyseancorfield: ...two legs good!
12:51jonasendnolen: That'll be very interesting.
12:51technomancyibdknox: you can use lein run -m
12:51technomancyor set :skip-aot
12:51duck1123AOT is bad, but if you are trying for interop with a library that scans the classpath for class files that implement an interface...
12:52ibdknoxtechnomancy: I added ^{:skip-aot true} for everything
12:52ibdknox:)
12:52technomancyibdknox: partial aliases can address that to
12:52ibdknoxoh?
12:52technomancylein launch -> lein run -m myproject.web
12:52ibdknoxah
12:53ibdknoxI assume there's some fix we can do for the GC call
12:54dnolenjonasen: we'll see, hopefully it'll let you guys get to the next level with what type of rules you can specify.
12:54technomancyibdknox: depends on whether you want to run from source
12:55ibdknoxtechnomancy: ah, it's already fixed then?
12:55technomancywell
12:55clgvtechnomancy: in my project the jars main file draws in a low for AOT transitively
12:55technomancyibdknox: it's easy enough to comment out the GC call
12:55ibdknoxoh haha :)
12:55technomancyor maybe wrap it in a (when (windows?) ...)
12:56technomancyactually if someone could confirm that fixes it that would be super
12:56clgvtechnomancy: is there a possibility to avoid that transitive AOT?
12:56duck1123was this just recently added? Would it be worth it to try downgrading my lein?
12:56xeqitechnomancy: I can confirm removing the gc call makes lein faster
12:57technomancyduck1123: I think it's new in 1.7.0
12:57xeqithe gc call forces FullGCs each time on my ubuntu/vagrant box
12:57technomancyxeqi: thanks
12:57technomancyyeesh
12:57xeqi"forces" as in the jvm decides to do it
12:57technomancyclgv: you can use runtime require/refer in your main ns
12:58duck1123it has been getting very much slower, but I've been blaming myself for that
12:58technomancynow you can blame windows!
12:58ibdknoxscrew windows :p
12:59clgvtechnomancy: ah ok thanks.
12:59dnolenromanandreg: nice looking patch - but it causes some CLJS tests to fail. if you can address that we can merge in your patch.
12:59TimMcclgv: Wait, you're just trying to avoid AOT?
12:59clgvtechnomancy: and why did the "lein clean" get so slow? is that the windows bug you are currently talking about?
13:00romanandregdnolen: oh… right, tests! ups hehe, going to check those out for sure later in the day, thanks for the feedback
13:00technomancyclgv: yeah, apparently without it Windows doesn't release file handles or something
13:00dnolenromanandreg: np
13:00clgvTimMc: yeah. my jars main draws in almost all of my code for AOT
13:00clgvah ok
13:00technomancyclgv: oh man; you are in luck
13:00technomancyTimMc has just the thing for you
13:01TimMcclgv: lein-otf
13:01seancorfieldclgv: consider AOT compile for main only and dynamically resolve everything else
13:02clgvTimMc: interesting. have to try that one
13:02duck1123this won't work for gen-class that pulls in everything, will it?
13:03seancorfieldwe AOT compile our log4j appender but it resolves a call to the main logic at runtime - so no AOT explosion
13:03seancorfieldtime to switch rooms at clojure/west... back online later
13:16TimMcYeah, lein-otf only helps you avoid AOT infection from the -main of an uberjar.
13:16TimMcBut you can use the same technique directly.
13:34jonasendnolen: I'm constantly looking for more ways to use core.logic. For example https://github.com/jonase/kibit/commit/fa2539b524ce1d10415a938b54735f09baef83aa
13:35jonasendnolen: one line of logic can achieve much :)
13:37dnolenjonasen: so true! glad you're digging in with such a cool tool :)
13:43ieure(doc first) -> Unable to resolve symbol: doc in this context
13:43ieureDid this change in 1.3 or something?
13:43clojurebot"([coll]); Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil."
13:43duck1123doc moved to clojure.repl, so you'll have to use that first
13:43jodaroieure: (use 'clojure.repl)
13:44ieureThanks.
13:44technomancyieure: or C-c C-d C-d
13:44choffsteinHmmm, 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:44ieurechoffstein, Because macroexpand doesn't evaluate the expansion.
13:45choffsteinHere's a gist: https://gist.github.com/2051381
13:45choffstein(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:46ieurechoffstein, What happens if you eval the expansion?
13:46choffsteinAh, same error. Gotcha.
13:48choffsteinExcept just calling (resque-clojure.core/enqueue "test" "expanded-name" "job-id" "arg1" "arg2") from my repl works
13:48choffsteinWhich is just confusing as hell for me
13:49jodaroi mostly go to conferences for the bottomless cup of coffee
13:54rlbis clojure.contrib.core seqable? still the preferred source for that test?
13:55dnolenHOLY MOLY
13:55dnolenClojure/core got accepted to GSoC 2012!
13:55choffsteinThe issue seems to be in ~@, since I don't have & args in the arg list.
13:56choffsteinIf I know an input will be a vector or list for a macro, can I splat it with ~@?
13:57TimMcdnolen: Way cool.
13:58TimMcchoffstein: ##`(1 2 3 ~@[4 5 6])
13:58lazybot⇒ (1 2 3 4 5 6)
13:58choffsteinYeah, that's what I thought. This is just weird.
13:59TimMc&'ping
13:59lazybot⇒ ping
13:59choffsteinTimMc: 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:59TimMc&`(1 2 3 ~@(range 4 7)])
13:59lazybotjava.lang.RuntimeException: Unmatched delimiter: ]
13:59TimMc&`(1 2 3 ~@(range 4 7))
13:59lazybot⇒ (1 2 3 4 5 6)
14:00TimMcchoffstein: Is enqueue a macro?
14:01choffstein...I actually don't know
14:01choffsteinit's another library
14:01TimMcIf it's a fn, use apply instead of making a splicing macro.
14:01jaendnolen: was it? i'm still stalking the gsoc page
14:06dabdlein search downloaded the maven central index so I guess it searches it too
14:07dabdsearching for the entire artifact name doesn't work either
14:08dabd'lein search math' also does not find it. Who can fix lein search?
14:10dabdlooking at the implementation the search function seems to use Lucene so it is strange that it does not work
14:16dabdtechnomancy: I opened an issue on leiningen github about lein search failing. thx
14:18raekdabd: I think you need to add a wildcard for inexact searches
14:18raekdabd: have you tried this? lein search 'math*'
14:19raek(I'm not familiar with the lucene query syntax)
14:24dabdraek: I am updating the index and will try the search with wildcards when it finishes. Does it work for you?
14:27raekit finds math.numeric-tower, math.combinatorics and some others for me
14:31jaenraek: 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:34choffsteinis there a way with moustache to change the response type?
14:35raekchoffstein: what do you mean by response type?
14:35raekcontent-type?
14:36choffsteinwell, 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:38raekI usually do those things in the handler function or in middleware
14:38dabdlein search 'math*' works
14:38choffsteinOh, it seems like if I wrap it with a fn that takes a single arg (the req), I can do it...
14:39raekbut you should be able to construct the response inline too
14:39raeka map does not mean response in all positions in moustache
14:39choffsteinYeah. Looks like I needed {:get (fn [req] {:status 200 :body "ok"})}
14:40raekthere is a shorthand too
14:40choffsteinI guess that makes a decent amount of sense, since moustache is asking for a handler
14:40raekmaybe you need to wrap the innermost map in []s
14:40raekok, a "handler-main" can be a literal ring response map
14:41raekthe value in a method-dispatch map is a "shorthand-or-handler"
14:41raekah, and a map is treated as a method-disptach there
14:42raekchoffstein: this should work: [""] {:get [{:status 200 :body "ok"}]}
14:42choffsteinI just tried that. Didn't like it...
14:43raekhrm
14:43choffsteinOp .. it does!
14:43choffsteinThat was strange
14:44raekhttp://moustache.cgrand.net/syntax.html
14:44choffsteinah, nice. thanks
14:44raekimplicitly, it's all there ;-)
15:03rptHi everyone, can anyone tell me what is wrong with this? http://cljbin.com/paste/4f638e38e4b0b0541f4c83dc
15:04rpt(a function meant to remove consecutive duplicates)
15:04dnolenit's official folks, http://www.google-melange.com/gsoc/accepted_orgs/google/gsoc2012
15:05mdeboardrpt: What output do you expect and what do you get? What's sample input?
15:06rptmdeboard: sample input [1 2 2 3 2 4 4], sample output [1 2 3 2 4]
15:08mdeboardWell the main problem I see is that you're just returning s
15:08mdeboardyour final expression is the input
15:08rptmdeboard: but s will only be returned if s has less than two elements?
15:09mdeboardNot in that code
15:09rptmdeboard: (ie when (second s) is nil)
15:12hhutchdnolen: great news!
15:12rptmdeboard: ah OK, got it
15:12dnolenhhutch: yes!
15:12jaenincidentally, how hard would it be to get into gdoc given you haven't done any open source work to date?
15:14dnolenjaen: now is a good time as any.
15:14mdeboardrpt: I assume this is just for a programming exercise, not an actual problem you're trying to solve
15:14mdeboardlike production problem
15:14rptmdeboard: yup, 4clojure probb
15:14mdeboardthought so!
15:15rptmdeboard: what would you use in real life?
15:15mdeboardwhat number?
15:15rptmdeboard: #30
15:15rptmdeboard: gotta go, tx for the help
15:15jaendnolen: 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:15mdeboardgl;dd
15:22georgekhi, 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:23georgekdoes foreign-libs only matter for advanced compilation? I'm working in development mode in cljs one
15:25fliebelHow do you do integer division? Like the other part of the remainder.
15:26Wild_Catfliebel: % ?
15:26fliebel&(% 10 4)
15:26lazybotjava.lang.RuntimeException: Unable to resolve symbol: % in this context
15:26fliebel&(rem 10 4)
15:26lazybot⇒ 2
15:27fliebelBut want I want is more like ##(int (/ 10 4))
15:27lazybot⇒ 2
15:28Wild_Catfliebel: sorry, mod
15:28Wild_Cat?(mod 4 3)
15:28Wild_Cat,(mod 4 3)
15:28clojurebot1
15:28dnolenfliebel: quot
15:28dnolen,(quot 4 3)
15:28clojurebot1
15:28dnolen,(quot 10 2)
15:28clojurebot5
15:28fliebeldnolen: thanks.
15:42mk270gday - i don't understand map/apply in clojure. why does (apply println ["a" "b"]) put everything on the same line
15:42mk270(what i want is the equiv of ocaml's List.iter print_endline ["a";"b";]
15:44uvtcmk270, apply unpacks the the 2nd arg and passes all of the items at once to the first arg (a fn).
15:44Vinzentmk270, because (println "a" "b") prints ab\newline
15:44uvtcmk270, map calls the fn on each item one at a time.
15:45Vinzentmk270, also, don't forget about lazyness: you should use either dorun with map or doseq
15:45Vinzent(in order to get your side-effects immediately)
15:45mk270ok thank you both :) i shall now digest that
15:46mk270what is lazyness?
15:46mk270that surely isn't lazy evaluation a la haskell?
15:47Vinzentmk270, language itself isn't lazy, but sequences are
15:47dnolenmk270: many sequence operations in Clojure are lazy, to counter the lack of TCO on the JVM.
15:47mk270ok
15:48uvtcmk270, 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:49uvtcmk270, 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:49mk270ok - yes, it is what i thought it is
15:49mk270i just didn't realise sequences were lazy
15:50mk270all is now clear. fair enough. thank you
15:51uvtcmk270, 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:51uvtcnon-lazy.
15:52uvtc"fully-realized". Not sure what the correct term is.
15:53fdaoudhi everyone
15:53fliebeldnolen: 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:53jmalonehello
15:53fdaoudI have a "there's gotta be a better way" question..
15:54mk270uvtc: cheers
15:54fdaoudin a ring handler, I want to add a param to request :params. I have (handler (assoc request :params (merge (request :params) {:myaddkey "myaddvalue"})))
15:55fdaoudis there a nicer way to do that?
15:55Vinzentfdaoud, update-in
15:55dnolenfliebel: not sure what you mean.
15:56weavejester,(update-in {} [:params :myaddkey] "myaddvalue")
15:56clojurebot#<ClassCastException java.lang.ClassCastException: java.lang.String cannot be cast to clojure.lang.IFn>
15:56weavejesterOh, assoc-in
15:56weavejester,(assoc-in {} [:params :myaddkey] "myaddvalue")
15:56clojurebot{:params {:myaddkey "myaddvalue"}}
15:56Vinzentum, right!
15:56fliebeldnolen: (lambda (x y) (fresh (z) (goalfd x y z))) -> Constrained variable ~s without domain with irritant
15:57Vinzentbtw, where is 'dissoc-in'?
15:57weavejesterVinzent: Not in clojure.core, but I believe I saw it in core.incubator
15:57Vinzentweavejester, oh, so it'll be in 1.4
15:58fdaoud,(let [req {:params {:a 5 :b 8}}] (assoc-in req [:params :c] 42))
15:58clojurebot{:params {:c 42, :a 5, :b 8}}
15:58weavejesterVinzent: Maybe. I'm not sure that everything in incubator will be in 1.4.
15:58fdaoudfantastic! thanks weavejester and Vinzent!
15:59dabdI 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:59dabdclojuredocs is outdated
15:59mdeboarddabd: http://dev.clojure.org/display/design/Where+Did+Clojure.Contrib+Go
16:00fdaoudweavejester: btw thanks for compojure et. al., loving it
16:01dnolenfliebel: 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:02dnolenfliebel: I think some sort of domain inference would be nice, but that would complicate Scheme cKanren. Certainly something to consider for Clojure cKanren
16:03fdaoudone day I'd like to write a clojure web development book.. and hopefully it would get as good reviews as the stripes book
16:03dabdmdeboard: that's what I am following but it does not have a search facility
16:03ibdknoxdnolen: the GSOC thing is awesome!
16:03dnolenibdknox: totally!
16:03fdaoudthings are moving just a little too fast now though
16:04fdaoudring, compojure, noir, clojurescript..
16:04ibdknoxyeah
16:04ibdknoxI don't think now is the right time for a book on this stuff
16:04ibdknoxit'll be wrong by the time you finish writing a single chapter ;)
16:04fdaoudyeah
16:05fliebeldnolen: 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:05mefestoi'm lovin stencil with clojure web dev :)
16:05fdaoudsure is a lot of fun to explore though
16:05ibdknoxit'll only get better
16:05mefestoi was using hiccup but i guess im so used to using snippets of html that i can't break away
16:05ibdknoxI have lots of things up my sleeve still
16:06fdaoud:)
16:06ibdknoxmefesto: totally, it's not for everyone
16:06fdaoudgonna try your db stuff next
16:06dnolenfliebel: I don't see why that's a problem.
16:06fdaoudum..
16:06fdaoudthe name escapes me
16:06mdeboarddabd: I see. Apparently not.
16:06fdaoudkarma?
16:06ibdknoxkorma
16:06jolyfliebel: 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:06fdaoudyes
16:06ibdknoxhttp://sqlkorma.com
16:06dabdif 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:07fliebeldnolen: Okay, then I love domain inference already.
16:07fdaoudscreencasts are another possibility
16:07ibdknoxdnolen: 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:07fdaoudyou learn this stuff and you love it, you want to share the joy
16:08ibdknoxdnolen: which is not to say it isn't, just curious if you know of uses out in the wild
16:10fdaoudat the current rate, you find a tutorial on a blog from a year and a half ago and it's already outdated
16:11jodaroa year and a half
16:11dnolenibdknox: some folks at relevance have used it, some folks at revelytix have used it.
16:11jodaroor, like, a week
16:11uvtcfdaoud, 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:12fdaouduvtc: good points
16:12uvtcfdaoud, 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:12dnolenibdknox: i believe there's a real world presentation about it at Clojure/west
16:12dnolenibdknox: also I have a feeling a lot of people will use it in the real world w/ the kibit linter :)
16:12ibdknoxdnolen: 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:12uvtcfdaoud, I created an "external articles" sub-page at that wiki. Hopefully it will start to fill up.
16:13ibdknoxdnolen: absolutely, I was looking at it for some interesting code pattern matching stuff. Though I think starting from the analyzer would be better
16:13dnolenibdknox: exactly, I would use where it solves the problem in a cleaner simple way - where performance is not of the utmost concern.
16:13ibdknoxdnolen: got it
16:14dnolenibdknox: I've definitely got ideas on how to make it a lot faster - but those are very long term goals.
16:15jolydnolen: 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:15ibdknoxdnolen: 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:16dnolenjoly: 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:17dnolenibdknox: nor have I but I think people will come up w/ more and more cool stuff as time goes on.
16:18jolydnolen: I'd be very interested in hearing your ideas on it
16:18dnolenjoly: did you look at the cKanren paper?
16:20fliebeldnolen: aww, there is no way to write a proper recursive goal with finite domains, this hurts a bit.
16:20jolydnolen: 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:22dnolenfliebel: why? I've written recursive goals.
16:23fliebeldnolen: well, as soon as you use fresh, you are in trouble.
16:23dnolenjoly: the cKanren paper is very good, but there are lot of obvious perf optimizations we can make.
16:24jolydnolen: Yeah, I was think of hash lookups for domains and constraints at the very least
16:24dnolenfliebel: i don't follow, http://dosync.posterous.com/another-taste-of-ckanren
16:25jolythinking*
16:25dnolenjoly: 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:27jolydnolen: 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:28fliebeldnolen: Ah, you pass around n, to create a domain while recurring. I'm back to the drawing board.
16:29dnolenjoly: 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:30dnolenfliebel: yep
16:31jolydnolen: 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:32fdaoudgood weekend all
16:35dabdhow do i use clojure.contrib.monadic-io-streams with 1.3.0? It was not ported to the new modules
16:35fliebeljoly: So are you going to do cKanren for GSOC?
16:35jolyfliebel: sadly I don't think I qualify for GSoC
16:36TimMcdabd: You could try forking it and upgrading it to work with 1.3
16:36mdeboardWhich raises the question of why clojuredocs.org is out of date, is it something that more manpower can fix
16:37fliebeljoly: Me neither. I think it would have been nice to apply with cKanren tough.
16:37jolyfliebel: yeah
16:40fliebel> (run 1 (q) (fresh (x) (infd q x (range 0 100)) (divfd q 10 1 3 x)))
16:40fliebel(3)
16:41dnolen fliebel: excellent
16:42dnolenfliebel: I hear that Dan & Will might be working on CLP(R)
16:44fliebeldnolen: Insane... Does that just mean you get to do (infd x y (range 1 10 0.5))?
16:49dnolenfliebel: I don't think you need to specify an increment. I haven't looked at CLP(R) too closely.
16:50jolyfliebel: I would expect it to keep and operate on ranges, not make it into a finite domain
18:09yoklovoh huh. clojure/core is part of google summer of code.
18:09yoklovlooks what i know what i'm going to try to do this summer.
18:23_ulisesevening
18:24_ulisesis anybody doing the NLP stanford course? If so, have you got a clojure skeleton for submitting the course work?
18:28mayanks43_ulises spamlord??
18:28lazybotmayanks43: Definitely not.
18:28_ulisesmayanks43: yes
18:29jaen_ulises: is that course polyglot then?
18:29_ulisesjaen: I don't think so; I'm hoping I can write the solutions in clojure and submit the .class files
18:29jaenso it's Java then?
18:29_ulisesJava/Python
18:31jaenOkay, Python at least sounds reasonable, I feel weird without the ability to be somewhat FPy
18:31jaenAt the very least
18:31_uliseshum, I just checked out Submit.java and it will try to submit SpamLord.java; clojure won't be an option :/
18:32_ulisesand 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_ulisesit'll have to be Python I guess
19:00ashafahello
19:00ashafahow's clojurewest?
19:01ashafaCan I bother anybody with some problem with the clojurescript compiler that I have?
19:03ashafabasically (.in some-obj "x") compiles to some-obj.in$("x") in cljs
19:03ashafanotice the in$
19:04ashafawhat I'm I doing wrong?
19:04ashafaam I*
19:17prasadI was to define a map of regex and a function (without a name), how can I define it?
19:17qbg{#"foo" (fn [x] (+ x 1)), #"bar" (fn [x] (- x 1))}
19:17qbg?
19:18prasadqpg, thnks
19:21ashafaAnyone know why the 'in$' in clojurescript?
19:22septominprobably because "in" is a keyword?
19:23ashafai was searching for in the api docs but couldnt find it
19:24septominhttps://developer.mozilla.org/en/JavaScript/Reference/Reserved_Words
19:25ashafaah javascript reserved keyword
19:55prasadmay 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:55qbgYou mean get the keys?
19:55qbg&(keys {:a 1, :b 2, :c 3})
19:55lazybot⇒ (:a :c :b)
19:59prasadok 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:00prasaddo I need to use map here
20:00prasad? i was trying to achieve that using doseq somehow
20:02tmciverprasad: Are you starting with a map or trying to build one?
20:02prasadI am starting with a hashmap
20:02qbg&(let [x {:a 1, :b 2}] (zipmap (keys x) (map inc (vals x))))
20:02lazybot⇒ {:b 3, :a 2}
20:03prasadits a map of regex and some function that I would like to apply on the matched result
20:08prasaddoes that sound valid?
20:08prasad(defn apply-regex-rules [rulesMap file] (let [apply-rule? (fn [rule] (re-seq rule file))] (map (apply-rule? %) &(keys rulesMap))))
20:09qbgDo you mean #(apply-rule? %)?
20:10prasadya, #(apply-rule? ..
20:10qbgWhich is equivalent to just apply-rule?
20:10prasadaah
20:11qbgI assume you don't mean the & in &(keys rulesMap)
20:11prasadI just want the map to be work on every key of the rulesMap
20:11qbgIt would be (keys rulesMap) then
20:12qbg(Lazybot evals expressions that start with &)
20:12qbg(probably your confusion there)
20:12prasadaah, ok, thnkx
20:12qbg(+ 1 2) ;; doesn't eval
20:12clojurebot3
20:12prasadatleast got it to compile
20:12qbgI guess clojure bot does in that case :p
20:13qbgAlso, camelCase is not commonly used for locals in Clojure
20:13qbgSo rules-map instead of rulesMap
20:14prasadaah, coming from java background, functional paradigm just giving me kicks, learning..
20:14qbgOur names can include - :)
20:15tmciverprasad: also, I assume your 'rule' is the regex? It looks like your not using the vals in your rules-map.
20:15qbgPersonally, I would call apply-rule? rule-applies?
20:15tmcivers/your/you're
20:16prasadtmciver, 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:16prasadthe intension is something like
20:17prasad(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:17tmciverprasad: might have to reheap that instead ;)
20:18prasad(def regexMap {#"\w[.\w+]*@\w+\.\w+" (fn [x] (x))} )
20:18prasad(defn apply-regex-rules [rulesMap file] (let [apply-rule? (fn [rule] (re-seq rule file))] (map #(apply-rule? %) (keys rulesMap))))
20:18prasad(apply-regex-rules regexMap "inputfile.txt")
20:19prasadand bingo, i forgot to slurp the file
20:19qbgTake this with you; it is dangerous to go alone: https://refheap.com/paste
20:19prasadohh my god it worked.
20:19prasadqbg, thnks
20:22tmciverprasad: 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:22prasadtmcviewer, how do I fetch the entry?
20:23prasad*tmciver
20:23prasad( ;) )
20:23tmciver(map (fn [[key val]] (dosomething key val)) some-map)
20:24tmciveror ...
20:24tmciver(map (fn [[regex func]] (func (some-fun regex)) some-map)
20:25tmciverprasad: 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:26prasadtmciver, thats right
20:26tmciverprasad: something like the above should allow you to do that in one step.
20:27tmciverprasad: the some-fun part would be your apply-rule? function, I guess.
20:30FrozenlockIs it possible to import a .java file?
20:31qbgYou need to compile it first
20:31qbgAnd then have the resulting class on the classpath
20:31qbg(or use classloader trickery)
20:32Frozenlock:(
20:32FrozenlockThanks
20:32qbgLeiningen can compile your java files for you and make them available
20:33FrozenlockOh? I do have leiningen...
20:33prasadtmciver: seems to work
20:33qbgthere is a javac task
20:33prasadthnkx
20:34FrozenlockThanks, I'll check the leiningen Doc!
20:46archaicLooking 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:50amalloyarchaic: you want to talk to TimMc
20:50amalloypretty sure he's into a project like that already
20:51archaicalright
21:01prasadhow can I concat sequence of strings in one big string
21:02xeqi,(apply str ["asdf "fdsa"])
21:02clojurebot#<ExecutionException java.util.concurrent.ExecutionException: java.lang.RuntimeException: EOF while reading string>
21:02xeqi,(apply str ["asdf" "fdsa"])
21:02clojurebot"asdffdsa"
21:03prasadthnkx
21:03qbgYou can also checkout clojure.string/join
21:04qbgEspecially useful if you need to interleave something between the parts
21:05prasadqbg, re-seq returns a sequence rite? seen as ("matched stuff"), I just want to do some string operations on this
21:06prasadsay, replace stuff with bang
21:06prasad(fn [x] (replace-str "stuff" "bang" x))
21:06qbg&(.replaceAll "matched stuff" "stuff" "bang")
21:06lazybot⇒ "matched bang"
21:07qbgThat's an easy way :p
21:08prasadi think this is more specific about applying func to the result of regex which is a sequence ()
21:34TimMcarchaic: org.baznex/imports
21:36TimMcarchaic: You probably want the rename function, so you'd get (e.g.) Watch/ENTRY_DELETE
21:36archaicexactly what I wanted, thanks
21:36TimMcIf you have any suggestions for an even fancier API, I'm open to suggestions.
21:44prasadCan some one help to debug why this is throwing #<IllegalArgumentException java.lang.IllegalArgumentException: Wrong number of args (2) passed to: regex-matcher$fn>
21:44prasadhttps://refheap.com/paste/1099
21:54stirfooprasad: you wouldn't be a spammer now would you?
21:54prasadI am not
21:56prasadstirfoo, was that about the link posted? or the stuff in the link?
21:58stirfooprasad: 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:59prasadstirfoo, yes you spotted correctly, just working on some nlp assignment, info extraction they call it. trying out clojure for the first time today
22:01prasadit 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:02qbg&(re-seq #"h(ello)" "hello world, hello")
22:02lazybot⇒ (["hello" "ello"] ["hello" "ello"])
22:03prasadqbg, i have added a "?:" that turns off the grabbing
22:04prasad&(re-seq #"h(?:ello)" "hello world, hello")
22:04lazybot⇒ ("hello" "hello")
22:06qbgYou are applying your fn to the result of re-seq
22:07qbgI suspect that you want (map func (apply-rule? regex)) instead of (apply func (apply-rule? regex))
22:07prasadqbg, I tried to use "apply func (regex-fun?)"
22:07prasadso I want to apply func on every element of sequence returned by regex
22:07qbgUse map
22:08qbg(apply f [1 2 3]) == (f 1 2 3)
22:08pyninjaWhy does this happen: https://gist.github.com/1ecad17978e06b3c5e78 ?
22:08qbg(map f [1 2 3]) == [(f 1) (f 2) (f 3)]
22:08prasadaah, ok, rite
22:09prasadqbg, thnks for pointing out
22:09prasadworks
22:10qbgpyninja: Works for me at the repl
22:10prasadqbg, do you have better idea for applying number of replace functions on a string?
22:10qbgAre you using some ide?
22:10qbgIf so, which?
22:10pyninjaqbg: what does it say? I'm running lein repl on Mac OS X (which rlwrap installed).
22:10pyninjawith*
22:11qbgI get \<that character> for the second form
22:11qbgI'm just running the jar directly though
22:11qbgEncoding issue probably?
22:12pyninjaHm, I guess. But it's clearly capable of displaying unicode characters so I don't understand what's wrong...
22:12qbgI see the same thing with lein repl
22:12qbgI think lein repl is broken
22:13qbgTry printing out x
22:13qbgIt didn't like that string very much
22:13pyninjathat works for me
22:13gtuckerkelloggqbg, perhaps the encodin on the terminal
22:14pyninjathe terminal encoding appears to be fine
22:14qbgIt works at my terminal just running the jar
22:14qbgLeiningen 1.7.0 on Java 1.6.0_23 OpenJDK 64-Bit Server VM
22:14gtuckerkelloggfor me i get both behaviors
22:14gtuckerkelloggit work find in emacs swank repl
22:14qbgI don't have rlwrap, so I think it is dropping back to jline
22:15pyninjayeah
22:15gtuckerkelloggbut under the terminal it doesn't
22:15qbgprasad: Use reduce and .replaceAll?
22:17qbg&(reduce (fn [s [regex rep]] (.replaceAll s regex rep)) "hello, beautiful world!" {"beautiful" "ugly", "hello" "bye"})
22:17lazybot⇒ "bye, ugly world!"
22:17prasadqbg, beauty.
22:19prasada 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:19qbgYou mean concurrent execution?
22:19prasadyes
22:19qbgThere is pmap
22:19qbgBut that has some overhead
22:19qbg&(doc pmap)
22:19lazybotjava.lang.SecurityException: You tripped the alarm! pmap is bad!
22:19prasadbut i mean parallel, if run on multicores
22:19qbg,(doc pmap)
22:19clojurebot"([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:20prasadthnk
22:21jtoywhat is the proper way to convert a map to a vector?
22:21qbgjtoy: what do you want the vector to look like?
22:21qbgprasad: normal map is lazy, so the values are computed on demand
22:22jtoyqbg: a => val, b => val , I'm pretty new to clojure, so trying to get a program running
22:22qbgSo {:a 1, :b 2} becomes [:a => 1 :b => 2] ?
22:23jtoyqbg: yes
22:23qbg&(vec {:a 1, :b 2})
22:23lazybot⇒ [[:a 1] [:b 2]]
22:24jtoyqbg: what does & mean there? is that just for lazybot ?
22:24jtoy&(+ 1 2)
22:24lazybot⇒ 3
22:24qbgYes, for lazybot
22:24jtoyyes
22:24qbg&(vec (mapcat (fn [[k v]] [k '=> v]) {:a 1, :b 2}))
22:24lazybot⇒ [:a => 1 :b => 2]
22:25jtoyqbg: ok ,so that just converts a whole vector, I'll try doing that for now
22:25qbgWhy do you need to convert a map to a vector?
22:26qbgMaps are already seqable
22:26jtoyqbg: I'm trying to make this work: http://groups.google.com/group/cascalog-user/browse_frm/thread/fb212cd71ca19329#
22:26jtoynevermind, I see it now. The problem is with (json/parse-string ..), which is returning a map. You need to return a vector.
22:31qbgI haven't used Cascalog, but using vec there might be what you need to do
22:41jtoyqbg: k thanks, still trying to figure it out
22:42FrozenlockI'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:44qbgHere is how you do in straight Java: http://docs.oracle.com/javase/6/docs/api/javax/swing/JFrame.html#setDefaultCloseOperation%28int%29
22:46FrozenlockThanks! (frame :title "My frame" :on-close :exit) works perfectly!
22:55jtoynice ,got it to work ,although not sure why :)
23:00jtoyhow 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:00jtoy [line]
23:00jtoy (map (json/parse-string line) ["a_id" "b_id"]))
23:58uvtcCan anyone point me to documentation or a blog article that explains the lifecycle of a how Clojure code gets compiled and run?