2011-01-03
| 00:18 | anthony_ | I know this is question has a very obvious answer, but I'm stuck. I'm trying to use Compojure for the first time (so it might not even belong here). How can I use a javax.servlet.Servet? It looks like there used to be a run-server function that would accept a servlet, but that's gone. |
| 00:56 | amalloy | i'm still using 1.2.0 but i'd like to be future-friendly for a var i'd like to be dynamic-bindable. how do i do that? (def ^{:dynamic true} foo bar) feels right, but i'm not sure if i actually read that anywhere |
| 01:35 | auser | what is the '->>' operator called/do? |
| 01:36 | qbg | It is a thrush operator |
| 01:36 | qbg | (->> 1 (* 2) (+ 3)) == (+ (* 1 2) 3) |
| 01:37 | qbg | I mean (+ (* 2 1) 3) |
| 01:37 | qbg | Urg |
| 01:37 | auser | can't find it in the docs... hmmm |
| 01:37 | qbg | (+ 3 (* 2 1)) |
| 01:37 | qbg | ,(clojure.walk/macroexpand-all '(->> 1 (* 2) (+ 3))) |
| 01:37 | clojurebot | (+ 3 (* 2 1)) |
| 01:38 | auser | not sure I understand... |
| 01:38 | auser | hm |
| 01:38 | _na_ka_na_ | amalloy: good point about being future friendly, I'm also in the same bucket, I would like to ask a broader question - if something runs with 1.3, will it also run with 1.2, w/o any code changes (except classpath changes ofc) |
| 01:38 | qbg | It makes the previous form be the last element of the next list |
| 01:38 | auser | ahh |
| 01:39 | qbg | Useful for making functional operations look sequential |
| 01:39 | tomoj | http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E#example_191 |
| 01:39 | _na_ka_na_ | auser, http://clojuredocs.org/clojure_core/clojure.core/-%3E%3E |
| 01:39 | tomoj | hmm, should've unfolded the iterate |
| 01:39 | auser | awesome! thanks _na_ka_na_ |
| 01:40 | amalloy | &(macroexpand-all '(->> (range) (filter even?) (take 10) (map #(* 5 %)) (reduce +))) |
| 01:40 | sexpbot | ⟹ (reduce + (map (fn* [p1__8789#] (* 5 p1__8789#)) (take 10 (filter even? (range))))) |
| 01:41 | tomoj | there :) |
| 01:41 | tomoj | ooh, adding a sum on the end would be good too |
| 01:41 | amalloy | auser: that's sorta a typical use: you're performing a long sequence of operations on a single value, and it's more legible as a sequence of steps than as a nested operation |
| 01:41 | amalloy | tomoj: i did |
| 01:41 | auser | I see... that could definitely clean up some of my code |
| 01:41 | tomoj | I meant in the example on clojuredocs |
| 01:41 | amalloy | ah |
| 01:42 | tomoj | oh, and (iterate inc 0) is outdated now.. |
| 01:43 | amalloy | tomoj: i assumed we'd had (range) forever; is it new as of 1.2.0 or something? |
| 01:43 | tomoj | it's recent |
| 01:44 | tomoj | not sure when |
| 01:44 | amalloy | &(-> range var meta :since) |
| 01:44 | sexpbot | ⟹ nil |
| 01:44 | amalloy | &(-> range var meta) |
| 01:44 | sexpbot | ⟹ {:ns #<Namespace clojure.core>, :name range, :file "clojure/core.clj", :line 2246, :arglists ([] [end] [start end] [start end step]), :added "1.0", :doc "Returns a lazy seq of nums from start (inclusive) to end\n (exclusive), by step, where start defaults to 0, step to 1, and end\n to infinity."} |
| 01:44 | amalloy | hm. it claims 1.0, but i don't think that's really trustworthy |
| 01:46 | tomoj | a55df92f |
| 01:46 | tomoj | april |
| 01:47 | _na_ka_na_ | hey guys how is this example of ->> ... (->> (read) (eval) (println) (while true)) ! |
| 01:47 | _na_ka_na_ | make your own repl |
| 01:47 | amalloy | cute |
| 01:47 | tomoj | you can shave some parens |
| 01:48 | _na_ka_na_ | ya but they're required in general .. (->> read eval println (while true)) |
| 01:48 | amalloy | _na_ka_na_: read still needs parens |
| 01:48 | _na_ka_na_ | oh ya |
| 01:49 | _na_ka_na_ | that's why I prefer to use () always |
| 01:49 | _na_ka_na_ | can I add this to clojuredocs ? |
| 01:49 | amalloy | i think it's a great example; to be more repl-like i'd like to use loop instead of while |
| 01:49 | _na_ka_na_ | hmm |
| 01:49 | tomoj | think you just need an account |
| 01:49 | amalloy | but it's a little tricky to manage |
| 01:54 | _na_ka_na_ | (->> (read) (eval) (println) (#(loop [] % (recur)))) |
| 01:55 | _na_ka_na_ | not so pretty |
| 01:56 | _na_ka_na_ | how about with this.. (defmacro loop-forever [& body] `(loop [] ~@body (recur))) |
| 01:58 | amalloy | _na_ka_na_: if you're going to define a loop-forever macro, it might as well use the more legible while true |
| 01:59 | _na_ka_na_ | amalloy: I was just going with the theme of the L in REPL |
| 02:00 | amalloy | _na_ka_na_: sure, i was just saying that if the final form will look like (->> ... (loop-forever)) it doesn't matter much whether loop-forever's implementation starts with an L; but of course it's fine if it does :) |
| 02:00 | _na_ka_na_ | amalloy: is its probably a better example for -> .. coz ->> are generally used for sequences |
| 02:01 | amalloy | _na_ka_na_: true |
| 03:10 | auser | interesting |
| 03:11 | auser | sorry, wrong window |
| 03:12 | Licenser | ,prmomg everypmne |
| 03:12 | clojurebot | java.lang.Exception: Unable to resolve symbol: prmomg in this context |
| 03:12 | Licenser | orning I mean |
| 03:16 | amalloy | Licenser: i moved the keys on your keyboard while you were sleeping |
| 03:42 | ddudey | i'm trying to create a clojars jar with native-deps but they're not extracting correctly. Has anyone got any experience? |
| 04:12 | LauJensen | I think all the bits are in for ClojureQL 1.0 now, so after a few reviews of the code I expected to release within the next 24 hours or so |
| 04:13 | ejackson | nice on LauJensen |
| 04:23 | ossareh | LauJensen: clojureql being some sql interface? |
| 04:23 | LauJensen | ossareh: http://bestinclass.dk/index.clj/2010/11/clojureql--1.0.0-now-in-beta.html |
| 04:25 | ossareh | looks sweet - part of the manly CMS? |
| 04:26 | LauJensen | No the manly CMS is cooking up the website for ClojureQL :) |
| 04:27 | LauJensen | But I assure you, both libraries are quite manly, yet elegant! |
| 04:33 | ossareh | nice - definitely looking forward to seeing the CMS |
| 04:34 | ossareh | what is the secret to getting dispatch to work on multimethods being fed records? |
| 04:34 | ossareh | (defmulti some-fn class) (defmethod some-fn ???? :foo) |
| 04:34 | ossareh | what is ??? ? |
| 04:36 | ossareh | I'm consistenly getting "No method in multimethod 'rec-test' for dispatch value: class surveyengine.storage.Foo" |
| 04:37 | ossareh | oh, it works - sorry. I'd been slimed. |
| 05:20 | Licenser | amalloy_: I'm in the office I am constantly sleeping |
| 05:53 | neotyk | Morning everyone, Happy New Year! |
| 06:10 | LauJensen | neotyk: Morning :) |
| 07:27 | no_mind | Someone please explain me this code http://pastebin.ca/2037667 . I am confused on the map part. Map function takes two argument but here only one is passed and yet no error ? |
| 07:28 | Chousuke | no_mind: there are two arguments |
| 07:28 | Chousuke | no_mind: (map ref (take 5 (repeat 0))) |
| 07:29 | Chousuke | other than that, it's broken code because there is no argument vector for let :P |
| 07:29 | Chousuke | or binding vector |
| 07:29 | no_mind | Chousuke, I copied it from somewhere. If I do a println instead of ch it works. |
| 07:30 | Chousuke | instead of let you mean? |
| 07:30 | no_mind | But I cant understand 2 arguments. Is ref considered an function arg here ? |
| 07:30 | Chousuke | yes |
| 07:30 | no_mind | Chousuke, yes |
| 07:30 | Chousuke | it's the function |
| 07:30 | Chousuke | no_mind: the let doesn't work because it's missing the vector form |
| 07:31 | Chousuke | it's supposed to be (let [ch (zipmap ...)]) |
| 07:31 | no_mind | ok |
| 07:31 | Chousuke | I suppose it looks like a single argument because there's no space between ref and the second argument |
| 07:32 | Chousuke | so you might think it's a function call or something :P |
| 07:34 | no_mind | yup, I thought it is a function call :) |
| 07:35 | Chousuke | function calls start with a ( |
| 07:35 | Chousuke | :) |
| 10:21 | jfields | Does clojure have a fn that does this: |
| 10:21 | jfields | (defn apply-while [f-to-apply init-val pred boundry-val] |
| 10:21 | jfields | (loop [v init-val] |
| 10:21 | jfields | (if (pred v boundry-val) |
| 10:21 | jfields | v |
| 10:21 | jfields | (recur (f-to-apply v))))) |
| 10:22 | jfields | seems like something generic that should already be there, and I don't want to reinvent the wheel. :) |
| 10:23 | opqdonut_ | you can use iterate and take-while |
| 10:23 | pdk | so the idea is |
| 10:23 | opqdonut_ | for the same effect |
| 10:23 | pdk | it returns the same list but applies f-to-apply on the values in the list that meet the predicate |
| 10:23 | opqdonut_ | ,(take-while (partial > 5) (iterate inc 2)) |
| 10:23 | clojurebot | (2 3 4) |
| 10:24 | jfields | actually, I'm using it for, (apply-while dec 5 < 3), which returns 2 |
| 10:24 | opqdonut_ | add a call to last if you only want the last element |
| 10:24 | jfields | gotcha |
| 10:24 | opqdonut_ | but of course the clojure implementation doesn't roll out those sequence operations |
| 10:24 | opqdonut_ | so your loop version should be faster |
| 10:25 | jfields | I guess it's poorly named too, it should be apply-until... anyway. thanks for the help. |
| 10:31 | leafw | has anybody noticed the bug regarding boxing/unboxing with nested loops? |
| 10:32 | leafw | http://groups.google.com/group/clojure/browse_thread/thread/1af34b3ab3779460 |
| 10:32 | leafw | Allen wrote a nice minimal example |
| 10:51 | dnolen | leafw: I don't think loop can return primitives. |
| 10:52 | leafw | dnolen: aha, so that is the issue. I thought loop was like a let? Can't let return a primitive either? |
| 10:53 | dnolen | leafw: I doubt it. But not sure. |
| 10:53 | dnolen | leafw: only fns can return primitives as far as I know. |
| 10:53 | chouser | err |
| 10:53 | Chousuke | hm. loop and let should work with primitives |
| 10:53 | chouser | which version of clojure are we talking about? |
| 10:54 | leafw | git master |
| 10:55 | leafw | let can, I just tested it: (let [i (let [k (int 0)] k)] (inc i)) |
| 10:55 | leafw | doesn't give any warning .. not sure if the test is correct though |
| 10:55 | chouser | (expression-info '(loop [a 1] a)) ;=> {:class long, :primitive? true} |
| 10:55 | leafw | right, bad test |
| 10:56 | chouser | (expression-info '(let [i (let [k (int 0)] k)] (inc i))) ;=> {:class long, :primitive? true} |
| 10:57 | chouser | (expression-info '(let [i (let [k (int 0)] k)] (+ (Integer. 5) i))) ;=> {:class java.lang.Number, :primitive? false} |
| 10:58 | leafw | chouser: then why: (loop [b (int 0)] (let [c (loop [a 1] a)] (if false (recur (inc c))))) |
| 10:58 | leafw | ... igves a boxing warning? |
| 10:58 | leafw | Auto-boxing loop arg: b |
| 11:04 | chouser | leafw: hm, it may indeed be a bug. |
| 11:05 | chouser | (expression-info '(loop [a 1] a)) ;=> {:class long, :primitive? true} |
| 11:05 | chouser | (expression-info '(let [c (loop [a 1] a)] c)) ;=> nil |
| 11:06 | chouser | ...indicating that the compiler doesn't know the type of that 'let', and so will treat it as Object |
| 11:06 | leafw | chouser: uf, ok, so I am not allucinating |
| 11:06 | chouser | no autobox warning for: (loop [b 0] (let [c (long (loop [a 1] a))] (recur (inc c)))) |
| 11:06 | leafw | chouser: I'd appreciate if you file it. |
| 11:07 | leafw | yeah sure, but that cast should not be needed, as far as let and loop are supposed to work |
| 11:07 | chouser | right |
| 11:16 | SergeyD | Hi, is pre and post conditions on protocols are planned? Right now I can't make it work neither in protocol declaration nor in protocol implementation in deftype. I'm using Clojure 1.2 |
| 11:17 | SergeyD | It is mentioned on http://www.assembla.com/wiki/show/clojure/Protocols in "Old ideas/scratchpad", that's all I have found on this topic |
| 11:18 | SergeyD | Sorry for grammar errors :) |
| 11:20 | chouser | good question. I haven't heard of any concrete plans, but it does seem like something that would be useful, and I can't think of any techincal reason why it couldn't be done. |
| 11:23 | SergeyD | I see, thanks Chouser |
| 11:24 | leafw | a quicksort in java for a double[] and associated int[] array that keeps track of the indices: https://gist.github.com/763139 -- takes about 15x a java version of it (java: 0.00568 ms; clj: 0.088 ms) |
| 11:24 | leafw | type hints are in, and all math is primitive. What could account for clojure being slower? |
| 11:27 | SergeyD | leafw, that is for 1.3, right? |
| 11:28 | leafw | SergeyD: yes |
| 11:28 | leafw | I tried making the functions static, or turning them into macros: no improvement. |
| 11:28 | leafw | the wya it's written, I'd think it should run as fast as java. |
| 11:30 | qbg | Maybe using aset-double and aset-int would help? |
| 11:30 | chouser | have you tried unchecked math? I'm not sure what Java does by default. |
| 11:30 | leafw | chouser: java does unchecked math |
| 11:30 | leafw | is there are atrigger for unchecked math, or should one use unchecked-add, aetc. ? |
| 11:31 | qbg | *unchecked-math* |
| 11:31 | a_strange_guy | you can set! *unchecked-math* to tru i think |
| 11:31 | leafw | ok,trying that |
| 11:31 | leafw | doesn't exist ... not in git master |
| 11:32 | qbg | Are you up to date? |
| 11:32 | leafw | from yesterday, yes |
| 11:33 | qbg | You are using https://github.com/clojure/clojure right? |
| 11:33 | leafw | url = git://github.com/clojure/clojure.git |
| 11:34 | qbg | You ran ant? |
| 11:34 | leafw | I do |
| 11:34 | qbg | Hmm... |
| 11:35 | leafw | it generated clojure-1.3.0-master-SNAPSHOT.jar |
| 11:36 | qbg | Here is the commit that added it: https://github.com/clojure/clojure/commit/aa7d26336faff6ccc65e4405e28e471221f35fc4 |
| 11:39 | leafw | adding unchecked-inc-int for inc and -dec- for dec reduced from 0.088 to 0.056, still ~10x slower |
| 11:40 | abedra | cemerick: do you still need access to build.clojure.org? |
| 11:40 | abedra | cemerick: I am locking down the machine |
| 11:40 | abedra | cemerick: because hudson will start doing the clojure releases |
| 11:40 | leafw | qbg: I have that commit, strange, ... I'll do a clean again |
| 11:41 | cemerick | abedra: no, you can drop me |
| 11:41 | abedra | cemerick: ok cool, if you need ssh access again just let me knows |
| 11:41 | abedra | know |
| 11:41 | cemerick | sure, thanks |
| 11:42 | a_strange_guy | leafw: your code compiles down to primitive calls on my clojure |
| 11:42 | cemerick | abedra: FYI: the gpg key should probably be backed up somewhere else |
| 11:42 | abedra | cemerick: agreed |
| 11:42 | a_strange_guy | checked it with a java disassembler |
| 11:42 | cemerick | in addition to whatever regular backups are going on, that is |
| 11:43 | abedra | cemerick: I have a list of things that are set for a backup strategy |
| 11:43 | abedra | I just have to pick or setup a service for it |
| 11:43 | abedra | right now contegix is doing backups of the machines |
| 11:44 | abedra | but that's not quite good enough for things |
| 11:45 | leafw | a_strange_guy, qbg : I recompiled, speed still 10x slower than java |
| 11:45 | qbg | How many times are you running the code? |
| 11:45 | leafw | a_strange_guy: indeed there aren't any boxing/unboxing calls |
| 11:46 | leafw | qbg: I am testing with 10x |
| 11:46 | leafw | dotimes 10 |
| 11:46 | qbg | Try a larger number |
| 11:46 | a_strange_guy | of corse it will be much slower than the java version |
| 11:46 | a_strange_guy | your arrays are too small |
| 11:46 | a_strange_guy | the JIT wont kick in |
| 11:47 | leafw | a_strange_guy: ok, trying with random array with 100,000 elements |
| 11:48 | a_strange_guy | the compiler compiles everything down to static function calls |
| 11:49 | a_strange_guy | those are just easy to inline, but won't be inlined automatically |
| 11:53 | SergeyD | leaf, use the code like: (dotimes [_ 5] (println (time (dotimes [_ 100000] (inc 3))))) |
| 11:55 | chouser | leafw: http://dev.clojure.org/jira/browse/CLJ-701 |
| 11:55 | SergeyD | BTW, I wonder if JIT can find out that the result of every iteration above is not used and omit that call? |
| 11:56 | SergeyD | In that case more complex timing code should be used, something like accumulating the result of every iteration |
| 11:58 | leafw | chouser: thanks |
| 11:59 | a_strange_guy | SergeyD: the jit cant do that because it must call .getVarRoot on a var each call |
| 11:59 | a_strange_guy | and the root of a var is marked volatile |
| 12:00 | chouser | a_strange_guy: are you sure that's still true? |
| 12:00 | a_strange_guy | chouser: not 100% 'ly |
| 12:01 | a_strange_guy | chouser: still volatile |
| 12:05 | ejackson | chouser: is there an obvious solution for the case, when using fill-queue, when the return value of filler-func needs to be returned ? In my case filler-func returns a client that I need later to affect requests. |
| 12:09 | SergeyD | leafw, it's ~400ms for 100000 iterations on my computer. How did you test the java version? |
| 12:11 | chouser | ejackson: when filler-func returns, the nothing else can be added to the queue. How can it's return value affect later requests? |
| 12:12 | ejackson | chouser: its a call into a java lib (that I don't control), that starts its own thread. |
| 12:12 | leafw | SergeyD: I have my own implementation, but I think it has an error in it. I am looking at it at the moment. |
| 12:14 | ejackson | you call a function passing it a callback (i'm using fill), it constructs a client, starts it in another thread, and returns a reference to it. I'm using filler-func as the call to this constructor function. |
| 12:14 | leafw | SergeyD: the clj version runs in 24 ms here for 100000 elements :) |
| 12:15 | ejackson | chouser: oh, i get you, sorry. dumb. |
| 12:16 | bmh | Does clojure have a construct like scheme's boxes? |
| 12:16 | ejackson | chouser: I'll be on my way... rethink. Thanks. |
| 12:17 | qbg | bmh: atoms perhaps? |
| 12:17 | qbg | Basically any of the reference types |
| 12:18 | bmh | wonderful |
| 12:18 | bmh | I'm implementing embedded planar graphs and it would be nice not to route everything through a hash table. |
| 12:19 | kumarshantanu | is anybody using Clojure 1.3.0 Alpha-4 as a Maven dependency yet? can you tell me me the artifactId etc? |
| 12:20 | SergeyD | kumarshantanu, this is working in my leiningen file: "[org.clojure/clojure "1.3.0-master-20101220.130227-7"]" |
| 12:21 | leafw | SergeyD: longer arrays do make the JIT kick in: 10^7 random doubles, java: 171 ms, clj 307 ms (last of 10 runs) |
| 12:21 | leafw | SergeyD: still a factor of 2x, but far from 15x that I saw at the beginning |
| 12:22 | leafw | 10^6 sorry, one million |
| 12:23 | leafw | so unless one runs a large array first, small arrays will get sorted slowly. Strange prospect. |
| 12:23 | kumarshantanu | SergeyD: thanks it's working for me too |
| 12:28 | SergeyD | leafw: JIT will compile small arrays too if you run it 100000 times |
| 12:28 | a_strange_guy | yah, but creating array in clojure is more expensive than in java |
| 12:28 | a_strange_guy | ^yeah |
| 12:29 | leafw | SergeyD: we hope :) |
| 12:29 | leafw | I wait for the day that clojure can really perform as fast as java when it comes to math. It's come a long way, and it looks like within months that may happen. |
| 12:30 | SergeyD | a_strange_guy: that's true |
| 12:30 | SergeyD | leafw: I don't hope, I have just measured :) |
| 12:31 | a_strange_guy | leafw: I think java will still be faster, mostly because you can use ints and not longs |
| 12:31 | a_strange_guy | and the overhead to fetch a fn from a var still exists |
| 12:33 | leafw | a_strange_guy: in a 64-bit machine, int vs long may not make much of a difference |
| 12:34 | leafw | a_strange_guy: there's always macros. Once the code looks nice, one can macro it to death. Never try to edit it again. |
| 12:34 | leafw | a_strange_guy: or define fn as static. Seems to make a big difference. |
| 12:35 | a_strange_guy | ^:static is gone for now |
| 12:35 | leafw | it;s a no-op ? |
| 12:35 | leafw | one can still write (defn afn ^:static [] ^:void ... ) |
| 12:35 | leafw | the compiler does not complain. |
| 12:36 | a_strange_guy | yeah, but it's a no-op |
| 12:36 | a_strange_guy | static is replaced by non-dynamic vars by default |
| 12:37 | a_strange_guy | $(fn ^:a-unneeded-annotation ^:and-another self [] nil) |
| 12:37 | a_strange_guy | &(fn ^:a-unneeded-annotation ^:and-another self [] nil) |
| 12:37 | sexpbot | ⟹ #<sandbox6382$eval8816$self__8817 sandbox6382$eval8816$self__8817@1ab2399> |
| 12:37 | a_strange_guy | the compiler -never- complains xD |
| 12:38 | a_strange_guy | yeah, littering your code with macros can produce identical performance to java already |
| 12:39 | a_strange_guy | &(doc definline) |
| 12:39 | sexpbot | ⟹ "Macro ([name & decl]); Experimental - like defmacro, except defines a named function whose body is the expansion, calls to which may be expanded inline as if it were a macro. Cannot be used with variadic (&) args." |
| 12:39 | leafw | a_strange_guy: interesting. Like a macro, but clean like a function |
| 12:39 | leafw | thnaks for the pointer |
| 12:40 | chouser | and so fun to exploit |
| 12:40 | a_strange_guy | is there some reason why you can't have variadic inlines? |
| 12:43 | qbg | Would variadic inlines be very useful? |
| 12:43 | leafw | hum, definline doesn't work for me: java.lang.ClassCastException: clojure.lang.Symbol cannot be cast to java.lang.Number ... in fn that takes as arguments: (definline aswap! [^doubles vals ^ints idxs ^long x ^long y] ...) |
| 12:44 | chouser | no point in hinting the args |
| 12:44 | chouser | hm, well, maybe there is. But I'm not surprised it doesn't work. |
| 12:49 | leafw | chouser: without the hints, the compiler warns about reflection |
| 12:49 | leafw | so it doesn't work by design, and thus I dont understand how to use definline, or is it an error? |
| 12:50 | chouser | definline is old. primitive-hinted fn args are new. I'm not sure the two have been thought about together by anyone. |
| 12:50 | leafw | chouser: so definline is up for a revision. |
| 12:50 | chouser | or removal perhaps |
| 12:50 | rak85 | hi, guys |
| 12:51 | rak85 | is there any function that returns a boolean if a string starts with some substring? |
| 12:51 | rak85 | like (starts-with? "aba" "abaca") |
| 12:51 | chouser | ,(.startsWith "abaca" "aba") |
| 12:51 | clojurebot | true |
| 12:51 | rak85 | thanks! |
| 12:51 | leafw | ,(.startsWith "abaca" "aba") |
| 12:51 | clojurebot | true |
| 12:52 | leafw | oops :) |
| 13:33 | AWizzArd | A starts-with that works on all sequences would be interesting, taking a comparator. |
| 13:37 | chouser | (defn starts-with [c x y] (every? zero? (map c x y))) |
| 13:37 | amalloy | AWizzArd: (fn [a b] (every? identity (map = a b))) |
| 13:38 | amalloy | chouser: actually neither of our solutions is right |
| 13:38 | amalloy | if the starts-with sequence is longer than the sequence to test against, map returns prematurely |
| 13:39 | chouser | good point |
| 13:40 | amalloy | (fn [a b] (= b (take (count b) a))) is neither pretty nor flexible, but... |
| 13:43 | chouser | still has false positives in the case you described, doesn't it? |
| 13:45 | amalloy | chouser: i don't think so. b is the sequence to test against; = is doing a strict comparison of the whole list |
| 13:45 | amalloy | ((fn [a b] (= b (take (count b) a))) [1 2] [1 2 3]) |
| 13:45 | amalloy | &((fn [a b] (= b (take (count b) a))) [1 2] [1 2 3]) |
| 13:45 | sexpbot | ⟹ false |
| 13:46 | amalloy | &((fn [a b] (= b (take (count b) a))) [1 2 3] [1 2]) |
| 13:46 | sexpbot | ⟹ true |
| 13:46 | chouser | oh, right. very good |
| 14:42 | gfrlog | anybody had any trouble with clojureql recently? |
| 14:42 | LauJensen | gfrlog: no trouble, why ? |
| 14:43 | gfrlog | my project won't compile all of a sudden, and I haven't been mucking with my clojureql code |
| 14:43 | gfrlog | it gets a classNotFound clojureql.core.Relation |
| 14:43 | LauJensen | You're using lein? |
| 14:43 | gfrlog | yeah |
| 14:43 | gfrlog | I've also seen it complain that where* is unbound |
| 14:43 | gfrlog | it actually does complete "lein uberjar" successfully |
| 14:43 | LauJensen | lein doesn't handle protocols well. technomancy has an updated prepared. Try cake in the meantime |
| 14:44 | gfrlog | but on executing the jar, or running "lein repl" I see the error |
| 14:44 | gfrlog | okay |
| 14:44 | gfrlog | are protocols in clojureql new? |
| 14:44 | LauJensen | gfrlog: Been there since day 1 |
| 14:44 | gfrlog | hmm |
| 14:44 | gfrlog | strange that this popped up now then |
| 14:44 | gfrlog | oh well |
| 14:44 | LauJensen | technomancy: Got an ETA on that release yet? This comes off a little too often :( |
| 14:44 | technomancy | gfrlog: the latest lein should fix this; you can set :clean-non-project-classes false in project.clj in the mean time |
| 14:44 | gfrlog | thank you |
| 14:44 | technomancy | I pushed out the fix a few days ago |
| 14:44 | LauJensen | gfrlog: could you try that please and let me know? |
| 14:45 | gfrlog | I will do that right now |
| 14:45 | LauJensen | technomancy: great- you keep an impressive pace :) |
| 14:45 | gfrlog | technomancy: thanks |
| 14:45 | gfrlog | LauJensen: I will try his clean-non-project-classes arg first |
| 14:45 | LauJensen | sure, let us know how it goes |
| 14:45 | technomancy | if you have any trouble on 1.4.2 with AOT and protocols plz to report on https://github.com/technomancy/leiningen/issues/issue/141 |
| 14:46 | danlarkin | Anyone have any luck using native-deps-1.0.5, lein-1.4 and lein-swank-1.2.1? lein-swank throws an exception when I try and start it when I have native deps installed |
| 14:46 | technomancy | I believe it's fixed, but I don't use protocols or AOT myself, so I haven't verified it on the field. |
| 14:46 | technomancy | danlarkin: you're not using the "lein-swank" dependency itself, right? |
| 14:46 | technomancy | I mean, it should be swank-clojure |
| 14:47 | danlarkin | technomancy: yeah, sorry, swank-clojure-1.2.1 |
| 14:48 | technomancy | danlarkin: there was a thread about it few weeks ago on the lein mailing list you could check |
| 14:49 | gfrlog | LauJenson: after changing the project.clj, I immediatly still got the classNotFound exception; after switching to beta-2 I now get the where* is unbound errer again |
| 14:49 | danlarkin | I see the one re: lein-1.4, but not one involving swank |
| 14:49 | ossareh | is it weird to (let [some-ref (ref nil) _ (while (is-nil ref) populate-ref-fn)] @some-ref) ? I need a loop that continues until it passes and want to return the value. previously i've used loop/recur for this. |
| 14:50 | gfrlog | LauJenson: I'll try the new version of lein |
| 14:51 | gfrlog | technomancy: could you remind me what the native readline package that lein uses for "lein repl" is? You told me once and I've had no luck googling for that conversation |
| 14:51 | LauJensen | gfrlog: Im not called Jenson :) |
| 14:51 | technomancy | gfrlog: that's rlwrap |
| 14:51 | gfrlog | technomancy: thanks! |
| 14:51 | chouser | ossareh: yeah, that's probably not right, unless you're actually doing multithreaded work. |
| 14:51 | gfrlog | LauJensen: By squinting at the bright yellow font my client uses for names, I can tell you're correct; pardon me |
| 14:52 | ossareh | chouser: no threads involved - at this point. definitely feels weird - I guess I want a let-while or something |
| 14:52 | chouser | ossareh: loop/recur would be better, or perhaps take-while |
| 14:52 | LauJensen | gfrlog: No worries. I find it amusing that so many americans spell my name like they would say it |
| 14:53 | ossareh | chouser: or when-let ? |
| 14:53 | gfrlog | LauJensen: yeah; my pronunciation for Jensen is about the same as Jenson |
| 14:53 | ossareh | chouser: actually, no. I'll stick with loop/recur. Cheers. |
| 14:53 | chouser | sure, when-let, but you'd still need to loop |
| 14:54 | gfrlog | leiningen is the top google hit for its name; so much for that story about ants |
| 14:55 | LauJensen | The story is epic |
| 14:59 | micahmartin | Is there a way to define a function "get" such that I don't get this warning? "WARNING: get already refers to: #'clojure.core/get" |
| 15:00 | gfrlog | I think cake will probably have a harder time achieving the same google-status |
| 15:00 | cemerick | micahmartin: add a :refer-clojure slot to your ns form |
| 15:01 | cemerick | micahmartin: see: http://clojure.github.com/clojure/clojure.core-api.html#clojure.core/ns |
| 15:02 | micahmartin | cemerick: that worked like a charm... Thanks! |
| 15:03 | gfrlog | I'm looking at the readme page for cake, and it talks about installing a gem and yet doesn't mention ruby anywhere. Is that a little weird? |
| 15:06 | danlarkin | technomancy: found it -- you fixed it in leiningen master 78384ba6 |
| 15:06 | LauJensen | gfrlog: Which distro are you on? |
| 15:08 | gfrlog | ubuntu 10.04 |
| 15:08 | gfrlog | test |
| 15:09 | gfrlog | LauJensen: I think I am doing okay now |
| 15:09 | LauJensen | gfrlog: Okay. Otherwise just install ruby/gems, then sudo gems install cake. Its quite simple |
| 15:09 | gfrlog | LauJenses: Updating lein seems to have worked |
| 15:10 | LauJensen | Ehm. Its not Jenses either :) You could try ERC, it has name completion :) |
| 15:11 | bobo_ | dont think gems install cake works in ubuntu |
| 15:11 | technomancy | yeah, gem is pretty screwed up on ubuntu |
| 15:11 | bobo_ | depends on how you installed the gem thingy |
| 15:11 | LauJensen | really? I think I recall seeing it working. Also works on Windows |
| 15:12 | bobo_ | i think the apt-get installed gem stuff did something weird. didnt work for me, and i saw more people complaining |
| 15:12 | technomancy | it breaks self-update and puts bin wrappers in inaccessible places |
| 15:13 | LauJensen | ninjudd: Can you submit patch for ubuntu please? the linux noobs are hurting |
| 15:13 | technomancy | I've bugged them about it. they are not interested. =( |
| 15:13 | technomancy | apparently working gems are not FHS-compliant or something. |
| 15:14 | LauJensen | technomancy: 'they' ? |
| 15:14 | technomancy | LauJensen: the debian ruby team |
| 15:14 | LauJensen | oh ok |
| 15:14 | technomancy | so now everyone just says "whatever you do, don't use apt-get for ruby" which just pisses them off more. |
| 15:15 | bobo_ | yeh its not just cake that doesnt work |
| 15:15 | bobo_ | its ehm, everything :-p |
| 15:15 | LauJensen | Well. I guess Ubuntu in itself is a temporary OS that you use before moving on to more manly distros, so its okay I guess |
| 15:17 | rak85 | is there any way to write (not (= 1 2)) ? |
| 15:17 | chouser | (not= 1 2) |
| 15:17 | rak85 | something like (!= 1 2) |
| 15:17 | rak85 | chouser: thanks |
| 15:20 | rak85 | how can I check if a string has some substring? something like (contains? "asdf" "sd") |
| 15:21 | rak85 | i have found |
| 15:22 | chouser | ,(<= 0 (.indexOf "asdf" "sd")) |
| 15:22 | clojurebot | true |
| 15:22 | rak85 | (.contains "asdf" "sdf") |
| 15:22 | chouser | ah, nice! |
| 15:22 | rak85 | chouser: thanks for your solution! |
| 15:22 | chouser | note also (re-find #"sd" "asdf") |
| 15:31 | qbg | Adding lexical scope to my syntax-rules lib was nasty |
| 15:35 | cemerick | qbg: glad to see you get such a positive response on the ML |
| 15:36 | cemerick | qbg: I might suggest that you mail the clojure-dev list and offer up syntax-rules as a contrib library, if you are so willing. |
| 15:37 | qbg | cemerick: dnolan suggested that I while ago |
| 15:37 | qbg | I mailed in my CA a week ago |
| 15:37 | qbg | Haven't heard anything though |
| 15:38 | amalloy | ossareh: (loop [v nil] (or v (recur (try-again v))))? |
| 15:39 | amalloy | or (drop-while (complement acceptable?) (iterate try-again initial-val)) |
| 15:39 | cemerick | qbg: I don't think there's a notification system; you just get added to a list :-) |
| 15:40 | qbg | I don't see my name on http://clojure.org/contributing yet |
| 15:42 | cemerick | qbg: In any case, starting that thread now wouldn't hurt anything, assuming it's something you're open to. |
| 15:42 | qbg | Just applied for the clojure dev group |
| 15:57 | auser | I definitely have a very esoteric question... I'll see if I can functionally address it... I have an object that I'm creating and serializing, but on deserialization, I get an error 'clojure.core$bytes cannot be cast to [B' I've pasted the functional code here: http://paste.lisp.org/display/118246 |
| 15:57 | auser | any help would be awesoe |
| 15:57 | qbg | sounds like you are trying to use a function as an array |
| 15:58 | amalloy | auser: qpg took the words out of my mouth |
| 15:58 | ohpauleez | yeah |
| 15:58 | qbg | (with-open [bais (java.io.ByteArrayInputStream. bytes) |
| 15:58 | qbg | That line |
| 15:58 | auser | interesting... |
| 15:58 | qbg | Maybe you meant object? |
| 15:58 | auser | I'd like to convert it to an object |
| 15:58 | auser | yeah |
| 15:59 | amalloy | auser: you'll have to try harder to come up with an esoteric question :) |
| 15:59 | qbg | Also, what is up with the docstring style? |
| 15:59 | auser | damn, I thought I had a better shot at the esoteric question |
| 16:00 | auser | what do you mean qbg, just a string? |
| 16:00 | qbg | (defn- foo "docstring" [...] ...) works also |
| 16:01 | auser | yeah, i kinda like that :doc in there |
| 16:01 | auser | but I can change that |
| 16:01 | qbg | Not very idiomatic |
| 16:01 | auser | fair enough |
| 16:02 | paudo | hi |
| 16:07 | abedra | cemerick: pushed your membership through on clojure-dev |
| 16:09 | cemerick | abedra: Thanks; tinkering with the thought of gmail-only for clojure communications. :-) |
| 16:18 | auser | hm... can you cast a class or an instance of the class to a java.io.ObjectOutputStream? more investigation is necessary it seems |
| 16:20 | qbg | You shouldn't need to do casting |
| 16:21 | qbg | (eval (.read (read-string ois))) looks wrong |
| 16:22 | qbg | You want to be calling .readObject on ois |
| 16:24 | qbg | deserialize should probably take a string s, bytes should be (.getBytes s), and (eval (.read ...)) should probably be (.readObject ois) |
| 16:25 | qbg | And (str (.toByteArray ...)) in serialize should probably be (String. (.toByteArray ...)) |
| 16:33 | auser | nm, I think I got it |
| 16:33 | auser | yep qbg that did it |
| 16:35 | auser | you rock, thanks qbg |
| 16:47 | abedra | cemerick: that's what I do |
| 16:47 | cemerick | abedra: it'll either be that or I'll bite the bullet and start running mail through cemerick.com |
| 16:48 | cemerick | though I don't know if I have the chutzpah to match up with me@ the way fogus does ;-) |
| 16:48 | TobiasRaeder | hey :0 |
| 16:49 | TobiasRaeder | Anyone using cake and not having an inferior-lisp buffer in emacs aswell? Got a little problem with that |
| 16:49 | abedra | cemerick: NO don't go there |
| 16:50 | abedra | cemerick: Spend your time somewhere useful |
| 16:50 | abedra | cemerick: trust me |
| 16:50 | cemerick | abedra: oh, I wouldn't run a mail server myself! |
| 16:50 | abedra | cemerick: the day google offered apps for personal domains is the day I shut it all off |
| 16:50 | cemerick | abedra: or do you object to vanity domains in general? |
| 16:51 | abedra | cemerick: I don't |
| 16:51 | abedra | cemerick: I have aaronbedra.com |
| 16:51 | cemerick | I'd probably use rackspace mail for it if I were to go that way. |
| 16:51 | abedra | cemerick: I have just always used my gmail account for lists because it was my first google identity |
| 16:51 | cemerick | Their web interface is *horrible*, but they've not gone down once and I'm grandfathered into a pretty sweet pricing scheme from the webmail.us days. |
| 16:52 | abedra | cemerick: running google apps for your domain is FREE |
| 16:52 | abedra | cemerick: except for the whole google owns your data thing |
| 16:53 | cemerick | I got an android phone a few months ago. I think I'm screwed in that department at this point. :-( |
| 18:46 | ninjudd | TobiasRaeder: i personally don't use cake inside an inferior-lisp buffer, but you may want to ask in the #cake.clj channel |
| 18:47 | AWizzArd | OT but interesting: http://www.kurzweilai.net/womens-study-finds-longevity-means-getting-just-enough-sleep |
| 18:49 | Somelauw | Is there a != operator? |
| 18:49 | AWizzArd | yes: not= |
| 18:49 | ninjudd | bobo_: what issue were you having with 'gem install cake' on Ubuntu? i just tried on karmic and it worked fine. was the issue on lucid? |
| 18:49 | AWizzArd | ,(not= 10 20) |
| 18:49 | clojurebot | true |
| 18:51 | Somelauw | Okay, it was hard to find that function. But thanks. |
| 18:51 | raek | there's also if-not and when-not, that might be more compact sometimes |
| 18:53 | companion_cube | what is the best clojure book for a functional programmer accustomed to static typing ? |
| 19:08 | pdk | you just might want to pick up any ol general lisp book if the typing system is your issue |
| 19:12 | companion_cube | thanks, but in fact i'm more looking for a quite exhaustive book which would preferably expect the reader to know functional programming (typing is not a big issue) |
| 19:13 | pdk | i'm not sure if there are any clojure books yet that assume advanced knowledge of functional coding coming in |
| 19:14 | pdk | practical clojure and programming clojure at least introduce the concept at the beginning so |
| 19:14 | pdk | if you branch out you could read graham's on lisp i guess |
| 19:14 | companion_cube | ok, thanks |
| 19:14 | pdk | also take note that clojure's typing system is also strong |
| 19:16 | pdk | it's also probably best to have some advance knowledge of java and the java api as well though not everything you do will need it |
| 19:16 | pdk | and clojure borrows cl's system of letting you put optional type hints on things like function arguments |
| 19:17 | raek | ,((fn [^String x] x) 1) |
| 19:17 | clojurebot | 1 |
| 19:17 | raek | type hints don't prevent you from passing a value of a different type |
| 19:18 | raek | they are for helping the compiler to pick the right method when doing java interop |
| 19:19 | pdk | yeah there are some wrinkles in the picture bridging between java's static world and clojure's ideally dynamic world |
| 19:44 | devn | hey all |
| 19:45 | joshua__ | hi |
| 19:45 | devn | am i missing something or should i not be using clojars for ring releases? |
| 19:57 | joshua__ | devn, I don't know what other people are doing but I use [ring/ring-jetty-adapter "0.3.1"] as that was what was mentioned in the compojure guide that I used. Hopefully someone else can answer your question more fully. |
| 20:33 | Derander_ | LauJensen: https://github.com/LauJensen/clojureql I'm trying to follow this pseudo-intro and query a users table. I'm getting an "unable to find Driver for ..." error though. |
| 20:33 | Derander_ | Do I need to install the mysql driver for jdbc? |
| 20:36 | Derander_ | No suitable driver found for jdbc:mysql://127.0.0.1:3307/database_name (using correct db name) |
| 20:47 | amalloy | Derander_: yes. but it's available in maven, so you can just add it as a dep in project.clj |
| 20:47 | Derander_ | amalloy: alright |
| 20:48 | amalloy | Derander_: http://mvnrepository.com/artifact/mysql/mysql-connector-java/5.1.6 |
| 21:49 | zakwilson | http://functionaljobs.com/ <-- the front page here suggests Akamai is or will be using Clojure. Anyone know if there's truth to that? |
| 21:51 | amalloy | &(into-array [nil]) |
| 21:51 | sexpbot | java.lang.NullPointerException |
| 21:51 | amalloy | is this desired behavior? |
| 22:00 | drewr | zakwilson: they sponsored, and were recruiting at, the conj, so I would say yes |
| 22:01 | danlarkin | zakwilson: I know it to be true |