2011-08-06
| 00:02 | jcromartie | technomancy: thanks! |
| 00:03 | technomancy | next version you'll be able to just to M-x clojure-jack-in, but there's a bug right now that means sometimes it'll mess up if you don't kill *swank* first |
| 00:42 | fmw | I guess this wasn't a good time to ask a question |
| 00:42 | fmw | I'll try again later :) |
| 00:45 | jcromartie | fmw: sup? |
| 00:47 | fmw | jcromartie: "<fmw> are there problems with doseq in clojurescript? I'm suppose I'm just |
| 00:47 | fmw | using it incorrectly: https://gist.github.com/1128963 ? I'm getting |
| 00:47 | fmw | notified that something in core.js is undefined (see the provided paste)" |
| 00:48 | fmw | I tried applying the patch in CLJS-39 that fixes an issue with doseq scoping, but no luck |
| 00:49 | jcromartie | sorry :( no idea... kind of strange that it says "<big long string of code> is undefined" |
| 00:50 | fmw | jcromartie: yes, basically it is doing (function() [...]).call() |
| 00:50 | jcromartie | but the compiler must be doing something strange to yield that undefined message |
| 00:50 | fmw | but it says the thing its doing .call on is undefined |
| 00:52 | fmw | https://gist.github.com/1129025 there is the javascript function that is undefined (starting at line 11) |
| 00:53 | fmw | according to firebug that whole function is undefined |
| 00:53 | jcromartie | ah |
| 00:54 | jcromartie | basically: (function () {})().call(null,o); |
| 00:56 | fmw | jcromartie: indeed |
| 00:56 | fmw | I'm going to try and find the relevant cljs code now |
| 00:57 | fmw | and see if I can do (let-fn [fn [...]] (my-fn o)) or something to that extend |
| 00:57 | fmw | so it gets compiled differently |
| 01:01 | amalloy | fmw: letfn isn't implemented yet |
| 01:01 | amalloy | (or ever? i think it will be eventually but i don't know) |
| 01:04 | fmw | amalloy: ah, thanks |
| 01:05 | fmw | amalloy: anyway, I will just (let [my-fn (fn [] ...)] ...) in that case |
| 01:06 | fmw | I can't really find where to do that for cljs.core, though (see https://gist.github.com/1129025 for the function I'm trying to let-fn on line 11) |
| 01:09 | fmw | https://github.com/clojure/clojurescript/blob/master/src/cljs/cljs/core.cljs#L126 seems to be how that JavaScript output I pasted is generated, but I can't figure out where to change it |
| 01:09 | fmw | the implementation, that is, to work around the undefined bug |
| 01:12 | amalloy | fmw: the line you linked to doesn't even have any code. it's just a protocol definition |
| 01:12 | amalloy | the generated code was from the (or) macro |
| 01:13 | amalloy | &(macroexpand '(or x y)) |
| 01:15 | fmw | amalloy: I wonder where that is called, though. |
| 01:15 | fmw | amalloy: it seems to figure out the type of protocol and call the seq implementantation for it |
| 01:17 | fmw | amalloy: so maybe I'm looking in the wrong file and I should check where defprotocol is implemented, to find that (or) macro |
| 01:18 | fmw | amalloy: ah, https://github.com/clojure/clojurescript/blob/master/src/clj/cljs/core.clj#L113 I think that the or macro is there |
| 01:22 | fmw | yes, its that method I linked that produces the function that is undefined according to both chrome and firefox (https://gist.github.com/1129025) |
| 01:23 | fmw | s/method/defprotocol implementation |
| 01:23 | lazybot | <fmw> yes, its that defprotocol implementation I linked that produces the function that is undefined according to both chrome and firefox (https://gist.github.com/1129025) |
| 02:27 | jcromartie | is there a good way to do something with a timeout? |
| 02:27 | jcromartie | like, don't let a function run more than some amount of time? |
| 02:28 | tomoj | you don't happen to need async i/o or event driven stuff, do you? :) |
| 02:28 | tomoj | lamina has very cool timeouts but wouldn't be worth including just for that |
| 02:33 | jcromartie | no |
| 02:34 | jcromartie | although what would be even better would be a time-bound lazy sequnce |
| 05:34 | zoldar | hello, I'm trying to use ztellman's gloss library for serializing/deserializing data. My attempt mostly follows the basic header usage example given on the wiki page but encoding attempt fails: http://paste.lisp.org/display/123831 . What am I missing? |
| 05:44 | fantazo | hi, how do you actually import in clojure all classes of a package? like in java java.awt.*? |
| 05:47 | zoldar | fantazo, afaik there's no way to do this |
| 05:47 | fantazo | ok, thank you |
| 06:19 | fantazo | hmm. in scheme you normally do the simple counter example with (define (make-counter) (let ((x 0)) (lambda () (set! x (+ x 1)) x))) as clojure works with non-mutable structures in default, how do you something trivial like that? I know, this is actually not functional style. |
| 06:25 | zoldar | fantazo: (let [entity-counter (atom 0)] (defn gen-entity-id [] (swap! entity-counter inc)) |
| 06:29 | fantazo | is ok, but doesn't yet do what the scheme version does. |
| 06:33 | fantazo | but this version does what I want: (defn make-counter [] (let [x (atom 0)] (fn [] (swap! x inc)))) |
| 06:36 | zoldar | fantazo, yup, sorry, mindless copy-paste from my old code |
| 06:37 | fantazo | clojure is interesting, it helps to get over the non-functional coding habits. |
| 06:37 | fantazo | or atleast seeing them as that. |
| 06:37 | zoldar | added benefit: clojure version of that counter if thread-safe |
| 06:41 | fantazo | with clojure java is finally useable. |
| 09:29 | pyr | when i define symbols in macros |
| 09:29 | pyr | with the symbol# idiom |
| 09:29 | pyr | they only live within the context of the expanded code, i can do no manipulation on them, right ? |
| 09:31 | pyr | for instance if one of these holds a vector, I can't do (fn argvector# ~@body) |
| 09:35 | raek | pyr: a macro is basically function that returns code in the form of clojure data structures |
| 09:35 | raek | a symbol is just a variable name |
| 09:35 | clojurebot | c'est bon! |
| 09:36 | raek | when the returned code is compiled, there might be a variable with that name, and only when that code is actually executed it hols a value |
| 09:36 | thorwil | pyr: in other words, you can do "manipulations" on them |
| 09:40 | Vinzent | but (fn argvector# ~@body) won't work anyway |
| 09:43 | pyr | Vinzent: yep |
| 09:43 | pyr | got it |
| 09:43 | thorwil | Vinzent: because of the @, or is there an additional problem? |
| 09:43 | pyr | thorwil: because (fn somevec (do-something)) doesn't work |
| 09:44 | pyr | thorwil: and because there's no way to replace argvector# with it's value |
| 09:44 | Vinzent | yep |
| 09:44 | pyr | alright then, no worries |
| 09:45 | malkomalko | is there a more idiomatic way to add up the values in deeply nested maps then reduce combined with assoc/merge? |
| 09:45 | raek | pyr: yes, it doesn't have a value at that point. but your macro can emit code that does the operation on the value |
| 09:45 | paul__ | hey |
| 09:47 | paul__ | (clojure.contrib.str-utils/re-split #"\s+" "sdf sdf sdf") |
| 09:47 | paul__ | i get an error with the above code :( |
| 09:48 | paul__ | my swank auto completion can't find contrib.str-utils |
| 09:48 | raek | paul__: first, there is clojure.string since clojure 1.2 |
| 09:48 | Vinzent | and re-split is in core |
| 09:48 | raek | paul__: have you required the namespace? |
| 09:48 | raek | it isn't loaded until you have require'd or use'd it |
| 09:48 | paul__ | i thought that i didn't need to do that when i write out the whole path |
| 09:50 | dnolen | paul__: the library needs to be loaded first, it's not loaded by default, and that won't automatically load it. |
| 09:50 | dnolen | ,(require '[clojure.string :as string]) |
| 09:50 | clojurebot | nil |
| 09:50 | dnolen | ,(string/split "sdf sdf sdf" #"\s+") |
| 09:50 | clojurebot | ["sdf" "sdf" "sdf"] |
| 09:52 | paul__ | thanks |
| 09:52 | paul__ | i wanted re-split because it has reverse args |
| 09:55 | dnolen | ,(let [flip (fn [f] (fn [& args] (apply f (reverse args))))] ((flip string/split) #"\s+" "sdf sdf sdf")) |
| 09:55 | clojurebot | ["sdf" "sdf" "sdf"] |
| 09:56 | raek | skynda |
| 09:57 | raek | eh, wrong channel |
| 09:57 | paul__ | cool |
| 10:36 | ejackson | hmm... Google Closure doesn't seem to have a datagrid widget. |
| 10:37 | ejackson | an emoji picker, yes.... datagrid, sorry. |
| 10:49 | abedra | technomancy, does @hiredman's RT.load fix solve your issues? |
| 10:49 | abedra | I am reviewing the patch right now |
| 10:50 | abedra | I'm trying to collect patches and get them checked in so we can cut a beta2 soon |
| 10:51 | abedra | everything looks reasonable in the patch, but I just wanted to make sure it resolves the issue you were having |
| 11:14 | triyo | Is there a filter-like function that can actually return two sequences, the difference based on predicate? |
| 11:18 | thorwil | triyo: you mean one list with matches and one with non-matches? |
| 11:18 | triyo | oops, I mean a vector with two elements. [pass-pred-test-seq, fail-pred-test-seq] |
| 11:19 | triyo | thorwil: I see there is something simple in clojure.contrib called seperate |
| 11:20 | triyo | source -> [ (filter f s), (filter (complement f) s) ] |
| 11:23 | thorwil | sure, though the whole filtering work is done twice |
| 11:23 | triyo | Hmm, thats quadratic time right? |
| 11:23 | triyo | hehe |
| 11:23 | triyo | ;) |
| 11:23 | triyo | n^3 |
| 11:23 | triyo | oops |
| 11:23 | triyo | I mean n^2 |
| 11:24 | triyo | O(n^2) |
| 11:24 | thorwil | if you can make sense of (source filter), you could do a trivial modification to get your result, i guess |
| 11:25 | triyo | yup, I'll come back to efficiency question after I finish the implementation. |
| 11:25 | triyo | that seems the most logical to me. |
| 11:26 | triyo | Question is also what size of seq I'll be dealing with |
| 11:26 | thorwil | yes, premature optimization and all that ... |
| 11:31 | abedra | triyo, remember that contrib is deprecated |
| 11:32 | abedra | and won't be supported on 1.3 |
| 11:32 | abedra | this isn't a big deal in your case since the function you are working on is pretty simple. |
| 11:32 | abedra | but it is worth remembering |
| 11:33 | triyo | abedra: yup, I know, thanks for the reminder. I did a search on clojuredocs.org and came across the implementation. I just wanted to look at the source. |
| 11:33 | abedra | triyo, ok good deal |
| 11:33 | triyo | "he function you are working on is pretty simple." -> exctlly |
| 11:44 | malkomalko | maybe I'm missing something, what's the best way to test if something is a number? |
| 11:45 | Vinzent | ,number? |
| 11:45 | clojurebot | #<core$number_QMARK_ clojure.core$number_QMARK_@70cf21> |
| 11:45 | Vinzent | ,(number? 5) |
| 11:45 | clojurebot | true |
| 11:47 | malkomalko | ahh, that's not on the api cheatsheet |
| 11:50 | Vinzent | hm, indeed (and here http://clojuredocs.org/quickref/clojure%20core too) |
| 11:56 | abedra | malkomalko, The best way to learn is to crack open core.clj |
| 11:56 | abedra | put a marker in the code and take a look at one or two functions a day and try them out |
| 11:57 | malkomalko | makes sense |
| 11:57 | abedra | pretty soon you will have a great understanding of the language |
| 11:57 | malkomalko | the most difficult part of clojure is realizing how much is already there for you |
| 11:57 | abedra | it |
| 11:57 | abedra | yes |
| 11:57 | malkomalko | and trying to re-implement things that already exist |
| 11:57 | abedra | yes |
| 11:57 | abedra | that is why I encourage people to look inside |
| 11:57 | abedra | the language is evolving |
| 11:57 | abedra | cheat sheets really won't cut it |
| 11:58 | malkomalko | take for example http://clojure.github.com/clojure-contrib/map-utils-api.html deep-merge-with |
| 11:58 | abedra | the source is really easy to examine |
| 11:58 | malkomalko | love that function, just found it, exactly what I needed |
| 11:58 | abedra | malkomalko, but that is clojure-contrib |
| 11:58 | abedra | not clojure |
| 11:58 | malkomalko | I know |
| 11:58 | abedra | and contrib is being deprecated |
| 11:58 | malkomalko | in 1.3? |
| 11:58 | clojurebot | I don't understand. |
| 11:58 | abedra | yes |
| 11:59 | abedra | in 1.3 |
| 11:59 | malkomalko | what are they planning to do with those libraries? require things in as needed instead of having a clojure.contrib? |
| 12:00 | abedra | github.com/clojure |
| 12:00 | abedra | libraries from inside of contrib have been pulled in as their own projects |
| 12:00 | chouser | and/or will be |
| 12:00 | chouser | <-- culprit |
| 12:01 | malkomalko | is the plan to have all ported over? or are some going to not make the cut? |
| 12:01 | abedra | malkomalko, a lot of libraries went unmaintained |
| 12:01 | abedra | no some will not make it |
| 12:01 | malkomalko | that's understandable |
| 12:01 | abedra | those that have gone stale |
| 12:01 | abedra | malkomalko, here's the current plan http://dev.clojure.org/display/design/Contrib+Library+Names |
| 12:01 | malkomalko | well chouser wrote map-utils so I hope deep-merge-with makes it in :) |
| 12:02 | abedra | malkomalko, that's up to @chouser :) |
| 12:02 | malkomalko | that's very helpful |
| 12:02 | chouser | I wrote map utils? |
| 12:02 | malkomalko | well, either your name is on it |
| 12:03 | abedra | malkomalko, the idea is that any library from contrib can get it's own project as long as there is a maintainer |
| 12:03 | abedra | it does not have to be the original author |
| 12:03 | abedra | it does, however, fall under the same CA policies as Clojure |
| 12:03 | malkomalko | alright |
| 12:03 | malkomalko | is there a good post detailing the gameplan for 1.2 -> 1.3? |
| 12:03 | abedra | the link i just posted |
| 12:03 | abedra | it gives the current strategy |
| 12:03 | chouser | malkomalko: quite possible I did and have forgotten. :-P |
| 12:04 | abedra | for contrib |
| 12:04 | malkomalko | not for contrib libs |
| 12:04 | malkomalko | for core |
| 12:04 | abedra | there has been lots of mailing list posts |
| 12:04 | malkomalko | yah yah, no worries :P |
| 12:04 | malkomalko | ok, I'll check the google group |
| 12:04 | abedra | quite a bit has changed |
| 12:04 | abedra | and there's a beta1 that you can grab |
| 12:04 | abedra | or if you want to just run off of master |
| 12:05 | abedra | http://dev.clojure.org/display/doc/Maven+Settings+and+Repositories |
| 12:05 | abedra | if you add the sonatype repository to your project.clj file or pom.xml you can pull in 1.3.0-master-SNAPSHOT |
| 12:05 | abedra | which should become beta2 soon |
| 12:06 | abedra | just a few more patches to get in |
| 12:06 | malkomalko | very helpful.. I'll go look around to figure out the bigger changes |
| 12:06 | abedra | cool |
| 12:07 | abedra | numerics, defrecord, :dynamic, bindings, all kinds of things have been modified |
| 12:07 | malkomalko | and very good idea to just read core.clj |
| 12:08 | abedra | yes |
| 12:08 | abedra | chouser, I just put up a patch to make BigInt math much faster for long sized values inside of BigInts |
| 12:08 | chouser | cool |
| 12:10 | malkomalko | also, the joy of clojure rocks |
| 12:10 | malkomalko | so, thanks for that :) |
| 12:11 | abedra | yes, that book is awesome |
| 12:13 | malkomalko | reading the tests seem very handy too, no brainer way to pick things up |
| 12:14 | chouser | ah, sure! glad you like it. |
| 12:15 | abedra | chouser, I hope you guys get the Jolt! |
| 12:17 | ejackson | does anybody know how to determine which events a Closure Library widget supports ? |
| 12:21 | chouser | huh, Jolt? Hm. |
| 12:21 | jsoftw | . |
| 12:22 | lucian | ejackson: don't the closure docs say such things |
| 12:22 | lucian | ? |
| 12:22 | ejackson | lucian: to which docs do you refer ? |
| 12:23 | lucian | ejackson: it has no docs |
| 12:23 | lucian | ? |
| 12:23 | lucian | bah |
| 12:23 | ejackson | it does |
| 12:23 | ejackson | for instance: http://closure-library.googlecode.com/svn/docs/class_goog_ui_BidiInput.html |
| 12:23 | ejackson | thought you might have others |
| 12:24 | ejackson | but these don't give me the events it can produce |
| 12:24 | lucian | hmm |
| 12:25 | lucian | i don't know of a way to introspect event listeners in js |
| 12:25 | lucian | uh, rather which events one can listen to |
| 12:38 | momox | how do i read (filter (fn [x] (every? #(% x) filters)) coll) ? I am particularly confused on the #(% x) portion... |
| 12:42 | ejackson | it depends on what filters contains |
| 12:43 | momox | ejackson: it contains a sequence of functions |
| 12:43 | momox | filters [#(> % 1) #(< % 5)]] |
| 12:43 | ejackson | ok |
| 12:44 | ejackson | in that case it filters coll, returning a seq for which applying every predicate in filters to the elements is true |
| 12:45 | ejackson | the (every? ...) bit runs each function in filters against x, and return true if each function application returns true |
| 12:45 | ejackson | the outer filter will return only those x |
| 12:46 | ejackson | in coll for which that inner operation is true |
| 12:47 | momox | but i don't know what #(% x) expands into...i know x will be the element in coll but what is %? |
| 12:48 | ejackson | oh, % will be each function in filters in turn |
| 12:48 | ejackson | you see, x gets bound to an element of coll |
| 12:48 | ejackson | then every? runs the #(% x) function for each element of filters, and in each case % is bound to one of those functions |
| 12:49 | ejackson | the problem you might have is that you've got % meaning two things, apparently :) |
| 12:50 | ejackson | as far as every? is concerned its a function, but that function is itself written in terms of #(> % 1), so in the inner case the % will be bound to the argument THAT function was passed, being x. |
| 12:50 | ejackson | foncusing indeed |
| 12:52 | ejackson | gotta hop, cheers all. |
| 13:33 | pyr | is there a way to update a var |
| 13:33 | pyr | as in, change it's meta data for instance |
| 13:34 | Vinzent | alter-var-root to update value, and something similar for meta :) |
| 13:35 | pyr | alter-var-root! |
| 13:35 | pyr | thanks |
| 13:50 | arohner | pyr: there's also vary-meta for metadata specifically |
| 14:00 | pyr | ok, alter-meta! was the one i was looking for |
| 14:00 | pyr | ultimately |
| 14:09 | crazyFox | Hi. Ive got a question about (lazy) seqs. Anybody there to answerß |
| 14:14 | Vinzent | crazyFox, don't ask to ask, just ask :) |
| 14:14 | crazyFox | alright. coming up... |
| 14:17 | crazyFox | im trying to do (take 10 (cons 2 primes)) in the repl. wheres primes is an infinite lazy seq. The thing is: the expression doesnt evaluate. No result shows up. No new prompt shows up. What am i doing wrongß |
| 14:19 | Vinzent | ,(take 10 (cons 2 (range))) |
| 14:19 | clojurebot | (2 0 1 2 3 ...) |
| 14:19 | Vinzent | crazyFox, probably the problem is in definition of primes |
| 14:20 | crazyFox | its the one from clojure.contrib.lazy-seqs. actually i just tried again. it worked... |
| 14:21 | crazyFox | omg. it was a paren mistake. bugged me yesterday already. i just realize now. ok all is fine. dont be bothered. |
| 14:24 | Vinzent | crazyFox, :) you should consider using paredit |
| 14:25 | crazyFox | i know. still have to set up emacs or some other decent editor with built-in repl. |
| 14:32 | zvrba | Vinzent: i looked at paredit and it introduced a bunch of hard to remember keyboard shortcuts :( |
| 14:35 | Vinzent | zvrba, I use only 5: C-M-i,k for killing sexps, C-M-j,l for navigating and C-M-u for going up level |
| 14:36 | Vinzent | (M-j,l,i,k for moving cursor) |
| 14:36 | Vinzent | very handy |
| 14:50 | leeda | Is this the best way to write this: (last (take-while #(>= x %) cutoffs)) ? (cutoffs is a vector of integers in strictly increasing order) |
| 14:54 | leeda | actually what I want is: (- (count (take-while #(>= 15 %) cutoffs)) 1) |
| 14:54 | leeda | (the index in the vector) |
| 15:04 | crazyFox | leeda: so, u want the index of the largest number <= 15 in a vector with strictly increasing order, is that rightß |
| 15:05 | leeda | crazyFox: yeah. (15 actually would be any integer) |
| 15:09 | crazyFox | leeda: i would do (dec (take-while #(>= limit %) yourvec)). im not too firm with the clojure libraries though. still a newcomer... :) |
| 15:09 | crazyFox | leeda: i forgot the count... |
| 15:10 | leeda | crazyFox: oh yeah ok. so same thing but just use dec instead of #(- % 1), good idea |
| 15:10 | MasseR | Didn't read the entire conversation, but I just learned about 'indexed' which might be of use |
| 15:10 | crazyFox | leeda: yes |
| 15:11 | MasseR | http://clojuredocs.org/clojure_contrib/clojure.contrib.seq/indexed |
| 15:11 | MasseR | (indexed "foo") would return [1 \f 2 \o 3 \o] |
| 15:11 | leeda | hm i think that would just make it more complicted |
| 15:18 | jsnikeris | Is it idiomatic clojure to throw exceptions? |
| 15:18 | thorwil | leeda: just for fun: (reduce #(if (>= 20 %2) (inc %1) %1) 0 [1 5 9 12 15 20 34]) |
| 15:19 | leeda | thorwil: nice |
| 15:20 | jsnikeris | For example, I have a function that attempts to save a blog entry. If a similar entry already exists, I don't want to overwrite it, and I want to communicate to the caller why the entry wasn't saved. Would this be the right place to throw an exception? |
| 15:21 | Vinzent | MasseR, vtw, there is map-indexed and keep-indexed in core |
| 15:21 | Vinzent | *btw |
| 15:22 | Vinzent | jsnikeris, I think if you don't have to ineroperate, you should prefer more flexible exception system over plain java exceptions |
| 15:22 | jsnikeris | Vinzent: What would you suggest? |
| 15:23 | zvrba | jsnikeris: why not return an error code? |
| 15:23 | crazyFox | leeda: there is faster solutions though, but much harder to write |
| 15:24 | leeda | crazyFox: yeah i'm sure. |
| 15:25 | Vinzent | jsnikeris, I can't remember the name... try to search scigiraldi try+ on github. also, raek have written such lib. There is error-kit in the 1.2 contrib. |
| 15:29 | jsnikeris | Vinzent: looks like there is clojure.contrib.condition by Stephen C. Gilardi |
| 15:30 | Vinzent | jsnikeris, yeah, and also c.c.condition. (first two libs was for 1.3) |
| 15:33 | crazyFox | is clojuredocs.org linked from clojure.org? i didnt know about it up to now. its neat! better than the doc on github |
| 15:44 | mjg123 | If I have a list of functions (f1 f2 f3... ) and a list of values (v1 v2 v3...) what's a good way to create a list like ((f1 v1) (f2 v2) (f3 v3) ... ) ? |
| 15:45 | mjg123 | as in, to apply each function to its corresponding value? |
| 15:45 | crazyFox | did anybody try jswat-4.5 with clojure-1.2.1? Does it work? |
| 15:48 | MasseR | mjg123: Maybe (map #(%1 %2) funs vals) |
| 15:48 | MasseR | or (map apply .. |
| 15:50 | MasseR | (Both are untested) |
| 15:52 | mjg123 | MasseR, the first does me fine, thanks! |
| 15:53 | thorwil | ,(reduce #(if (integer? %2) [(conj (first %1) %2) (second %1)] [(first %1) (conj (second %1) %2)]) [[] []] [1 "a" 2 "b" 3 4]) |
| 15:53 | clojurebot | [[1 2 3 4] ["a" "b"]] |
| 15:53 | thorwil | too bad triyo isn't around anymore ^^ |
| 15:58 | thorwil | ,(partition 2 (interleave ["a" "b"] [1 2])) |
| 15:58 | clojurebot | (("a" 1) ("b" 2)) |
| 15:58 | thorwil | ^ mjg123 |
| 16:03 | crazyFox | ,(map #(%1 %2) '(+ - * /) (range 1 5)) |
| 16:03 | clojurebot | (nil nil nil nil) |
| 16:03 | crazyFox | why does it not give results i expect? |
| 16:04 | Vinzent | ,(map #(%1 %2) [+ - * /] (range 1 5)) |
| 16:04 | clojurebot | (1 -2 3 1/4) |
| 16:04 | crazyFox | so whats wrong with the quoted list? |
| 16:04 | Vinzent | ,(#('+ %) 1) |
| 16:04 | clojurebot | nil |
| 16:05 | Vinzent | ,('+ {'+ :ok}) |
| 16:05 | crazyFox | ok. makes sense. ty |
| 16:05 | clojurebot | :ok |
| 16:06 | Vinzent | crazyFox, so symbols acts like keywords when treated like a functions |
| 16:06 | pdk | (key map) is a common idiom for value lookup in maps |
| 16:07 | pdk | it's not a matter of the symbol being in function position, it's that it's quoted and the second argument is a map |
| 16:07 | crazyFox | yeah. knew that. its cool |
| 16:09 | lucian | ,(take 10 (iterate + 1)) |
| 16:09 | clojurebot | (1 1 1 1 1 ...) |
| 16:10 | crazyFox | ,(take 10 (iterate inc 1)) |
| 16:10 | clojurebot | (1 2 3 4 5 ...) |
| 16:11 | Vinzent | pdk, but it's quoted = it's a symbol in that case :) |
| 16:11 | crazyFox | ,(+ 1) |
| 16:11 | clojurebot | 1 |
| 16:11 | pdk | exactly |
| 16:11 | lobotomy | it would be kind of cool if (=) worked |
| 16:12 | crazyFox | ,(take 10 (iterate #(+ 1 %) 1)) |
| 16:12 | clojurebot | (1 2 3 4 5 ...) |
| 16:12 | Vinzent | also, only keywords and symbols work that way? |
| 16:12 | lucian | crazyFox: hmm |
| 16:13 | Vinzent | lobotomy, hm, should it return nil or true? |
| 16:14 | lobotomy | dunno :) |
| 16:19 | crazyFox | my Firefox just crashed. Its also a crazy fox... :) |
| 16:51 | lucashansen | hello world |
| 16:55 | lucashansen | I am just starting with Clojure. What is the best way to use it with vim? |
| 16:56 | crazyFox | did u have a look at http://dev.clojure.org/display/doc/Getting+Started+with+Vim already? |
| 16:57 | markskil1eck | lucashansen: :! emacs |
| 16:58 | markskil1eck | ;D |
| 16:58 | lucashansen | I'd seen that plugin but I wasn't sure if it was the complete experience. Whenever I look up lisp on vim, people tell me to use emacs ha ha |
| 16:59 | markskil1eck | I love Vim, so I do. But it felt as though I was fighting Vim to get some Lisp support, so I gave up. Emacs offered a better immediate experience. |
| 16:59 | markskil1eck | Slimv was... alright. |
| 17:23 | crazyFox | did anybody try clooj? (https://github.com/arthuredelstein/clooj) Is it worthwhile? |
| 17:25 | micrypt | crazyFox: Some screenshots would've been nice. |
| 17:27 | crazyFox | try this http://dev.clojure.org/display/doc/getting+started+with+Clooj |
| 17:31 | wastrel | clooj fancy |
| 17:39 | crazyFox | so u tried it? |
| 17:47 | jsnikeris | How do I access a class created with :gen-class? For example, I want to check if this class is being thrown: http://tinyurl.com/3bvsd3s. So I have (require '[clojure.contrib.condition :as cond]) and I want to write something like: (is (thrown? cond/Condition (fn-where-it-might-be-thrown))) |
| 17:48 | jsnikeris | Do I always have to write out the whole ns: clojure.contrib.condition.Condition |
| 17:55 | amalloy | jsnikeris: you can't require/as the class, because it's a class, not a function. but you can import it, just like any other class |
| 17:58 | jsnikeris | amalloy: ahh, import. I knew I was missing something. Thanks |
| 17:59 | zoldar | when using leinigen, can I point to a certain git repository as a dependency ? |
| 18:00 | arohner | zoldar: kind of. read the 'checkouts' section of the lein faq |
| 18:01 | jsnikeris | amalloy: so I added, (:import [clojure.contrib.condition.Condition]) to my ns declaration. I expected to be able to reference a bare Condition in my code, but I'm getting an Unable to resolve classname: Condition exception. Am I missing something? |
| 18:01 | amalloy | jsnikeris: you probably don't want the []s |
| 18:02 | zoldar | arohner, thanks, this will do |
| 18:03 | jsnikeris | amalloy: that did it. Thanks |
| 19:29 | zmaril | What's the function that lets me iterate over two lists at the same time element by element? Not for, but something that iterates index by index |
| 19:29 | crazyFox | interleave ? |
| 19:30 | zmaril | Not interleave. Can you use map on two collections at once? |
| 19:30 | crazyFox | ,(interleave [:a :b :c] [1 2 3]) |
| 19:30 | clojurebot | (:a 1 :b 2 :c ...) |
| 19:31 | crazyFox | yes, if the supplied function can deal with two args |
| 19:31 | zmaril | Nice! Thanks |
| 19:31 | crazyFox | ,(map str "abc" "123") |
| 19:31 | clojurebot | ("a1" "b2" "c3") |
| 19:32 | amalloy | map |
| 19:41 | Pupeno | Apparently I became the clojars most valuable programmer: https://www.masterbranch.com/developer-achievements?uid=1566 lolo |
| 19:47 | amalloy | man, the recent attempts to make "social" programmer profiles that just scrape their data from github are pretty unimpressive |
| 20:14 | pschorf | I've defined a macro which is a wrapper around defrecord, but records defined using it cannot be imported to another ns |
| 20:14 | pschorf | has anyone else seen this behavior? |
| 20:19 | amalloy | pschorf: then your macro is broken |
| 20:24 | zoldar | (apply hash-map (reduce concat (SomeRecord. a b c))) -> is there some more succint way of converting record to pure map? |
| 20:27 | amalloy | zoldar: if you want to do that, why are you using records at all? |
| 20:27 | amalloy | (that said, (into {} (SomeRecord. a b c)) is nicer) |
| 20:28 | zoldar | amalloy, I'm using gloss library for data serialization and at the same time I do some java interop - gloss works with maps but doesn't play nicely with records |
| 20:29 | veered | Sorry for the noob question, but I can't seem to get the REPL to work on osx. It runs and evals ok, but I can't use the arrow keys. They come up as "^[[C" etc. |
| 20:29 | zoldar | always forget about "into" .. |
| 20:29 | pschorf | amalloy, it turns out it was due to a - in the lib name...for the import, i had to replace it with a _ |
| 20:30 | pschorf | veered, you need to use JLine or something similar |
| 20:31 | MicahElliott | veered: I just installed leiningen: https://github.com/technomancy/leiningen |
| 20:31 | MicahElliott | and it nicely gives history editing, via realine AFAICT. |
| 20:32 | MicahElliott | So I'm even doing vi-mode editing in repl. Very nice. |
| 20:33 | MicahElliott | Which gets to my question... |
| 20:33 | MicahElliott | It's pretty annoying to kill repl with ctrl-c. |
| 20:33 | MicahElliott | I found this old thread: https://groups.google.com/d/topic/clojure/MuT4kwBFYRg/discussion |
| 20:33 | MicahElliott | But it's not addressed. Anyone know how to enable ^C without killing repl? |
| 20:37 | amalloy | veered: or rlwrap: http://stackoverflow.com/questions/5639502/one-repl-to-bind-them-all |
| 20:37 | veered | MicahElliott: Thanks that did the trick. I can now work on finishing my first Clojure tutorial! |
| 20:43 | MicahElliott | amalloy: rlwrap is awesome! thx |
| 20:55 | amalloy | MicahElliott: you don't say what you mean by "enabling C-c", but if you mean interrupting a single command while leaving the repl running, that's not possible in general. java doesn't have a portable way to handle signals like SIGINT |
| 20:57 | MicahElliott | amalloy: Yes, that's exactly what I mean. Bummer. |
| 21:56 | jimblomo | is there a way to define a global variable in lein? eg dev-mode/debug? |
| 22:06 | Nanarpuss | is anybody using clojurescript? |
| 22:10 | jimblomo | a bit |
| 22:12 | Nanarpuss | I'm having a hell of a time getting my timer callbacks to work. I'd like to have one timer update the counter on 6 divs |
| 22:13 | jimblomo | you're using goog.Time/callOnce? |
| 22:13 | jimblomo | Timer |
| 22:13 | Nanarpuss | no (. timer (start)) |
| 22:15 | Nanarpuss | it only updates the last div |
| 22:21 | jimblomo | so are you setting up a event listener? |
| 22:21 | Nanarpuss | yeah, hold on I might have something |
| 23:21 | jweiss | i'm having trouble using proxy to subclass a java class - getting 'no matching ctor found'. there are several ctors of the same arity so i assume i need a type hint. but that doesn't seem to help: http://paste.lisp.org/display/123845#1 |
| 23:22 | jweiss | tried adding ^ThreadFactory before the (reify ...) - no help |
| 23:27 | amalloy | $google javadoc threadpoolexecutor |
| 23:27 | lazybot | [ThreadPoolExecutor (Java 2 Platform SE 5.0)] http://download.oracle.com/javase/1,5.0/docs/api/java/util/concurrent/ThreadPoolExecutor.html |
| 23:29 | amalloy | jweiss: what version of clojure? could be int/long confusion maybe? |
| 23:29 | jweiss | amalloy: 1.2 |
| 23:29 | jweiss | what i am not clear on with type hints - do you need just enough hints to narrow the choices down to 1? |
| 23:30 | jweiss | or do you need to hint everything? or something in between? |
| 23:30 | jweiss | hinting the ThreadFactory in 6th position should narrow it to 1 |
| 23:31 | ataggart | jweiss: it's all or nothing to resolve reflection |
| 23:31 | jweiss | ataggart: so i have to hint all the arguments? |
| 23:31 | ataggart | there are improvements pending for Reflector, but they've been pushed back another release |
| 23:31 | ataggart | yarp |
| 23:31 | jweiss | ah, that would explain it, thanks |
| 23:32 | ataggart | not needing that is one of the many fixes I made for Reflector |
| 23:32 | ataggart | but it's too big of a change to fit into 1.3.0 |
| 23:33 | ataggart | right now I'm trying to figure out why clojurescript is utterly broken |
| 23:33 | seancorfield | we're close to the next milestone build i'd hope? (of 1.3.0) |
| 23:34 | jweiss | ataggart: how do i hint an int or long? |
| 23:34 | jweiss | ^int 2 gives me "Metadata can only be applied to IMetas" |
| 23:35 | ataggart | well, you only need to type hint variables, not literals |
| 23:36 | bortreb | I want to make something that behaves like vectors, but has the additional property of either being "up" or "down". What's the best way or going about this? |
| 23:36 | ataggart | so, it would be mor correct to say, all args need to be known to resolve reflection |
| 23:36 | ataggart | either by typehinting or literal |
| 23:37 | jweiss | ataggart: expressions need to be hinted i assume |
| 23:37 | ataggart | if the expression does not have a known type, yes. |
| 23:38 | jweiss | ataggart: hm, i'm not sure - it's a call to reify. |
| 23:38 | jweiss | should have a known type, the interface i'm reifying :) |
| 23:38 | ataggart | need more information |
| 23:38 | ataggart | gist it |
| 23:38 | jweiss | http://paste.lisp.org/display/123845#1 |
| 23:39 | jweiss | not sure which i need to hint. tried the ^TimeUnit, ^BlockingQueue, and ^ThreadFactory, no help |
| 23:40 | amalloy | jweiss: reify may actually not have a known type, because you can reify multiple interfaces and the tagging system can only hold one class at a time |
| 23:40 | jweiss | amalloy: i see. not sure what's missing then, maybe forgot an import or something - checking |
| 23:41 | jimblomo | can i use clojure forms in my lein defproject? eg. an (if) form? |
| 23:43 | jweiss | aha - ataggart amalloy - (int 2) (int 2) (long 0) fixed it |
| 23:43 | jweiss | thanks for your help! |
| 23:44 | jweiss | good knowledge about type hinting there, not sure i've ever seen that explicitly stated in the docs |
| 23:44 | ataggart | odd. IIRC the reflector automatically coerces ints to/from longs |
| 23:45 | amalloy | ataggart: it's supposed to, but i wouldn't be surprised if there are edge cases |
| 23:45 | ataggart | ah wait, no, the reflector is dumb. it can't make widening conversions |
| 23:45 | ataggart | that was the main driver for my changes |
| 23:45 | ataggart | and 1.2.0 those literals are ints |
| 23:49 | amalloy | really? it only makes narrowing conversions? i guess that makes a little sense given 1.2's automatic widening of arithmetic |
| 23:50 | amalloy | but widening is the conversion it *should* do, isn't it? |
| 23:50 | amalloy | like, the direction that java goes |
| 23:52 | ataggart | amalloy: the method finding code does not account for widening conversions. The calling of methods in the copmiler *does* though. |
| 23:53 | amalloy | i don't understand the distinction |
| 23:53 | amalloy | doesn't it have to find a method to call it? |
| 23:54 | ataggart | At compile-time Compiler asks Reflector for a Method object given a collection of args. If an arg is an int, and all the methods take longs, Reflector returns null. |
| 23:54 | ataggart | *if there is more than one method for a given name |
| 23:56 | ataggart | assuming a Method was returned, the Compiler emits bytecode to call it, and that's when it does the long/int autocoerce |
| 23:56 | ataggart | so, in the case of only one named method that takes a long, you could call it with an int and it'd work. |
| 23:56 | amalloy | and if no method is found, then it emits bytecode to do runtime reflection, which does widen? i see |
| 23:56 | ataggart | yarp |
| 23:57 | ataggart | though that only works for int/long and float/double |
| 23:57 | ataggart | the other integral types don't get converted |
| 23:57 | ataggart | sadly |
| 23:57 | amalloy | right |
| 23:58 | ataggart | but again, I fixed all this months ago |
| 23:58 | ataggart | it's sitting in jira |
| 23:58 | amalloy | but short and byte are sorta a joke anyway. who uses them |
| 23:58 | amalloy | short, anyway |
| 23:58 | amalloy | ataggart: yeah, i remember |
| 23:58 | ataggart | people who need to work on byte arrays |
| 23:58 | ataggart | https://github.com/ataggart/codec/blob/master/src/codec/base64.clj |