2012-11-28
| 00:48 | clj_newb_234 | after I create a java.awt.Font object, is there a wya to get a list of all displabyel glyphs ? |
| 00:52 | clj_newb_234 | (. font getNumGlyphs) |
| 00:52 | abp | good mornin |
| 00:53 | tomoj | well, there's a canDisplay(char c), and there's only, what 65k chars? :/ |
| 00:56 | tomoj | clj_newb_234: https://www.refheap.com/paste/7f2aa59ebc3a126d9f6225e3f |
| 00:56 | clj_newb_234 | tomoj: is there a way to enumerate line 3? |
| 00:56 | clj_newb_234 | why is line 3 a bunch of constants? |
| 00:56 | tomoj | line 3 is the return value |
| 00:56 | clj_newb_234 | oh |
| 00:56 | clj_newb_234 | i'm an idiot |
| 00:57 | clj_newb_234 | thanks :-) |
| 00:59 | tomoj | bugs me that we don't have a range protocol |
| 00:59 | tomoj | ..rarely |
| 01:02 | clj_newb_234 | tomoj hmm |
| 01:02 | clj_newb_234 | that code outputs way more than (. font getNumGlyphs) |
| 01:04 | clj_newb_234 | 134 51406 134 51406 134 51406 |
| 01:05 | clj_newb_234 | 134 = (. font getNumGlyphs) |
| 01:05 | clj_newb_234 | 51406 = number that passes the filter |
| 01:09 | tomoj | oh. I don't even know what a glyph is, sorry |
| 01:09 | jyfl987 | hi , i have a problem when installing leining on my linode vps |
| 01:10 | jyfl987 | it just failed with saying " at clojure.main.main(main.java:37) " |
| 01:11 | tomoj | "canDisplay: Checks if this Font has a glyph for the specified character." |
| 01:11 | tomoj | I see |
| 01:11 | abp | jyfl987, probably it couldn't fetch the clojure jar? |
| 01:11 | tomoj | how'd it get a stacktrace into clojure.main then? |
| 01:11 | abp | jyfl987, are you behind a proxy? |
| 01:12 | jyfl987 | abp: wait , let me paste the full error log |
| 01:12 | abp | tomoj, um yea |
| 01:12 | abp | tomoj, should drink my first coffee before trying to be helpful ;) |
| 01:14 | jyfl987 | abp: http://dpaste.com/hold/838214/ here its |
| 01:16 | tomoj | wild guess, did you do `sudo apt-get install leiningen`? |
| 01:16 | jyfl987 | nope i use the github edition |
| 01:16 | abp | jyfl987, are you using lein repl on a project? |
| 01:16 | jyfl987 | i clone that and follow the inst in the readme file's building section as it recommend |
| 01:17 | jyfl987 | i want to got a try of noir |
| 01:17 | abp | jyfl987, no you said while installing? |
| 01:17 | jyfl987 | i mean installing plugin |
| 01:17 | jyfl987 | the noir's site told me to use that |
| 01:18 | abp | jyfl987, then better paste your project.clj, looks like leiningen is choking on that. |
| 01:18 | jyfl987 | lein plugin install lein-noir 1.2.1 |
| 01:18 | jyfl987 | then how can i do lein run? |
| 01:18 | abp | jyfl987, If you're using lein2 you don't need to explicitly install anything |
| 01:18 | jyfl987 | it seems that it would fail each time |
| 01:18 | abp | just declare it in your project.clj |
| 01:19 | jyfl987 | oop, then run that by manual? that would cause losing all the magic :[ |
| 01:20 | abp | jyfl987, let me see what that plugin does |
| 01:20 | tomoj | I wouldn't clone lein |
| 01:20 | tomoj | just do what it says in the "Installation" part of the readme |
| 01:20 | jyfl987 | my repo dont have leiningen |
| 01:20 | abp | jyfl987, and for lein2 the readme of lein noir says For Leiningen 2 run instead (you may also specify the lein-noir version to use in profiles.clj): |
| 01:20 | abp | lein new noir my-website |
| 01:22 | abp | jyfl987, lein2 should fetch necessary plugins by itself. |
| 01:23 | jyfl987 | well to use lisp syntax is pleasure, but recently i almost downloaded hundreds MB of files for the tools behind, and still got an error message :[ |
| 01:23 | tomoj | you cloned lein from github and followed the 'building' instructions? |
| 01:23 | jyfl987 | abp: but mine has fetched the plugins by itself |
| 01:24 | jyfl987 | tomoj: yep |
| 01:24 | tomoj | don't do that |
| 01:24 | jyfl987 | and my platform is ubuntu 12.04 on linode |
| 01:24 | jyfl987 | what? |
| 01:24 | clojurebot | What is 2d6 |
| 01:24 | tomoj | I'd `rm -rf .lein` (unless you put anything in ~/.lein/profiles.clj you want to save) |
| 01:24 | tomoj | then go back to the leiningen readme and follow the "Installation" instructions |
| 01:24 | tomoj | you don't need to clone |
| 01:24 | jyfl987 | so can you give me a workable instructions |
| 01:25 | jyfl987 | would try |
| 01:25 | tomoj | https://github.com/technomancy/leiningen/ |
| 01:25 | tomoj | where it says "Installation" |
| 01:25 | tomoj | start with "1. Download the script" |
| 01:26 | tomoj | I think you got a too-new version of leiningen |
| 01:26 | jyfl987 | ok done |
| 01:27 | tomoj | and.. same error? :( |
| 01:28 | jyfl987 | havent arrive that step :] |
| 01:29 | jyfl987 | jyf@li527-239:~$ lein plugin install lein-noir 1.2.1 |
| 01:29 | jyfl987 | The plugin task has been removed. |
| 01:29 | jyfl987 | that's what it return |
| 01:31 | abp | jyfl987, you still don't need to install that plugin |
| 01:32 | jyfl987 | abp: then how can i got the plugin? |
| 01:32 | abp | by using it |
| 01:32 | abp | it will be fetched automatically |
| 01:32 | jyfl987 | so it will analyzing your code before running it? |
| 01:33 | abp | I mean "lein new noir my-website" |
| 01:34 | jyfl987 | oop, thanks |
| 01:34 | jyfl987 | to you both :] |
| 01:35 | jyfl987 | another question is what do you use clojure for? |
| 01:36 | jyfl987 | yesterday i run a fibonacci 36 on my workmate's nexus 7, amazing its time costs! |
| 01:41 | abp | jyfl987, I don't use Clojure, I only sit in here, waiting for people to ask things. :P |
| 01:43 | jyfl987 | abp: well i am not joking |
| 01:43 | jyfl987 | just want to know its profits |
| 01:48 | tufflax | jyfl987, personally I think this is a very strong aspect of clojure http://www.infoq.com/presentations/Simple-Made-Easy |
| 01:49 | abp | tufflax, jyfl987 Yep I recommend everyone to watch this, too. |
| 01:55 | jyfl987 | i have read the book "hacker and painter" and worked for web site years, i feel the lisp familly its really suite for web usecase. so i started learning lisp langs |
| 01:55 | jyfl987 | recently i want to setup a really site, it would have so many change and view as i could assume |
| 01:56 | jyfl987 | so i want to know if clojure could do it |
| 01:56 | jyfl987 | i used to hate java |
| 01:56 | jyfl987 | but jvm is cool to me, i am a forth fans, i like stack based machine :] |
| 01:57 | jyfl987 | but the time costs made me shocked |
| 01:58 | jyfl987 | i was worried the performances |
| 01:59 | tufflax | jyfl987, what was your experiment? the fib 36 thing, what was the code |
| 02:02 | jyfl987 | tufflax: i live on python |
| 02:03 | jyfl987 | had a kink of should i use py or clj to done that? for using py, i knew its limitation which i would met |
| 02:17 | abp | jyfl987, I've been learning and trying things with Clojure for one and a half year now. I've written a data converter at work and will do web services, a swing application and web applications with server- and client-side in Clojure at work. At home I'm working on my own set of libraries. |
| 02:17 | tomoj | hmm |
| 02:17 | tomoj | "Internal reduce solves the lazily dangling open resource problem" |
| 02:17 | tomoj | "We need reducible I/O sources." |
| 02:18 | jyfl987 | abp: so you're java world guys? |
| 02:18 | tomoj | I guess we have no way to take two reducers and get a third |
| 02:19 | tomoj | so it's not really a problem that a reducible I/O source does the I/O every time it's reduced |
| 02:20 | abp | jyfl987, after a lot of languages I arrived at Java, yes. Have done it 3 or 4 years. Had no lisp, scheme or ml knowledge before starting Clojure. Had a lot of brief looks at Scala before discovering Clojure. |
| 02:21 | jyfl987 | abp: ok ,got it, why you have time to answer people's question? is it the code are compiling? :] |
| 02:21 | abp | tomoj, don't know whom you quote but that's dead right. I/O at a file level is really alien to Clojure processes. It's easily doable but doesn't integrate great like everything else. :) |
| 02:22 | tomoj | http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html |
| 02:22 | abp | jyfl987, my legs aren't in a very good condition right now. I've got a few days of to recover. :P |
| 02:22 | Sgeo__ | Wait, does reducers do things sort of like Haskell Iteratees? |
| 02:23 | abp | tomoj, ah, yes. Didn't remember that part. |
| 02:23 | jyfl987 | abp: greate company ! |
| 02:23 | tomoj | "... a problem solved similarly by Haskell's enumerators and iteratees. (Note that unlike iteratees, reducers do not allocate wrappers per step)" |
| 02:23 | tomoj | but you could theoretically zip two async reducers into a third |
| 02:23 | abp | jyfl987, german health system. |
| 02:24 | tomoj | and if you zipped an io reducer with itself for example, you'd do all the io twice |
| 02:24 | abp | jyfl987, I had an accident with my bike, so it's nothing enjoyable. |
| 02:24 | tomoj | though I guess there are space leak problems zipping even push seqs, anyway.. |
| 02:25 | Sgeo__ | Hmm. You should be able to map onto things that aren't collections >.> |
| 02:26 | jyfl987 | abp: oop, you're in german, is it true that your goverment would gave startup founder greencard? |
| 02:26 | Sgeo__ | Examples: (map f g) where g is a function could be (comp f g) |
| 02:26 | tomoj | heh |
| 02:26 | Sgeo__ | Because you're mapping f onto the result of g |
| 02:27 | Sgeo__ | Or promises: (map f somepromise-or-future) as returning a new promise or future that will result in f applied to the result of somepromise-or-future |
| 02:27 | abp | jyfl987, I don't know about startup specific immigration. The immigration law is relaxed. |
| 02:27 | tomoj | but that seems more confusing without static types |
| 02:28 | jyfl987 | just heard that from my friends |
| 02:28 | tomoj | I do wish (= [4 -2] (map [+ -] [1 2] [3 4])) |
| 02:29 | tomoj | well, that doesn't really work out |
| 02:30 | tomoj | since collections can really be functions |
| 02:31 | Sgeo__ | "The reducer fns are curried, and they can be easily composed:" |
| 02:31 | abp | ,(map (juxt + -) [1 2] [3 4]) |
| 02:31 | clojurebot | ([4 -2] [6 -2]) |
| 02:31 | abp | tomoj, isn't that close enough? |
| 02:31 | Sgeo__ | ..why haven't I thoguht of writing functions that may or may not be curried before? |
| 02:32 | abp | Sgeo__, because your type system prevented it? :P |
| 02:32 | tomoj | abp: no? |
| 02:33 | tomoj | &(map #(%1 %2 %3) [+ -] [1 2] [3 4]) |
| 02:33 | lazybot | ⇒ (4 -2) |
| 02:33 | tomoj | hmm.. $ is a valid symbol |
| 02:34 | Sgeo__ | Hmm. |
| 02:35 | tomoj | https://www.refheap.com/paste/3711749c6a766e8d801ef611d |
| 02:35 | abp | tomoj, ok. :x |
| 02:35 | Sgeo__ | eww at all those arglists |
| 02:36 | Sgeo__ | I guess the fear is that apply is slow? |
| 02:36 | tomoj | yeah |
| 02:38 | tomoj | I think IFn in core.cljs has 20 arities |
| 02:38 | tomoj | 21 |
| 02:45 | abp | tomoj, why isn't there a scaffolding macro for high arity fns? |
| 02:46 | tomoj | dunno |
| 02:46 | tomoj | I've been thinking about building macro combinators and the multiarity case is a looming threat |
| 02:55 | abp | tomoj, for macros building fns, do you know of a good way to keep fns capabilities besides destructuring? So, mostly the optionals: meta docstring and name. There's clojure.tools.macro/name-with-attributes. But I don't think that's what I want. |
| 02:56 | tomoj | nope, I just copied the bits of defn I needed :/ |
| 02:57 | tomoj | but why doesn't name-with-attributes work for you? |
| 02:58 | abp | tomoj, I need to process the argument list before building an fn. That defeats the purpose of name-with-attributes because it's complected. |
| 02:59 | abp | tomoj, I think the fn built should be what get's passed as the name arg. |
| 03:03 | abp | tomoj, I've looked for fn and fn* and thought it all was implemented in Java. Thanks for pointing me to defn. :) |
| 03:04 | tomoj | fns don't get docstring/metadata you know? |
| 03:05 | abp | tomoj, oh, thats sad. :x |
| 03:06 | tomoj | I mean, you can put metadata (and a :doc string) on a fn, but no one looks at it |
| 03:06 | abp | tomoj, yeah, with-meta only. |
| 03:06 | tomoj | yeah, but even then, e.g. (def foo (with-meta identity {:doc "identity"})) |
| 03:06 | tomoj | (doc foo) will not show that docstring |
| 03:06 | clojurebot | Titim gan éirí ort. |
| 03:07 | tomoj | because doc looks for metadata in the var |
| 03:08 | abp | tomoj, wow, I'm fucked. :D |
| 03:09 | tomoj | have to do (def ^{:doc "identity"} foo identity) |
| 03:09 | tomoj | (which is why name-with-attributes gives you the meta on the name) |
| 03:11 | abp | tomoj, sure, but I don't even def. So there will never be (doc ..) support. What about tools that produce documentation? Can I pass them fns and they find :doc meta on the fn? |
| 03:11 | abp | ,(meta (with-meta (fn []) {:doc "x"})) |
| 03:11 | clojurebot | {:doc "x"} |
| 03:13 | tomoj | the only tools I know that produce documentation look at nothing more than var :doc metadata and comments |
| 03:13 | tomoj | it would seem very odd to pass a fn to something that produces documentation |
| 03:14 | tomoj | why would you want documentation for a fn that's not accessible by a var? |
| 03:16 | Sgeo__ | Maybe it's accessible by a var but the assignment of the fn to the var shouldn't have to deal with placing the doc |
| 03:16 | Sgeo__ | As in, (def f (create-some-fn-with-dynamically-generated-documentation 1 2 3 4 5)) |
| 03:17 | tomoj | hmm.. so write defmeta which copies the meta from the fn :/ |
| 03:22 | abp | tomoj, I want to define whole applications in terms of special fns, so doc support would be useful. |
| 03:27 | Raynes | wat |
| 03:28 | abp | Raynes, javascript? |
| 03:28 | dimovich | hello all |
| 03:28 | dimovich | wondering, why does: |
| 03:28 | dimovich | (def urls ^{:limit 3} '("http://google.com")) (meta urls) => {:line 1} |
| 03:29 | dimovich | what am I doing wrong? |
| 03:29 | dimovich | the meta is not saved in the var... |
| 03:29 | Raynes | The metadata goes before the name. |
| 03:29 | Raynes | Also, you're looking up metadata on the list, not the var itself. |
| 03:30 | Raynes | dimovich: https://www.refheap.com/paste/7101 |
| 03:31 | dimovich | i see... |
| 03:31 | Raynes | abp: purple? |
| 03:32 | dimovich | thanks a bunch for the answer |
| 03:32 | abp | Raynes, so, ClojureScript? |
| 03:33 | Raynes | Aluminum? |
| 03:39 | jyfl987 | abp: btw, can i talk noir related question here ? |
| 03:40 | abp | jyfl987, sure. I don't use it, but others in here. And Raynes maintains it. :P |
| 03:44 | jyfl987 | abp: cool, ask author is the best way |
| 03:52 | Raynes | I'm very unlikely to be able to answer questions about Noir. Best luck is with the google group. |
| 04:36 | tomoj | Sgeo__: #(apply vector %1 (map inc %&)) is (with one sample each..) 15x slower than #(vector %1 (inc %2) (inc %3)) |
| 04:36 | Sgeo__ | :/ |
| 04:37 | tomoj | (((comp c/args c/rest) #(map inc %)) vector) is only 1.11x slower than apply |
| 04:38 | tomoj | where c is this ns I'm working in |
| 04:38 | Sgeo__ | Hmm |
| 04:38 | tomoj | r/map doesn't work there |
| 04:41 | tomoj | it seems like you should be able to apply to a reducer.. |
| 04:46 | tomoj | you can't seq them either. both of those probably make sense |
| 05:00 | andrewmcveigh|wo | Is there a function that merges two array-maps and returns an array-map? merge & into both give me a hash-map. |
| 05:02 | tomoj | merge is kind of like a funny name for conj |
| 05:02 | tomoj | but.. |
| 05:02 | tomoj | array maps will do that |
| 05:03 | tomoj | &(class (merge (array-map 1 2) (array-map 3 4))) |
| 05:03 | lazybot | ⇒ clojure.lang.PersistentArrayMap |
| 05:03 | andrewmcveigh|wo | hmm... |
| 05:05 | tomoj | &(class {0 1, 2 3, 4 5, 6 7, 8 9, 10 11, 12 13, 14 15}) |
| 05:05 | lazybot | ⇒ clojure.lang.PersistentArrayMap |
| 05:05 | tomoj | &(class (assoc {0 1, 2 3, 4 5, 6 7, 8 9, 10 11, 12 13, 14 15} 16 17 18 19)) |
| 05:05 | lazybot | ⇒ clojure.lang.PersistentHashMap |
| 05:05 | andrewmcveigh|wo | So, if I have more than 8/9 entries |
| 05:05 | andrewmcveigh|wo | it merges to a hash-map. |
| 05:06 | tomoj | why do you want an array map? |
| 05:07 | andrewmcveigh|wo | Because I need to keep order in the map. |
| 05:08 | tomoj | google flatland ordered-map |
| 05:08 | tomoj | I hope you're on the jvm? |
| 05:09 | andrewmcveigh|wo | yeah. |
| 05:09 | andrewmcveigh|wo | cheers. |
| 05:09 | bozhidar | tomoj: LinkedHashMap preserves the insertion order of memory serves me right |
| 05:10 | tomoj | those aren't persistent collections |
| 05:11 | tomoj | but, thanks, don't think I had that class in my memory |
| 05:12 | tomoj | "This technique is particularly useful if a module takes a map on input, copies it, and later returns results whose order is determined by that of the copy. (Clients generally appreciate having things returned in the same order they were presented.)" |
| 05:12 | tomoj | true.. |
| 05:12 | tomoj | I've always sort of ignored the fact that my json comes out scrambled |
| 05:13 | tomoj | hurray flatland |
| 05:13 | andrewmcveigh|wo | I get the feeling that array-maps are not really used... |
| 05:13 | tomoj | they're automatically used for.. at least small literal maps |
| 05:13 | tomoj | for efficiency |
| 05:14 | tomoj | but eventually hash-maps are faster |
| 05:14 | andrewmcveigh|wo | Yeah, I think after 8 entries the {} syntax makes a hash-map. |
| 05:25 | andrewmcveigh|wo | Is there something funky about clojure.core/reduce1 or is it just because of the java call? |
| 06:16 | borkdude | my lighttable instance keeps showing the shiny "waiting" logo on startup and hangs |
| 06:16 | borkdude | anyone else who has this problem? |
| 06:17 | borkdude | ah, removing ~/.lighttable did it |
| 06:37 | si14 | can I ask a question about core.logic here? :) |
| 06:38 | borkdude | yes |
| 06:38 | borkdude | (I wouldn't know what better place) |
| 06:39 | si14 | I've tried to emulate Mendelian laws in it yesterday: https://gist.github.com/4155884 how can it be done better? how can I transform this to emulate more than 1 gene? |
| 06:40 | si14 | of course I can map this run* over a sequence of genes and generate permutations in plain Clojure, but it's not so interesting |
| 07:26 | clgv | si14: well, write a unification over a list of genes with your inherito predicate |
| 07:29 | michaelr525 | hello |
| 07:40 | tgoossens | as an exercise i'm making my own "distinct" function. i don't understand why it stops working at a certain point: |
| 07:41 | tgoossens | ,(map first (group-by identity [1 2 1 3])) |
| 07:41 | clojurebot | (1 2 3) |
| 07:41 | tgoossens | ,(map first (group-by identity (range 10))) |
| 07:41 | clojurebot | (0 1 2 3 4 ...) |
| 07:41 | tgoossens | but |
| 07:41 | tgoossens | starting from (range 32) |
| 07:41 | tgoossens | it goes wrong |
| 07:41 | tgoossens | ,(map first (group-by identity (range 32))) |
| 07:41 | clojurebot | (0 1 2 3 4 ...) |
| 07:42 | tgoossens | ,(map first (group-by identity (range 33))) |
| 07:42 | clojurebot | (0 32 1 2 3 ...) |
| 07:42 | tgoossens | why is that 32 on the second place?? |
| 07:42 | lazybot | tgoossens: Definitely not. |
| 07:43 | tgoossens | i'm mind blown |
| 07:44 | babilen | tgoossens: My intuition tells me that it is related to chunked sequences |
| 07:45 | tgoossens | mm |
| 07:45 | babilen | ,(map first (group-by identity (vec (range 32)))) |
| 07:45 | clojurebot | (0 1 2 3 4 ...) |
| 07:46 | tgoossens | ,(map first (group-by identity (vec (range 33)))) |
| 07:46 | clojurebot | (0 32 1 2 3 ...) |
| 07:46 | babilen | still :) the 32 just yells "chunked sequence" |
| 07:46 | tgoossens | is it a bug in group-by? |
| 07:47 | tgoossens | because to me it does not follow its contract |
| 07:47 | tgoossens | "The value at each key will be a vector of the |
| 07:47 | tgoossens | corresponding elements, in the order they appeared in coll." |
| 07:48 | tgoossens | ,(group-by identity (range 33)) |
| 07:48 | clojurebot | {0 [0], 32 [32], 1 [1], 2 [2], 3 [3], ...} |
| 07:49 | babilen | yeah, I've just started investigating in the same direction |
| 07:50 | tgoossens | if so i'll file a bug report perhaps |
| 07:50 | tgoossens | it would be my first time i do that, where can I do it? :D |
| 07:52 | babilen | tgoossens: http://dev.clojure.org/jira/browse/CLJ (you need an account though) |
| 07:57 | p_l | can someone point me why nrepl's symbol-completion breaks on stuff imported by leiningen? |
| 08:00 | babilen | tgoossens: group-by is correct, but the resulting datastructure (map) doesn't ensure a certain order of its items -- You might want to sort those first or use an ordered map (such as flatland's ordered) |
| 08:01 | babilen | ,(map first (sort (items (group-by identity (vec (range 32)))))) |
| 08:01 | clojurebot | #<CompilerException java.lang.RuntimeException: Unable to resolve symbol: items in this context, compiling:(NO_SOURCE_PATH:0)> |
| 08:01 | tgoossens | i think that is not true |
| 08:01 | tgoossens | ,(group-by identity (range 34)) |
| 08:01 | clojurebot | {0 [0], 32 [32], 1 [1], 33 [33], 2 [2], ...} |
| 08:03 | babilen | ,(map first (sort (group-by identity (range 33)))) |
| 08:03 | clojurebot | (0 1 2 3 4 ...) |
| 08:03 | tgoossens | no not exactly |
| 08:03 | tgoossens | because |
| 08:04 | tgoossens | [1 1 3 2] -> [1 3 2] |
| 08:04 | tgoossens | must keep the order of occurence |
| 08:04 | tgoossens | i'll just submit the bug report , i just wrote it |
| 08:04 | abp | ,{:a 1 :b 2 :c 3} |
| 08:04 | clojurebot | {:a 1, :c 3, :b 2} |
| 08:05 | abp | tgoossens, Clojures maps have no ordering guaranteed. |
| 08:05 | babilen | tgoossens: The promise of order is *not* about the k,v pairs of the dictionary but of the internal order of they items |
| 08:05 | babilen | *its |
| 08:06 | tgoossens | i don't get it |
| 08:06 | tgoossens | how do you explain |
| 08:06 | tgoossens | ,(group-by identity (range 33)) |
| 08:06 | clojurebot | {0 [0], 32 [32], 1 [1], 2 [2], 3 [3], ...} |
| 08:06 | andrewmcveigh|wo | maps aren't ordered, but their vals are. |
| 08:07 | abp | tgoossens, group-by returns a map |
| 08:07 | tgoossens | oh |
| 08:07 | babilen | That's perfectly fine -- All the values are in the order in which they are inserted. As you only have a single one the order is not important. The order of the dictionary itself is not guaranteed |
| 08:07 | tgoossens | oh |
| 08:07 | tgoossens | i get it |
| 08:07 | tgoossens | "the key" |
| 08:07 | tgoossens | [1 1] has two distinct keys, 0 and 1 |
| 08:08 | babilen | tgoossens: Think about the case that multiple items have the same key -- They would keep their order in the vector that is the value of the key in the map |
| 08:13 | babilen | ,(group-by #(Character/isUpperCase %) "bBaAdDcCYyXy") |
| 08:13 | clojurebot | {false [\b \a \d \c \y ...], true [\B \A \D \C \Y ...]} |
| 08:14 | babilen | tgoossens: ^^^ for example -- But you still don't have any guarantee about the order of 'true [..]' and 'false [..]' |
| 08:14 | tgoossens | mm |
| 08:14 | tgoossens | ok |
| 08:18 | clgv | tgoossens: just destructure the group-by resut with true and false |
| 08:19 | tgoossens | i'll play with it a bit more thanks! |
| 08:20 | p_l | ergh. I think knowing CL and being used to SLIME is working against me with Clojure |
| 08:29 | michaelr525 | p_l: did you try using ritz? |
| 08:30 | p_l | michaelr525: so far I went through nrepl.el, nrepl+ritz, counterclockwise and la clojure w/ leiningen plugin |
| 08:30 | sthuebner | p_l, michaelr525: ritz-swank is very decent and works well enough with SLIME |
| 08:31 | p_l | sthuebner: does it support a version of slime that wasn't best pals with dinosaurs? |
| 08:31 | p_l | (i.e. if it doesn't support current snapshots of SLIME, I'm not touching it. Too much work repairing my environment again) |
| 08:31 | michaelr525 | haha |
| 08:36 | sthuebner | p_l: it supports SLIME 2011-11-13. I tried with snapshot, but there seemed to be a problem with emacs from trunk at the time I was trying it. Didn't take a second shot |
| 08:37 | p_l | sthuebner: afaik that's from before protocol change |
| 08:37 | sthuebner | p_l: you may wan't to test it with a recent snapshot of SLIME. If it's not working: sorry I talked you into it ;) |
| 08:37 | sthuebner | p_l: no idea |
| 08:39 | p_l | .act |
| 08:39 | p_l | oh well |
| 08:39 | p_l | I'll try at home |
| 08:39 | p_l | though it will undoubtedly blow memory |
| 08:41 | sthuebner | p_l: good luck! |
| 08:47 | Foxboron | Great |
| 08:47 | Foxboron | Get SICP, Joy of Clojure and Clojure Programming on my doorstep, from amazone. |
| 08:47 | Foxboron | SICP and Joy was fucking bent as they didnt manage to stack them properly |
| 08:47 | Hodapp | blugh |
| 08:48 | p_l | heh. I got my SICP for £1 in pretty good condition |
| 08:56 | p_l | just look through university thrift bookstores :) |
| 08:57 | Foxboron | https://pbs.twimg.com/media/A8yuqgtCMAARlum.jpg:large |
| 08:57 | Foxboron | Wasnt that bad when i opened it up, but srsly. packing books this way D:? |
| 08:57 | AimHere | p_l, yeah, but do you often get really good textbooks of the SICP ilk in those? |
| 08:57 | AimHere | About the only really good technical book I found was a first-edition K&R once |
| 08:57 | p_l | AimHere: depends on area, and whether they scrapped good subjects recently? :) |
| 08:59 | Hodapp | I found 2nd edition K&R for a couple dollars at a Christmas bazaar once |
| 09:01 | Foxboron | wow |
| 09:01 | Foxboron | Even tho i dont like K&R, thats quite cheap |
| 09:03 | Hodapp | and I was too unfamiliar with it to realize I'd acquired quite a gem of a book until about 6-7 years later |
| 09:03 | AimHere | It has the advantage of being thin |
| 09:03 | Hodapp | the bigger advantage is in the language itself that a thin book can express |
| 09:03 | AimHere | For a time, until ebook readers became commonplace, it was the rule that computer books were as thick and heavy as possible |
| 09:04 | AimHere | Therefore sellers were inclined to price them by the kilo |
| 09:04 | p_l | someone here haven't seen medical or physics textbooks |
| 09:05 | bluegray | howdy, trying to get this going: https://github.com/hugoduncan/hornetq-clj |
| 09:05 | bluegray | but I have no idea how to configure hornetq |
| 09:05 | bluegray | looking for some pointers before I get lost in the docs ;) |
| 09:13 | bhenry | if i have a clojure program that uses java.io.File/createTempFile how can i rename that file when i want to send it in an email attachment later? |
| 09:29 | solussd | good morning everyone! I need help naming a function. It works like get-in, but handles sequential collections along the way and returns a seq of seqs reflecting the nested structure of the sequential datastructures. e.g. (myfunction {:a [{:b {:c 5}} {:b {:c 6}} [{:b {:c 9}}]]} [:a :b :c]) => (5 6 (9)) |
| 09:30 | solussd | I was considering "get-across-in". :) |
| 09:32 | dfan | get-all-in ? |
| 09:33 | solussd | i like that better |
| 09:37 | edlich | If I compare the Sudokusolver in http://rosettacode.org/ Clojure (41 Lines) is only beaten by Prolog (26 lines). Could this be real? |
| 09:38 | solussd | prolog is designed to tackle problems like that |
| 09:39 | edlich | Is it using trial and error? |
| 09:39 | edlich | I do not understand the code... http://rosettacode.org/wiki/Sudoku#Prolog |
| 09:40 | dfan | It's basically describing what a vaild solution looks like and then it's Prolog's responsibility to find one |
| 09:40 | edlich | I mean there is no solving talk (but sorry wrong forum for this ;-) |
| 09:41 | solussd | it's not trial and error, it's constraint-based |
| 09:41 | edlich | But can it be started? |
| 09:42 | solussd | It's been a long time (college) since I played w/ prolog. I can't read that. :) |
| 09:43 | edlich | ;-) ok thanks for all the other answers. |
| 09:43 | edlich | Was just curious... |
| 09:43 | edlich | (But of course logic is important for Clojurianers...) |
| 09:44 | solussd | there is core.logic one of these days I'll dig into it.. :) |
| 09:45 | edlich | yes, must be important... (god let time rain...) |
| 09:47 | clgv | edlich: what is your exact question? |
| 09:48 | edlich | The exact question is: is the sudoku solver (rosettacode.org) in Prolog (that beats Clojure in lines) able to start and solve any given problem?! |
| 09:48 | edlich | Or is it just trial and error or a general description, what the solution looks like (the latter would be unfair). |
| 09:48 | clgv | edlich: probably. why not? backtracking is a built-in in logic programming |
| 09:50 | edlich | ok, then you can somehow feed the problem(1, [[_,_,_... to it. to the code above?! |
| 09:50 | dfan | It is a description of what the constraints on a valid Sudoku solution are |
| 09:50 | dfan | Along with an additional constraint which is the squares that have already been filled in for a specific problem |
| 09:51 | edlich | Yes but this is unfair. It also must solve a real world example. |
| 09:51 | clgv | edlich: a sudoku solver in clojure with logic programming: http://dosync.posterous.com/friendlier-shorter |
| 09:51 | dfan | Of course it solves real world examples |
| 09:51 | edlich | ups. This is cool stuff. Thanks. |
| 09:51 | edlich | indeed looks a little equal to prologe |
| 09:52 | edlich | Fantastic. You really made my day. |
| 09:53 | clgv | edlich: thank david nolen for writing that snippet and core.logic ;) |
| 09:53 | edlich | I will if I ever meet him. |
| 09:55 | bryanl | Is there a more succinct method for entering in math equations in clojure: https://gist.github.com/4156559 |
| 09:55 | bryanl | I've been doing it the long way |
| 09:56 | clgv | bryanl: incanter has a macro for infix -> prefix notation |
| 09:57 | clgv | bryanl: incanter.core/$= |
| 09:58 | bryanl | clgv: thanks for the pointer, i'll go take a look |
| 09:59 | bryanl | clgv: that's exactly what i was looking for |
| 09:59 | bryanl | thanks! |
| 10:00 | edlich | Is incanter better then R, Julia or the python libs? |
| 10:01 | clgv | edlich: incanter cant beat R since it has only some basic statistic tests. but I like it for charts since it's clojure ;) |
| 10:02 | edlich | I thought Colt leverages Incanter up in this field... |
| 10:03 | clgv | edlich: huh? isnt Colt just for matrix multiplications and other matrix related operations? |
| 10:03 | edlich | No it has more. |
| 10:03 | edlich | http://acs.lbl.gov/software/colt/api/cern/jet/stat/package-summary.html |
| 10:04 | clgv | there is no "statistic test" in that package |
| 10:05 | clgv | just probability distributions and some other functions ^^ |
| 10:05 | edlich | yes true |
| 10:05 | edlich | looks like a missing incanter feature... |
| 10:06 | borkdude | Clojure on R |
| 10:06 | clgv | well. you can easily "shell out" to R if you need more ;) |
| 10:06 | babilen | I found incanter to be quite unreliable and cumbersome for chart rendering and am still looking for a good alternative |
| 10:07 | clgv | babilen: I did some rewriting of chart implementations but didnt get to release them yet... |
| 10:07 | edlich | But bridging C and Fortran zu Clojure will surely be no fun... |
| 10:07 | clgv | babilen: unluckily they are based on incanter 2.4 |
| 10:08 | babilen | clgv: 2.4 ? |
| 10:08 | clgv | uhh 1.2.4 ^^ |
| 10:09 | babilen | clgv: Yeah, that is unfortunate. Did you by chance fix the "disappearing labels" bug? |
| 10:10 | clgv | babilen: no. I did not experience that one. I tried to make charts more composable and to have better "dynamic charts" |
| 10:10 | babilen | clgv: It is just that I have the impression that Incanter development slowed down significantly and that not many people work on it. Sure there was a release spurred by some of the discussions on the ML, but in general it doesn't necessarily strike me as a library that I want to depend on. |
| 10:11 | josteink | mpan: *nudge* |
| 10:12 | babilen | clgv: Ok - I gave up when I ran into https://groups.google.com/forum/?fromgroups=#!topic/incanter/g2k2M6JllYE and am now investigating Processing |
| 10:13 | babilen | clgv: But it looks as if I will keep on using matplotlib in Python until something reasonable appears in Clojure... :( |
| 10:13 | dimovich | whenever I modify my project, I need to reconnect the repl to get the new changes... |
| 10:13 | dimovich | is there a way to automatically pull the new changes into the repl? |
| 10:14 | zerokarmaleft | dimovich: depends on what kind of changes you're making |
| 10:14 | antoineB | hello, in cljs i can use: cljs.core.map(function(x) { x; }, [1, 2, 3]) |
| 10:14 | dimovich | modifying some source code in the ns I'm currently in the repl |
| 10:14 | zerokarmaleft | in general C-c C-l will reload the current file |
| 10:14 | antoineB | but i can use an array of Node? |
| 10:15 | antoineB | i get : [unsupported: no toString() function in type object] |
| 10:16 | zerokarmaleft | dimovich: if i redef'd a bunch of functions then i'll reload the file, otherwise i selectively eval so it gets updated in the repl |
| 10:17 | dimovich | thanks for the tips |
| 10:24 | antoineB | ok, i make a mistake the type i was using was HTMLCollection, where i think it was array |
| 10:25 | antoineB | just extend-type HTMLCollection like it is for array in github.com/clojure/clojurescript/master/src/cljs/cljs/core.cljs |
| 10:59 | Frozenlock | Any updates on if/when the clojure conj videos will be available? |
| 11:00 | katratxo | Frozenlock: https://twitter.com/clojure_conj/status/273614269029941250 |
| 11:00 | pjstadig | Frozenlock: https://twitter.com/clojure_conj/status/273614207822487554 |
| 11:01 | pjstadig | gah! you beat me |
| 11:01 | katratxo | ;) |
| 11:01 | Frozenlock | Terrific, thanks! |
| 11:01 | Frozenlock | (Shame it's still empty) |
| 11:34 | richo | I'm trying to create an image with Graphics2D and serve it up via noir.. but it looks like toString on ByteArrayOutputStream is doing some encoding magic which breakt he image. How do I server up a ByteArray with noir ? |
| 11:40 | dimovich | what's the best way to test the matching of a string literal against a collection of strings? |
| 11:41 | antoineB | dimovich: depends what you want, if you to know if there is almost one match, there is a function for that |
| 11:41 | antoineB | *if you want to know |
| 11:42 | dimovich | I got a chunk of an url and need to test if it matches a list of urls |
| 11:42 | dimovich | true false is enough |
| 11:43 | antoineB | http://clojuredocs.org/clojure_contrib/clojure.contrib.seq-utils/find-first |
| 11:43 | antoineB | macth the whole list? |
| 11:44 | mbcev | Are there any opinions surrounding UI with Clojure? I know there are tie ins to Swing (besides just making standard Java calls) and Processing, is there anything else? And would you recommend one framework vs another? |
| 11:44 | TimMc | Frozenlock: It usually takes about 5 months. |
| 11:44 | dimovich | stop on first positive |
| 11:44 | TimMc | dimovich: Are you doing routing for a web app? |
| 11:44 | dimovich | no... just some crawling and data extraction |
| 11:45 | antoineB | dimovich: find-first is what you need, for matching the url part to an url you can use regex |
| 11:46 | dimovich | for regex I need re-pattern but it doesn't escape the string... |
| 11:47 | Frozenlock | TimMc: A little longer than I was hoping :( |
| 11:48 | antoineB | dimovich: http://clojuredocs.org/clojure_core/clojure.core/some |
| 11:48 | antoineB | only true false result |
| 11:49 | dimovich | yeah, some is what I need |
| 11:49 | antoineB | ,(contains? "abcd" "b") |
| 11:49 | clojurebot | false |
| 11:50 | dimovich | (re-find (re-pattern "hello?") "hello?") => "hello" |
| 11:50 | dimovich | (re-find (re-pattern "hello\\?") "hello?") => "hello?" |
| 11:50 | dimovich | how do I automatically escape regex strings? |
| 11:51 | antoineB | http://clojuredocs.org/clojure_contrib/clojure.contrib.str-utils2/contains_q look at the source (notice this is not the standard library) |
| 11:51 | dimovich | antoineB: cool, this is perfect... thanks |
| 11:52 | mrroman | dimovich: maybe just use .contains from java.lang.String ? |
| 11:54 | dimovich | mrroman: yep |
| 12:01 | gtrak | would anyone pick Shiro over Friend at this point or something else for clojure-security? |
| 12:01 | mrroman | mbcev: There is also SWT. This is nice alternative to Swing. |
| 12:41 | SegFaultAX | Good morning ladies and gents. How's everyone doing today? |
| 12:48 | TimMc | Despising ExtJS. |
| 12:49 | mdeboard | TimMc: Employer mandate? |
| 12:49 | TimMc | Yeah. |
| 12:49 | mdeboard | That's the best |
| 12:50 | mdeboard | Did they buy a license before talking to the devs? That's my favorite. |
| 12:50 | TimMc | I can't even articulate what I hate about it yet -- but there's something deeply wrong with the design. |
| 12:51 | TimMc | Oh, we talked about it first. I recommended against it. "Let's just try it", and the thing grew like a tumor. |
| 12:51 | TimMc | I've recommended against using it on public-facing sites, by the way -- it's riddled with XSS holes. |
| 12:53 | SegFaultAX | TimMc: What's your preferred framework? I'm quite interested in AngularJS, but I haven't used it yet. |
| 12:53 | TimMc | I haven't worked with any JS frameworks. I'm not really sure there's a reason to. |
| 12:54 | TimMc | Angular did look intriguing. |
| 12:56 | SegFaultAX | TimMc: I find that, apart from reducing some of the boilerplate, js frameworks are really useful for organizing and structuring increasingly larger applications. |
| 12:57 | SegFaultAX | Maybe it's just a matter of inexperience on my part, but I feel like there is this hidden threshold in JS where it flips from being reasonable and manageable to complete shit. |
| 12:59 | SegFaultAX | dnolen: Do you build lots of large javascript-heavy applications? |
| 12:59 | TimMc | SegFaultAX: Remember to distinguish between frameworks and libraries. |
| 12:59 | mdeboard | dnolen: For us amateurs however, the code organization SegFaultAX mentioned is a huge plus. |
| 12:59 | TimMc | Ext is a framework, through and through -- no cherrypicking of Ext into other apps, and no cherrypicking of other libs into Ext. |
| 12:59 | dnolen | SegFaultAX: I've built very large JS applications in the past yes. |
| 12:59 | mpenet | imo there is no silver bullet, it all depends on the your task |
| 13:00 | mpenet | sometimes low level is better, sometimes angularjs like is good |
| 13:00 | TimMc | I feel like require.js, jquery, and a nice CSS grid would get us all the benefits of Ext without the disgustingness. |
| 13:00 | mdeboard | TimMc: Yuck |
| 13:01 | SegFaultAX | mpenet: The problem I struggle with is js isn't really designed for large applications. It lacks certain (what I consider to be basic) language-level features that make that task reasonable. Modules are my go-to example. |
| 13:02 | mpenet | SegFaultAX: I agree, there is no standard way to do this anyway, most of the time JS devs reinvent this in some way or another |
| 13:02 | mpenet | SegFaultAX: Which almost always ends up in a house of cards |
| 13:03 | SegFaultAX | mpenet: Yes! :( |
| 13:03 | S11001001 | ,(class (into-array ["hi"])) ; nDuff |
| 13:03 | clojurebot | [Ljava.lang.String; |
| 13:03 | S11001001 | nDuff: you don't have to remember |
| 13:03 | raek | nDuff: semicolon at the end... :) |
| 13:11 | sundbp | how do i set a breakpoint with nrepl-ritz? |
| 13:14 | hugod | sundbp: C-c C-x C-b on the line you want to break at |
| 13:14 | nDuff | S11001001: I wasn't sure that my problem was within the quotes; thus, knowing how to look up the class name didn't provide certainty. Clearly, though, such was in fact the case. |
| 13:15 | sundbp | hugod: ok, cool |
| 13:16 | sundbp | hugod: doesn't seem bound. what's the function and i can see if bound at all? |
| 13:19 | hugod | sundbp: slime-line-breakpoint or slime-java-line-breakpoint (in .java source) |
| 13:19 | hugod | sundbp: provided in the slime-ritz.el package |
| 13:19 | sundbp | hugod: for nrepl those are still the functions? |
| 13:19 | S11001001 | nDuff: multi-step process of elimination |
| 13:20 | hugod | sundbp: ritz for nrepl doesn't support breakpoints yet |
| 13:20 | sundbp | hugod: ok. i see |
| 13:21 | hugod | sundbp: breakpoints in nrepl will be simple to add - just haven't got to it yet |
| 13:22 | sundbp | sundbp: break on exception seems to leave the nrepl session hanging. says "b-o-e calling nil nil" |
| 13:23 | justix | I'm trying to get clojure-test-mode working. My project is structured in according to default lein projects with a /src and /test directory but for some reason "C-c t" tries to make a new file in /src instead of /test/path/to/ns.clj. is this a common issue? |
| 13:34 | sundbp | hugod: switched to ritz-swank and now b-o-e does the right thing |
| 13:36 | hugod | sundbp: was that ritz-nrepl 0.6 you were trying? |
| 13:37 | sundbp | hugod: yes |
| 13:37 | sundbp | hugod: i typed wrong nick, if you missed this is what i see: sundbp: break on exception seems to leave the nrepl session hanging. says "b-o-e calling nil nil" |
| 13:39 | borkdude | what is the paredit command for )) "foo") -> ) "foo" )) |
| 13:39 | hugod | sundbp: mm, I've seen that in 0.5, but not in 0.6 :( |
| 13:40 | langmartin | borkdude: that's called "slurp" |
| 13:40 | langmartin | M-s |
| 13:40 | zerokarmaleft | borkdude: slurp-forward from the second ) |
| 13:40 | sundbp | hugod: list packages shows: nrepl-ritz 0.6.0 installed |
| 13:40 | borkdude | ah, so I have to move backwards first if my cursor is on "foo"? |
| 13:41 | hugod | sundbp: it will be the lein-ritz plugin that makes a difference for this |
| 13:42 | borkdude | why is this invalid clojurescript? (set! (.innerText (.getElementById js/document "myP")) "foo") |
| 13:42 | sundbp | hugod: $ grep lein-ritz ~/.lein/profiles.clj |
| 13:42 | sundbp | {:user {:plugins [[lein-ritz "0.6.0"] |
| 13:42 | langmartin | borkdude: sorry, C-right is the binding for it. I can type paredit bindings, but my verbal brain can |
| 13:42 | langmartin | 't do them |
| 13:42 | ro_st | borkdude: .-innerText |
| 13:43 | borkdude | ro_st why the minus? |
| 13:44 | ro_st | .innerText becomes x.innerText() |
| 13:44 | ro_st | .-innerText becomes .innerText |
| 13:44 | ro_st | fun, ain't it |
| 13:44 | borkdude | ro_st ah I see |
| 13:45 | borkdude | ro_st I was trying the -> macro before, does it work with properties instead of methods? |
| 13:46 | ro_st | (set! (.-innerText (.getElementById js/document "thing")) "woohoo!") |
| 13:46 | ro_st | that should work? |
| 13:46 | borkdude | ro_st that works, yes |
| 13:46 | borkdude | ro_st but can we rewrite it with ->? |
| 13:47 | ro_st | if the macroexpansion of -> makes it look like the above, then yes :-) -engineer answer- |
| 13:47 | ro_st | argh. http://melpa.milkbox.net/packages/ is returning a 403. can't install packages to emacs |
| 13:48 | borkdude | like this: (-> js/document (.getElementById "myP") .-innerText (set! "foo")) |
| 13:49 | borkdude | yes, it works |
| 13:49 | borkdude | finally :-) -. did it |
| 13:50 | ro_st | spelunking in cljs, finally? :-) |
| 13:51 | borkdude | just trying some little things, nothing special |
| 13:55 | ro_st | so no google+ killer yet |
| 13:56 | borkdude | ro_st does it need a killer? I hardly use it :) |
| 13:57 | ro_st | me neither. picked the first massive js app i could think of :-) |
| 13:58 | ro_st | finally caving and installing nrepl.el |
| 14:10 | borkdude | what is the best way to print/str a (finite) lazy seq? |
| 14:11 | borkdude | wrap it in a seq call works, but why? |
| 14:14 | Raynes | &(pr-str (range 10)) |
| 14:14 | lazybot | ⇒ "(0 1 2 3 4 5 6 7 8 9)" |
| 14:14 | Raynes | prn works |
| 14:14 | Raynes | borkdude: Get anything out of the Haskell blog post? |
| 14:16 | borkdude | Raynes ah the pr-family is what I should use, tnx |
| 14:17 | borkdude | Raynes I thought it was interesting, but I have to dig into Haskell deeper to totally get it. It seems like a lot of work to parse JSON, but you get typesafety in return |
| 14:17 | borkdude | Raynes I like your style of writing |
| 14:18 | borkdude | Raynes applicative functors are definitely something I will read about more |
| 14:20 | borkdude | I'm trying to wrap my head around why lazy evaluation is something most FP academia prefer |
| 14:23 | borkdude | is this allowed in clojurescript? |
| 14:23 | borkdude | (def fib (lazy-cat [0 1] (map + fib (rest fib)))) |
| 14:23 | borkdude | (js/alert (pr-str (take 20 fib))) |
| 14:24 | borkdude | I get an error… maybe Haskell would tell me this before the compiler claimed to have succesfully compiled this? ;-) |
| 14:24 | p_l | lol |
| 14:33 | borkdude | I notice replacing with concat still doesn't work. maybe it has trouble understanding the recursive definition of the lazy list? |
| 14:35 | TimMc | borkdude: It fails with a type error, so yes. |
| 14:35 | TimMc | (yes, Haskell would catch that) |
| 14:36 | tomoj | why is it a type error if it works in clojure? |
| 14:36 | TimMc | It doesn't work in Clojure. |
| 14:37 | TimMc | ClassCastException clojure.lang.LazySeq cannot be cast to java.lang.Number |
| 14:37 | borkdude | it works here |
| 14:37 | TimMc | Oh, I know what I did wrong... |
| 14:37 | TimMc | Stupid nth. |
| 14:41 | borkdude | why do I always find strange bugs by trying out almost the first thing in a new technology I'm trying out |
| 14:41 | borkdude | -I'm trying out, that was duplication |
| 14:42 | borkdude | in the F# console I found a bug by typing in "1" as an expression, it crashed |
| 14:42 | p_l | haha |
| 14:42 | p_l | sounds like a gift |
| 14:42 | pisketti | a superpower |
| 14:44 | TimMc | You've got a bright career in QA. |
| 14:44 | TimMc | or pentesting, probably |
| 14:46 | p_l | just as long as he isn't supposed to be the user |
| 14:47 | borkdude | is there a document that lists what is and isn't possible in clojurescript? |
| 14:48 | redinger | borkdude: https://github.com/clojure/clojurescript/wiki/Differences-from-Clojure |
| 14:48 | redinger | It may not be what you are looking for, but it always helps me when things don't go as expected |
| 14:50 | borkdude | redinger tnx |
| 14:52 | mklappstuhl | Hey |
| 14:53 | mklappstuhl | I'm trying to give kibit a spin so I added it to my ~/.lein/profiles.clj like so: |
| 14:53 | mklappstuhl | {:user {:plugins [[lein-kibit "0.0.7"]]}} |
| 14:54 | mklappstuhl | running "lein kibit" returns an error that the given task is not available though |
| 14:57 | tomoj | borkdude: curious, what was the error? |
| 14:58 | borkdude | tomoj in javascript? |
| 14:58 | clojurebot | javascript is beautiful, you're just too conformist to appreciate its quirks: http://tinyurl.com/7j3k86p |
| 15:00 | jonasen | mklappstuhl: weird. What does "lein version" report? |
| 15:00 | mklappstuhl | Leiningen 1.7.1 on Java 1.6.0_24 OpenJDK 64-Bit Server VM |
| 15:01 | mklappstuhl | jonasen, -.- |
| 15:01 | borkdude | doh |
| 15:01 | mklappstuhl | jonasen, thanks ;) |
| 15:01 | Raynes | cemerick: Hope I didn't scare you too bad with the Haskell. |
| 15:01 | jonasen | mklappstuhl: np |
| 15:01 | Raynes | cemerick: I'm assuming the ceremony involved surprised you? |
| 15:03 | borkdude | I'm not continuing clojurescript until this mystery is solved |
| 15:03 | jonasen | mklappstuhl: the latest version requires lein 2. I should fix that.. either by mentioning it in the README or by actually supporting lein 1.x |
| 15:04 | borkdude | lein 1 or 2 it is the special case in clojure, just like f [] = [] in haskell |
| 15:05 | borkdude | Raynes can't they make an abstraction for the "empty" cases in Haskell, f [] = [] seems boilerplate to me ;) |
| 15:07 | mklappstuhl | jonasen, works fine, took 2 min |
| 15:08 | borkdude | Raynes like f belongs to the group of such and such operations and [] is the identity in this group, so I don't have to specify that case |
| 15:08 | mklappstuhl | jonasen, nice thing you built there btw :) |
| 15:09 | XPherior | technomancy: Remember that issue you opened for Korma a while back? |
| 15:10 | jonasen | mklappstuhl: thanks |
| 15:11 | cemerick | Raynes: terrified |
| 15:12 | cemerick | Reading the post was something like "ok...ooookayy...buh?...WTF!?" :-) |
| 15:12 | Raynes | cemerick: :p |
| 15:12 | borkdude | cemerick the hardest part of reading Haskell are those terrible infix operations ;) |
| 15:12 | TimMc | 'strue |
| 15:12 | tomoj | borkdude: yeah, with your fibs |
| 15:13 | cemerick | borkdude: I can cope there. |
| 15:13 | borkdude | tomoj actually now I get a lazyseq in the console, but it contains null |
| 15:13 | Raynes | cemerick: You should see that FromJSON instance without the applicative functor stuff. |
| 15:13 | Raynes | Your face would explode |
| 15:13 | cemerick | heh |
| 15:14 | kaoD_ | this is probably a stupid question, but anyways... |
| 15:14 | kaoD_ | what is my best shot at overriding some object's behavior? |
| 15:14 | borkdude | Raynes cemerick maybe it's more work, but you should take into account what the type system can do for you, does it save time in the future, less bugs? |
| 15:14 | kaoD_ | let me explain this further |
| 15:14 | borkdude | Raynes cemerick or is it just a pain in the ass until the end |
| 15:15 | kaoD_ | e.g. I want a vector with the ability to index negative indices |
| 15:15 | cemerick | Really, the worst part was the last example, of arbitrary key lookup |
| 15:15 | kaoD_ | so I have to reimplement nth |
| 15:15 | Raynes | cemerick: I keep thinking there is a better way to do that, but I haven't found one. |
| 15:15 | cemerick | borkdude: Yeah, I'm familiar with the tradeoff, to some extent; used scala for a while some years ago |
| 15:15 | kaoD_ | my best shot is reifying IPersistentVector and implementing ALL methods? |
| 15:15 | borkdude | kaoD_ You should use Python for that :P |
| 15:15 | Raynes | borkdude: I think the type system is very fun and useful, but it makes stuff like json parsing utterly horrid. |
| 15:16 | kaoD_ | borkdude: or any other dynamic-obect language, I know, but... had to ask |
| 15:16 | cemerick | kaoD_: Just use a map? |
| 15:16 | kaoD_ | cemerick: I can't see what you mean |
| 15:17 | kaoD_ | I want this object to still behave as a vector, btw |
| 15:18 | cemerick | I'm far more optimistic about the post-hoc typing and verification potential of Typed Clojure (/ Racket). No up-front penalty, pay the price of typing when you know what benefit you're hoping to get from that effort. |
| 15:18 | cemerick | kaoD_: negative indices sound as edge-case-y as e.g. a sparse vector |
| 15:19 | cemerick | which is also modeled naturally as a map |
| 15:19 | kaoD_ | cemerick: okay, then it was probably a bad example |
| 15:19 | kaoD_ | I do have a certain algorithm to re-sort a vector deterministically |
| 15:19 | cemerick | kaoD_: You can definitely do what you want (proxying APersistentVector is probably easier) but it sounds a bit sketchy. |
| 15:20 | cemerick | "re-sort"? |
| 15:20 | kaoD_ | yep, have it sorted in other order |
| 15:20 | cemerick | its values, you mean? |
| 15:20 | kaoD_ | nope, its indices |
| 15:21 | kaoD_ | I do have a function f(index_sorted) = index_original_vector |
| 15:21 | ttimvisher | is there a library function that trims a string to a maximum length at word boundaries? |
| 15:21 | kaoD_ | so I thought I could implement this function on top of nth so the new sort order is implicit and the vector is still the same |
| 15:21 | kaoD_ | which is O(1) |
| 15:22 | kaoD_ | which is cool for huge arrays |
| 15:22 | kaoD_ | *vectors |
| 15:22 | kaoD_ | see where I'm going? |
| 15:22 | ttimvisher | ie (trim-at-boundary 10 "a quick brown") => "a quick" |
| 15:22 | kaoD_ | ttimvisher: does Java implement something like that? probably |
| 15:22 | borkdude | this cljs compiles to this javascript, any pointers what's wrong? https://www.refheap.com/paste/7122 |
| 15:23 | tomoj | you can't (def fib (concat x fib)) |
| 15:24 | kaoD_ | cemerick: I know that shit is a bit sketchy and I should probably just use the mapping function myself instead of hacking into PersistentVector |
| 15:24 | llasram | Ooh -- I think applicative functors are exactly the formalization I've been looking for for a problem I'm facing |
| 15:24 | kaoD_ | but I just wanted to know if it could be done |
| 15:24 | tomoj | (lazy-cat x fib) works because it doesn't evaluate 'fib until later |
| 15:24 | llasram | Raynes: Thanks for the reference! |
| 15:24 | Raynes | llasram: ? |
| 15:24 | Raynes | Oh. |
| 15:25 | ttimvisher | kaoD_: you'd think that. i don't see anything obvious in google yet. |
| 15:26 | borkdude | tomoj good point |
| 15:26 | borkdude | tomoj I should probably give up on trying this until we have lazy-cat? |
| 15:26 | cemerick | kaoD_: It's definitely doable, and maybe isn't particularly difficult, but the result definitely won't be a sane vector. |
| 15:27 | cemerick | e.g. vectors are associative just like maps, so you'd get into issues where (not= (v 0) (first v)) |
| 15:27 | cemerick | I dunno what that might break. |
| 15:28 | kaoD_ | cemerick: I planned on reimplementing the whole interface chain |
| 15:28 | kaoD_ | so that the association is still valid |
| 15:29 | kaoD_ | if the vector internal structure isn't used anywhere outside these interfaces I should be fine, right? |
| 15:29 | kaoD_ | ttimvisher: |
| 15:29 | kaoD_ | &(.substring "012345" 0 4) |
| 15:29 | lazybot | ⇒ "0123" |
| 15:29 | kaoD_ | you wanted that, right? |
| 15:29 | kaoD_ | stop Googling and check JavaDoc FFS ! :P |
| 15:29 | cemerick | How could you square the fact that (first v) will return what (v -5) might return? |
| 15:30 | kaoD_ | cemerick: humm, you might've missed the explanation of my real use case |
| 15:30 | cemerick | probably |
| 15:30 | kaoD_ | I'm just reordering the indices |
| 15:30 | kaoD_ | that was a (probably bad) example |
| 15:31 | kaoD_ | I do have a function f(index_sorted) = index_original_vector <- so wrapping this function around ANYTHING that accesses vector's indices should be fine |
| 15:31 | kaoD_ | indices would still be 0 <= i < length |
| 15:31 | kaoD_ | they're just re-mapped |
| 15:32 | borkdude | kaoD why not just use that function to access the elements? |
| 15:33 | cemerick | Indeed, just change the indices you're using to do lookups. |
| 15:34 | tomoj | borkdude: I hadn't noticed we didn't |
| 15:34 | tomoj | I wonder if it was mistakenly left out? |
| 15:34 | tomoj | it's excluded in cljs/core.clj |
| 15:34 | cemerick | kaoD_: hacks aside, you're describing a map :-) |
| 15:34 | kaoD_ | cemerick: yeah but I still want it to behave as a vector |
| 15:34 | cemerick | The fact that the keys happen to be a set of contiguous integers is happenstance. |
| 15:35 | cemerick | why? |
| 15:35 | clojurebot | cemerick: because you can't handle the truth! |
| 15:35 | kaoD_ | I just want to avoid actually reordering the vector |
| 15:35 | tomoj | but I don't see why the exact def from core.clj wouldn't work |
| 15:35 | kaoD_ | I'm trying to shuffle a vector deterministically |
| 15:35 | kaoD_ | but I don't want to actually shuffle it |
| 15:35 | kaoD_ | because my vector might be freakin' HUGEEEEEEEE |
| 15:35 | kaoD_ | doing it like this adds a bit overhead to accessing |
| 15:35 | kaoD_ | but anyways, the operation is O(1) |
| 15:36 | kaoD_ | much better than O(my god that vector is huge) |
| 15:36 | kaoD_ | and I want it to be chainable so I can shuffle it many times without much overhead |
| 15:36 | cemerick | well, you can definitely subclass APV to apply a mapping to indices on lookup, seq creation, etc. |
| 15:36 | kaoD_ | and still feel as a vector |
| 15:37 | cemerick | But, premature optimization. Don't bother until you actually need to. |
| 15:37 | kaoD_ | cemerick: this is just a mental exercise, I don't really care about optimization |
| 15:37 | kaoD_ | in fact I don't even really care about this problem |
| 15:37 | kaoD_ | it was just posted somewhere and it made my mind start wondering what would be the most optimized version |
| 15:38 | kaoD_ | about reimplementing APV, that's what I thought... |
| 15:38 | kaoD_ | thanks for your time! |
| 15:38 | borkdude | kaoD a total function of the indices to the shuffled indices (a map of index to index) only adds a near constant extra overhead |
| 15:38 | kaoD_ | borkdude: yup, that's what I'm trying to do? |
| 15:39 | kaoD_ | I know it's optimized... now I just want to know if I can make it happen and make it still feel as a vector |
| 15:39 | kaoD_ | oh, you mean |
| 15:40 | kaoD_ | <borkdude> kaoD why not just use that function to access the elements? |
| 15:40 | kaoD_ | yep, I said that earlier |
| 15:40 | kaoD_ | it's a possibility |
| 15:40 | kaoD_ | but |
| 15:40 | kaoD_ | (nth (range 5) (my-function 3 237 4) doesn't feel as good as (nth (range 5) 4) |
| 15:41 | kaoD_ | and I dare you chain that and make several shuffles |
| 15:41 | kaoD_ | (nth (range 5) (my-function 3 237 (my-function 3 237 (my-function 3 237 (my-function 3 237 4)))) ?????? PLEASE NO |
| 15:41 | kaoD_ | specially when it has to be in every call |
| 15:41 | borkdude | (nth (range 5) (my-map 4)) would do it |
| 15:42 | kaoD_ | I would still have to: 1. create the map |
| 15:42 | kaoD_ | 2. use (nth (range 5) (my-map 4)) everywhere |
| 15:42 | kaoD_ | 3. chain using (nth (range 5) (my-map (my-map (my-map 4)))) |
| 15:42 | kaoD_ | 4. create SEVERAL maps when the parameters for the shuffling functions aren't the same |
| 15:43 | kaoD_ | 5. it only works with nth... what's going to happen when I try to print the vector? |
| 15:43 | kaoD_ | 6. FFS, that's not even kewl! |
| 15:44 | kaoD_ | 7. I just want to pass around that object and make it still behave as if it was shuffled |
| 15:44 | ttimvisher | kaoD_: not quite. "a quick brown" 10 => "a quick" |
| 15:44 | kaoD_ | but still behave as a good ole vector |
| 15:44 | ttimvisher | notice the break at the word boundary, even though there were more characters available |
| 15:45 | tomoj | Raynes: what if you want to pull out a nested field? (w/ aeson) |
| 15:45 | ttimvisher | substring works if you don't care about word boundaries. :) |
| 15:45 | kaoD_ | oh I see |
| 15:45 | kaoD_ | you'll have to DIY |
| 15:46 | borkdude | kaoD_ maybe you could write it as a lazy sequence instead of a vector (just an idea, not sure if it will work) |
| 15:46 | ttimvisher | kaoD_: looks like it :) |
| 15:47 | kaoD_ | borkdude: I thought about that too |
| 15:47 | kaoD_ | but I want random access |
| 15:48 | kaoD_ | I don't want a sequence, I want a vector |
| 15:48 | kaoD_ | I want to keep types |
| 15:50 | Raynes | tomoj: It'd be basically the same. |
| 15:50 | tomoj | ah right, ((v .: "foo") .: "bar) <*> ... ? |
| 15:51 | Raynes | Not quite. |
| 15:51 | Raynes | It's a monad, so you'd do ((v .: "foo") >>= (.: "bar")) |
| 15:52 | akhudek | Amazing. The compiler is telling me that I'm passing -2 arguments to core$max. |
| 15:52 | Raynes | akhudek: You're pretty good at this then. |
| 15:52 | Raynes | :p |
| 15:52 | tomoj | oic |
| 15:53 | tomoj | I wonder why I get "Couldn't match expected type `Text' with actual type `[Char]'" trying to use .: |
| 15:53 | Raynes | tomoj: It expects Text, not a string. Use the OverloadedStrings extension. |
| 15:53 | Raynes | Or you can import Data.Text and pack your strings, but that's a pain in the ass. |
| 15:54 | tomoj | oh, should have looked at your final code, thanks |
| 15:56 | TimMc | akhudek: macros take 3 extra args behind the scenes |
| 15:57 | tomoj | 3? |
| 15:57 | TimMc | Wait, sorry -- max is a fn. |
| 15:58 | borkdude | Raynes did you know there is a Haskell to js compiler? |
| 15:58 | Raynes | TimMc: You didn't have your orange juice toda did you? |
| 15:58 | Raynes | today* |
| 15:58 | TimMc | tomoj: 2? >_> |
| 15:58 | mpenet | borkdude: there are several |
| 15:59 | TimMc | Raynes: You can tell, huh? |
| 15:59 | mpenet | borkdude: but Fay is the hot thing atm |
| 15:59 | clojurebot | Roger. |
| 16:00 | borkdude | mpenet ah, ok cool. I was only familiar with this one http://uu-computerscience.github.com/uhc-js/ |
| 16:00 | brehaut | Raynes: im a little rusty, but is foldM .: v ["foo" "bar"] the equiv of that bind thing you showed earlier? |
| 16:00 | mpenet | borkdude: haste, ghcjs, fay, and another one I can't remember |
| 16:01 | mpenet | borkdude: and some lookalikes, ex roy |
| 16:01 | Raynes | brehaut: A hideous version of it, but I think so. |
| 16:01 | brehaut | haha |
| 16:03 | mpenet | borkdude: fay and roy are nice, they are usable in real world apps, not sure about the others |
| 16:04 | brehaut | mpenet: borkdude: roy is however close to becoming more useable; puffnfresh has been rewriting the type system, and there is talk of a standard library |
| 16:04 | mpenet | brehaut: Yup I saw some commits flying today :) |
| 16:04 | brehaut | oh nice :) thats even closer than i realised |
| 16:04 | mpenet | brehaut: I like roy a lot |
| 16:04 | brehaut | mpenet: likewise |
| 16:05 | mpenet | brehaut: fay is nice as well if you want to integrate with server side haskell |
| 16:05 | mpenet | you can shore types prety much |
| 16:05 | mpenet | share* |
| 16:05 | mpenet | since it's very close to "real" haskell |
| 16:06 | brehaut | interesting. i should have a look at it |
| 16:06 | borkdude | great info |
| 16:06 | borkdude | tnx |
| 16:06 | scriptor | do fay and roy have different niches? |
| 16:07 | mpenet | I use haskell as a test keyword on an analytics app I am working on, Fay is trending big time lately |
| 16:07 | mpenet | scriptor: roy learning curve is minimal |
| 16:07 | brehaut | mpenet: have you looked at funscript at all? |
| 16:07 | mpenet | scriptor: and more appealing to scala people I would guess |
| 16:07 | brehaut | mpenet: its very new, and from F# people |
| 16:08 | mpenet | brehaut: never heard of it |
| 16:08 | mpenet | I will have a look thanks |
| 16:08 | brehaut | mpenet: based on what ive heard aboout the stdlib, i imagine the 'appeals to scala people' is going to increase :P |
| 16:08 | mpenet | brehaut: Yeah and it's getting integrated with Play I think |
| 16:08 | brehaut | mpenet: its very much F#-like → JS style |
| 16:08 | borkdude | it would be sick to build a json parser in to-js compiled haskell though |
| 16:09 | brehaut | i actually want roys type checker as a stand alone library so i can use it as a schema language for json |
| 16:10 | brehaut | talking of roy http://turtle-roy.heroku.com |
| 16:12 | mpenet | That said I have high hopes for typed clojure, once it matures. |
| 16:13 | Frozenlock | How does the leiningen standalone works? I can't seem to give it any arguments: "no main manifest attribute, in leiningen-2.0.0-preview10-standalone.jar" |
| 16:13 | gf3 | brehaut: Is that even possible? |
| 16:13 | brehaut | gf3: why wouldnt it be? |
| 16:14 | gf3 | brehaut: I suppose I just don't know enough about language implementation, but I thought a lot of that would depend on the actual language in use? |
| 16:15 | brehaut | gf3: what do you mean by 'the actual language in use'? |
| 16:15 | gf3 | brehaut: For example, you wouldn't be able to simply tack on Roy's type checker to something like JavaScript |
| 16:16 | Raynes | cemerick: Delta finally refunded my tickets. :D |
| 16:18 | brehaut | gf3: well, no not without writing some code. but a type checker as a library is not really any different to any other validation library that you could apply to some data |
| 16:18 | brehaut | gf3: i'd particularly want it for JSON (ie, data only) rather javascript |
| 16:18 | brehaut | (that is ~typescript from MS incidentally) |
| 16:18 | gf3 | brehaut: Cool—I was just curious |
| 16:43 | brainproxy | woohoo, roman numerals parsing in clojure: https://gist.github.com/4163403 |
| 16:44 | brainproxy | had fun today with Alex Miller and the other clojurians at St. Louis Clojure Lunch Cljub |
| 16:44 | Raynes | Ugh |
| 16:44 | Raynes | Cljub? Really? |
| 16:44 | Raynes | People need to get over the j. |
| 16:44 | brainproxy | hehe, yeah.... |
| 16:51 | TimMc | Clsub |
| 16:51 | tomoj | already dropped the tld from my ns names. datomic's tendency to require full qualification makes me want to drop my domain too and put the project name as the first ns segment :/ |
| 16:51 | dfan | Nit: That to-roman isn't taking a decimal, it's taking an integer |
| 16:52 | TimMc | tomoj: I feel blessed to have a short domain name to use: timmc.org |
| 16:52 | dfan | 147 is an integer, "147" is the decimal representation, "CXLVII" is the Roman numeral representation |
| 16:52 | TimMc | Now if I can just establish a business presence in Monaco, maybe I can get tim.mc |
| 16:53 | seangrove | tomoj: Datomic or codeq? |
| 16:54 | lynaghk` | seangrove: I just saw your reflex question from the other day. It works fine in cljs, though the cljs compilers that lein cljsbuild 0.2.8 and 0.2.9 use break it mysteriously (this has since been fixed in cljs master). |
| 16:55 | lynaghk` | seangrove: w.r.t. reflex in general, all it really does is wire up a ton of callbacks for you, so you don't have to do it manually. All of the caveats of using callbacks (they highjack the execution thread when someone just changes an atom, you can tie yourself up in infinite loops, &c. &c.) still apply. |
| 16:56 | seangrove | Yeah, I'm just finding that UI programming is hellish, looking for a sane way of containing it |
| 16:57 | seangrove | Testing Shoreleave's pubsub now, but I haven't seen too much in the way of recommended approaches to building maintainable ui's in cljs |
| 16:58 | lynaghk` | seangrove: yeah, we have our own not-yet-open-sourced pubsub system |
| 16:59 | lynaghk` | seangrove: the problem is inherently pretty hellish---I haven't found a real general solution that I'm super happy with |
| 17:00 | seangrove | I'm wondering if at some point it might be a fun project to read Interface Builder's nib files into a structure that works with a cljs library |
| 17:00 | seangrove | Basically taking the approach that objective-j did to take advatnage of all the existing tooling |
| 17:01 | seangrove | But it might be too tied to the objective-c way of doing things, not sure. Anyway, a project for another day |
| 17:01 | lynaghk` | seangrove: that's a project for another man-year =P |
| 17:08 | tomoj | seangrove: datomic |
| 17:24 | hugod | dnolen: I'm getting ({:nn {:mx _.0}} :- (not-pathc (_.0 [:nn :mx]))) as a result from run* - I'm wondering if I'm doing something wrong, or if defc is missing something |
| 17:24 | hcumberdale | Hi ;) |
| 17:27 | tgoossens | mutual recursion, it screws up my mind :p |
| 17:27 | Chousuke | how come? It's just functions calling each other. |
| 17:28 | tgoossens | i just heard it for the first time (trampoline and stuff). So maybe i still have to place it :p |
| 17:29 | Chousuke | oh, trampoline |
| 17:29 | Chousuke | yeah, trampoline is a bit weird |
| 17:29 | tgoossens | cannot think of something useful to do with it |
| 17:29 | kaoD__ | tgoossens: www.4clojure.org helped me get past some issues learning |
| 17:29 | tgoossens | probably show up when i need it |
| 17:29 | tgoossens | kaod: well it is at 4clojure in encountered p |
| 17:30 | tgoossens | *i encountered it |
| 17:30 | Chousuke | tgoossens: non-stack-growing mutual recursion can be very useful in eg. modeling state machines. |
| 17:30 | Chousuke | you just write functions that represent each state and then call back and forth |
| 17:30 | tgoossens | hmm yes |
| 17:30 | tgoossens | i see |
| 17:30 | tgoossens | cool |
| 17:30 | p_l | eh, what wretched times have came that people don't remember what "trampoline" means :D |
| 17:31 | tgoossens | that's actually a pretty good example |
| 17:31 | dnolen | hugod: I need to see a minimal case |
| 17:31 | tgoossens | its like |
| 17:31 | Chousuke | tgoossens: but the way trampoline works is pretty simple. instead of recursing directly you write functions so that they return continuations |
| 17:31 | tgoossens | ask a state "what is the next state" |
| 17:31 | tgoossens | and trampoline will keep doing this |
| 17:32 | tgoossens | until it ends (no function anymore) |
| 17:32 | Chousuke | so when the function ends, its stack is unwound and its continuation is returned to the trampoline, which calls the continuation. |
| 17:32 | tgoossens | is that correct? |
| 17:32 | hugod | dnolen: ok, I'll try and put one together |
| 17:32 | Chousuke | tgoossens: trampoline is necessary in clojure because clojure can't do general TCO |
| 17:32 | tgoossens | TCO? |
| 17:32 | clojurebot | yes please |
| 17:33 | hcumberdale | ,(flatten (map (fn [[x y]] y) '(["x" (a b c)] ["y" (d e f)]))) |
| 17:33 | clojurebot | (a b c d e ...) |
| 17:33 | Chousuke | tgoossens: tail call optimization (or elimination) |
| 17:33 | tgoossens | ah yes |
| 17:33 | tgoossens | so like |
| 17:33 | tgoossens | the (loop recur) |
| 17:33 | Chousuke | yeah, that's the self-recursion case of TCO |
| 17:34 | tgoossens | i tried to read macro's but they are quite complex |
| 17:34 | Chousuke | which macros? |
| 17:34 | tgoossens | loop for example |
| 17:34 | hcumberdale | Any better way to write this? ,(flatten ... |
| 17:35 | tgoossens | or maybe it is just me not being familiar with it so "hard" is a better word perhaps. |
| 17:35 | Chousuke | hcumberdale: if you have only one level of nestirng, try (mapcat second whateverC) |
| 17:36 | Chousuke | tgoossens: many macros are very straightforward once you have a mental model of what is actually going on |
| 17:36 | hcumberdale | wow Chousuke, thx |
| 17:36 | Chousuke | some aren't though... |
| 17:36 | mbcev | quick question regarding some code I read in the "Joy of Clojure" book. There's a bit describing loop and they have something along the lines of (loop [sum 0, x x-initial] (if (pos? x) (recur (+ sum x) (dec x)))) my question is does [sum 0, x x-initial] set sum to zero and x to x-initial? I know the loop takes 2 arguments which is why recur gives back both, what happens to the 2 and x-initial and how does clojure know that those aren't required arguments? |
| 17:37 | Chousuke | mbcev: they are the initial values |
| 17:37 | TimMc | ~flatten |
| 17:37 | clojurebot | flatten is rarely the right answer. Suppose you need to use a list as your "base type", for example. Usually you only want to flatten a single level, and in that case you're better off with concat. Or, better still, use mapcat to produce a sequence that's shaped right to begin with. |
| 17:37 | TimMc | hcumberdale: ^ |
| 17:37 | Chousuke | mbcev: loop takes a binding vector, like let |
| 17:37 | TimMc | hcumberdale: Wait, that doesn't mention "for", which is another thing to use instead of mapcat. |
| 17:38 | hcumberdale | Wow, there is really mapcat in the reference |
| 17:38 | hcumberdale | ;) |
| 17:38 | mbcev | Chousuke: well what if in a different example I just opted for [x y] where x and y were defined by an outer let or what have you. |
| 17:38 | AimHere | "A map of the cat, sir?" she asked, horrified. |
| 17:39 | TimMc | Surely you're joking. |
| 17:39 | Chousuke | mbcev: what do you mean? |
| 17:39 | Chousuke | mbcev: the form of a binding vector is [name value, name2 value, ...], commas being optional |
| 17:39 | tgoossens | lol |
| 17:40 | mbcev | Chousuke: oooohhh, got it. So it's because loop is a special form right? and thus takes a binding vector as you said, not just any ol vector like when I define my own function. |
| 17:41 | Chousuke | mbcev: pretty much |
| 17:41 | mbcev | Chousuke: Thanks! <3 |
| 17:41 | Chousuke | mbcev: loop is a macro, actually, but it uses a special form internally. |
| 17:42 | jebberjeb | with clojure-ring, if I've :gen-class :extends HttpServlet, is there a way to get a reference to the servlet so I can invoke .forward()? |
| 17:42 | Chousuke | ,(macroexpand '(loop [[x y] example] dostuff (recur 1 2))) |
| 17:42 | clojurebot | (let* [G__66 example vec__67 G__66 x ...] (loop* [G__66 G__66] (clojure.core/let [[x y] G__66] dostuff (recur 1 2)))) |
| 17:43 | hcumberdale | Is there a contains? for string? |
| 17:43 | hcumberdale | Or do I have to use some? |
| 17:43 | Chousuke | hcumberdale: use java string methods |
| 17:43 | Chousuke | or regexp patterns. |
| 17:44 | hcumberdale | Chousuke to check if a list contains a string? |
| 17:44 | Chousuke | oh, that |
| 17:44 | joegallo_ | ,(some string? [1 2 3]) |
| 17:44 | clojurebot | nil |
| 17:45 | Chousuke | using some is good for that. |
| 17:45 | joegallo_ | (some string? ["abc" 1 2]) |
| 17:45 | mbcev | Chousuke: OHHH thank makes more sense; I'll look at the source next time. Herp derp. Thank you. |
| 17:45 | joegallo_ | ,(some string? ["abc" 1 2]) |
| 17:45 | clojurebot | true |
| 17:45 | Chousuke | ,(some #{"foo"} '("a" "list" "foo")) this is idiomatic as well |
| 17:45 | clojurebot | "foo" |
| 17:46 | hcumberdale | Chousuke right, but does not output true or false/nil |
| 17:46 | Chousuke | hcumberdale: that doesn't matter |
| 17:46 | Chousuke | if you need a boolean, just call boolean on the result :P |
| 17:46 | Chousuke | but most of the time you can just use the result as is |
| 17:47 | Chousuke | so long as you're not actually searching for the literal false |
| 17:47 | hcumberdale | ,(if nil "x" "y") |
| 17:47 | clojurebot | "y" |
| 17:47 | hcumberdale | ,(if "foo" "x" "y") |
| 17:47 | clojurebot | "x" |
| 17:52 | jebberjeb | what is ring.util.servlet.proxy$javax.servlet.http.HttpServlet$0 |
| 17:53 | hcumberdale | the #clojure IRC channel is so awesome |
| 17:53 | rattboi | ^^ this is true |
| 17:54 | hcumberdale | Writing so much clojure code since i've taken a lot barriers thx to the people here |
| 18:02 | black_joe | Can someone help me with my problem in Clojure? The example is a bit tricky. |
| 18:02 | black_joe | http://pastebin.com/FFqeHT5K |
| 18:02 | black_joe | It gets into an infinite loop with the following parameters: |
| 18:02 | black_joe | (make-struct '("list" ("x" "b")) '("t" "x")) |
| 18:02 | black_joe | But the or should handle that. |
| 18:06 | AimHere | You tried using empty? instead of (= foo '())? |
| 18:06 | AimHere | I think it's slightly more idiomatic |
| 18:07 | black_joe | I will try that. |
| 18:07 | tomoj | not slightly |
| 18:07 | black_joe | I usually use a home-cooked function called bad?, but I threw that away for debugging purposes. |
| 18:07 | brehaut | ,(when (seq [1 2 3]) :true) |
| 18:07 | clojurebot | :true |
| 18:07 | brehaut | ,(when (seq []) :true) |
| 18:07 | clojurebot | nil |
| 18:08 | brehaut | using seq to test the positive case rather than empty? to test the negative case is a bit more idiomatic if you are using both branches |
| 18:08 | black_joe | empty? has no effect. It plunges into an infinite loop, collecting nil on the conj. |
| 18:10 | metellus | black_joe: I think there might be an extra closing paren in your if |
| 18:10 | metellus | so the recur part is always happening, rather than being the else case |
| 18:11 | devn | im trying to update a clojurescript dependent library and am running into errors when running the tests |
| 18:11 | devn | https://github.com/devn/hiccups |
| 18:11 | devn | Anyone mind taking a peek? |
| 18:11 | black_joe | metellus: Man... That was a pretty silly mistake. I've been messing with this for quite a while. Thanks. |
| 18:12 | devn | "actual: java.lang.AssertionError: Assert failed: set! target must be a field or a symbol naming a var |
| 18:13 | devn | targetexpr" |
| 18:13 | AimHere | black_joe, I see your problem |
| 18:13 | AimHere | black_joe, you've got one too many right parens at the end of your if |
| 18:13 | AimHere | So it's just doing the if, then throwing the answer away, and then always recurring |
| 18:14 | bbloom | devn: that's a compile error, right? what line is it on? |
| 18:14 | AimHere | black_joe, oh, someone's seen it |
| 18:14 | black_joe | Yeah. That was actually helpful. It works now. |
| 18:14 | AimHere | Get your code indented properly! |
| 18:15 | AimHere | You'd see it! |
| 18:15 | black_joe | AimHere: It's just sloppy because I was debugging. Adding / subtracting lots of stuff. |
| 18:16 | devn | bbloom: analyze.clj #570 |
| 18:16 | bbloom | devn: i mean in your code |
| 18:16 | devn | bbloom: i just bumped the clojurescript version again, should be on the most recent release |
| 18:17 | bbloom | devn: I can find what line the message is on in cljs :-) |
| 18:17 | devn | bbloom: oh, heh, well, im guessing you can also read the stacktrace |
| 18:18 | devn | im seeing it around line 12 in test/hiccups/test_runner.clj |
| 18:18 | devn | this isn't "my" code -- just trying to get it up to date |
| 18:19 | bbloom | devn: I've been meaning to replace the asserts and throws in analyze and emit with proper error-raising functions, so that you can get some line numbers.... |
| 18:20 | devn | bbloom: yeah, sorry i don't have much more info at the moment |
| 18:20 | bbloom | devn: so line 12 in test runner is running the compiler |
| 18:20 | bbloom | devn: need to know what line is failing to compile |
| 18:20 | devn | there isn't a ton of code in this lib. does anything stand out to you? |
| 18:20 | devn | bbloom: yeah, understood that as soon as i hit return |
| 18:20 | devn | im hunting |
| 18:22 | devn | bbloom: any suggestions on narrowing it down? |
| 18:24 | bbloom | devn: get a local checkout of cljs' master and i'll give you a patch in a few minutes to help :-) |
| 18:24 | devn | !!! :) |
| 18:24 | devn | i've got one handy |
| 18:25 | devn | bbloom: if it's any help at all, this was the error I was getting against a year-old version of clojurescript: |
| 18:25 | devn | actual: java.lang.IllegalArgumentException: No implementation of method: :-requires of protocol: #'cljs.closure/IJavaScript found for class: clojure.lang.MapEntry |
| 18:32 | devn | bbloom: fire when ready |
| 18:32 | bbloom | devn: testing |
| 18:33 | devn | bbloom: thanks for the help |
| 18:34 | bbloom | np, this has been bugging me too :-) |
| 18:34 | bbloom | devn: good error messages are hard to do. |
| 18:35 | devn | :) |
| 18:37 | Sgeo__ | If I'm making an API with an event loop, should I have events run in their own threads? |
| 18:37 | Sgeo__ | Hmm, probably not |
| 18:37 | Sgeo__ | Actually, I have no idea what I should do |
| 18:37 | bbloom | Sgeo__: are you doing much IO? |
| 18:38 | Sgeo__ | IO but with a server somewhere via an SDK |
| 18:38 | bbloom | devn: waiting for some test runs :-) |
| 18:38 | Sgeo__ | I do want to be able to sleep, the way that something might pause for 5 seconds in a game |
| 18:38 | Frozenlo` | Uh Oh... I get a "REPL server launch timed out". Is there some argument I can give Leiningen to allow a longer time? |
| 18:38 | Licenser | Sgeo__ I'd say just go with a simple no thread stuff untill you notice it's a bottleneck |
| 18:38 | bbloom | Sgeo__: generally the rule for an evented system is 1 IO thread per network card, so for most server processes: exactly 1 IO thread |
| 18:38 | bbloom | Sgeo__: plus 1 message queue worker thread |
| 18:38 | bbloom | aka event pump thread |
| 18:39 | Sgeo__ | event pump? |
| 18:39 | Sgeo__ | Would that be my wait function? |
| 18:39 | bbloom | event loop |
| 18:39 | bbloom | pump |
| 18:39 | bbloom | whatever you want to call it |
| 18:39 | Sgeo__ | So, 2 threads |
| 18:39 | Sgeo__ | Does Lamina have functions for pausing for a bit... not sure if that's what I even mean |
| 18:41 | bbloom | devn: try this patch https://gist.github.com/4165569 |
| 18:42 | devn | Sgeo__: maybe something like defer? |
| 18:42 | Sgeo__ | There's no receive-and-close in Lamina? :( |
| 18:42 | devn | lamina.executor |
| 18:42 | bbloom | Sgeo__: generally, you won't write the IO thread yourself if you have an evented IO library |
| 18:42 | Sgeo__ | bbloom, I'm wrapping around a C library |
| 18:42 | devn | bbloom: applying... |
| 18:43 | aperiodic | Frozenlock: set :repl-options {:timeout 60000} (or higher as needed) in your project.clj |
| 18:43 | bbloom | devn: I'm gonna vet it a bit more myself and then put it up on jira |
| 18:44 | Sgeo__ | Err, what I want is read-channel followed by close |
| 18:45 | Frozenlock | aperiodic: It works! Thanks! |
| 18:47 | devn | bbloom: actual: java.lang.AssertionError: Assert failed: set! target must be a field or a symbol naming a var at line 7 test/hiccups/core_test.cljs |
| 18:47 | bbloom | devn: there you have it :-) go look at that line |
| 18:48 | Sgeo__ | Questions: Are futures lighter-weight than Threads? Will several running futures that are blocking on stuff (perhaps with Thread/wait or just deref-ing a future or promise) interfere with each other? |
| 18:51 | devn | bbloom: seems like it's a problem with the way macros are getting pulled in? |
| 18:52 | hcumberdale | how to write a list to a file |
| 18:52 | hcumberdale | each item a line |
| 18:52 | devn | my guess is (defmacro deftest [] ...) in test_macros.clj |
| 18:53 | bbloom | dnolen: i put up two good cljs patches for you to check out :-) |
| 18:55 | devn | bbloom: that is way better btw. thank you. |
| 18:56 | devn | bbloom: do you think my issue could be related to the use of `.` in hiccups.test.test-macros/deftest |
| 18:56 | dnolen | bbloom: nice, last patch looks awesome |
| 18:56 | dnolen | bbloom: will take a closer look soon thanks much. |
| 18:57 | bbloom | dnolen: just struck me: can probably do better to catch all exceptions |
| 18:58 | dnolen | bbloom: what do you mean? |
| 18:58 | bbloom | dnolen: 1 sec, ill show you |
| 19:03 | dnolen | hugod: I note that the following gist reproduces a similar constraint reification you mentioned earlier - https://gist.github.com/4165678 - this actually makes sense if you program allows this to happen. |
| 19:03 | dnolen | bbloom: gotta run, but let me know |
| 19:13 | Sgeo__ | Apparently I could use a java.util.Timer |
| 19:13 | Sgeo__ | Any Clojure libraries have a nice idiomatic interface around it, or should I just write one myself? |
| 19:13 | hcumberdale | clojure/data/xml/flatten-elements NoClassDefFound |
| 19:13 | hcumberdale | WTF... |
| 19:14 | tanzoniteblack | Sgeo__: is there a reason you need to have manual control of threads, as opposed to using futures, pmap, agents, or some similar native control structure? |
| 19:15 | bbloom | devn: looking at your thing now |
| 19:15 | bbloom | devn: yeah, deftest on line 3 in test-macros |
| 19:15 | bbloom | that is old syntax |
| 19:15 | Sgeo__ | tanzoniteblack, want to use an event-driven library in a synchronous fashion. I do have a use for manual sleeping: To be able to write games where things happen after a certain amount of time. |
| 19:15 | bbloom | it's trying to set a method |
| 19:15 | bbloom | but you have to set a property |
| 19:15 | bbloom | (.-foo bar) vs (.foo bar) |
| 19:15 | bbloom | devn: however, should be able to use real def there |
| 19:16 | nDuff | Sgeo__: I've got a wrapper around Timer somewhere. |
| 19:16 | nDuff | Sgeo__: ...actually, think I've already gisted it. |
| 19:16 | bbloom | `(def ~(symbol "goog.global" (str "test-" (name nm))) [] ...... |
| 19:16 | bbloom | devn: ^^ |
| 19:17 | nDuff | Sgeo__: https://gist.github.com/a7d911dc0df88c3c3c8f |
| 19:20 | hcumberdale | How can I modify a file with clojure? |
| 19:20 | hcumberdale | XML -> Modify -> Save |
| 19:21 | hcumberdale | Better to save a new file, right? |
| 19:26 | nDuff | hcumberdale: that's true regardless of the language. |
| 19:27 | nDuff | hcumberdale: ...create-and-rename is safer than overwrite because it's atomic on sane filesystems, whereas overwriting is almost never so. |
| 19:31 | Sgeo__ | How do I make sure things on the resource-path get included into the uberjar? |
| 19:31 | hcumberdale | what are the clojure.java.io writer options? |
| 19:31 | hcumberdale | to create/overwrite a file? |
| 19:32 | Sgeo__ | Oh, maybe it does, hmm |
| 19:34 | Sgeo__ | Ok, why does the SNAPSHOT.jar contain the dependencies I need while SNAPSHOT-standalone.jar does not? |
| 19:44 | tanzoniteblack | hcumberdale: http://clojuredocs.org/clojure_core/clojure.java.io/iofactory lists 2 options, but I'm not sure if there's a list of available options you can provide anywhere |
| 19:45 | hcumberdale | tanzoniteblack solved it, thx |
| 19:51 | Sgeo__ | nDuff, why proxy instead of reify? |
| 19:51 | mbcev | So I was under the impression that loop & recur did constant-space recursion (and I'm sure they do). Running out of memory; wondering what it is that I'm doing wrong? I don't think I'm holding anything in memory that I shouldn't be... |
| 19:56 | tanzoniteblack | mbcev: can you give some more info about what you're doing and what's happening (maybe some code?) |
| 19:56 | antoineB | mbcev: do you mean that recur do tail call recursion? |
| 19:56 | mbcev | Can I post a pastebin link? |
| 19:57 | tanzoniteblack | mbcev: please |
| 19:57 | antoineB | yes |
| 19:57 | mbcev | pastebin.com/KpkzmaL3 |
| 20:00 | mbcev | Also just noticed I copy-pasted my "test" code. when x = 10 in mod-test it does give me the 2520. When I set it to 20, heap overflow. |
| 20:02 | tanzoniteblack | mbcev: it doesn't especially look to me like you're keeping much in memory at all, so I'm unclear as to why you're getting that error. And running it on my machine it calculates quite quickly |
| 20:02 | antoineB | do a try catch and print "val" |
| 20:03 | mbcev | antoineB: try catch where? |
| 20:04 | antoineB | in the loop |
| 20:04 | antoineB | try { (if ....) } catch ... |
| 20:05 | mbcev | oh and print val on the catch? kay, hold on |
| 20:05 | antoineB | yes |
| 20:06 | tanzoniteblack | mbcev: what is the error message you're getting, and how are you running clojure |
| 20:08 | mbcev | It's still running, will let you know when it errors out on me. Also, I'm using LightTable in Windows. Just seemed a nice repl for the time being. |
| 20:11 | antoineB | mbcev: do you test on the exact same code as pastebin? because it does'nt feet the problem |
| 20:11 | tanzoniteblack | mbcev: it's possible that the problem is either with lighttable (which is still in alpha) or in how you're executing |
| 20:11 | antoineB | mod-test test to 0 to 10 instead of 0 to 20 |
| 20:12 | antoineB | tanzoniteblack: mbcev: how do you start the repl? |
| 20:12 | mbcev | Oh odd, I just excited it using lein and it executed quite quickly |
| 20:12 | mbcev | perhaps it is an issue with light table afterall |
| 20:13 | tanzoniteblack | mbcev: you should report that (along with your code) to lighttable as a bug so they can look into it |
| 20:14 | tanzoniteblack | mbcev: until then, if you're just learning Clojure, you might be happier trying a little bit more stable development environment |
| 20:14 | mbcev | Yeah, will do. Thank you guys! I was pretty sure I wasn't crazy, but I just had to make sure. |
| 20:16 | Sgeo__ | With Lamina, I want to use map*, but the function might return a result-channel, so how do I make a new channel that isn't a bunch of result channels but rather values? |
| 20:16 | antoineB | mbcev: i get 232792560 |
| 20:17 | antoineB | mbcev: make sure the repl you lunch is on the jvm, not on a javascript vm (where lighttable run) |
| 20:17 | mbcev | tanzoniteblack: is there a repl you'd recommend? I just really don't feel like setting up cygwin for emacs/vim. |
| 20:18 | mbcev | antoineB: I got the same thing when using lein instead of lightable haha |
| 20:18 | antoineB | ok |
| 20:18 | Sgeo__ | mbcev, there are Windows versions of emacs and vim |
| 20:18 | tanzoniteblack | mbcev: "I got the same thing when using lein", does that mean you're still having the issue? |
| 20:18 | tanzoniteblack | mbcev: and personally I use nrepl in emacs hooked to a lein instance |
| 20:19 | mbcev | tanzoniteblack: no sorry, I meant I got the same value of "232792560" and in miliseconds flat |
| 20:19 | antoineB | mbcev: so lein repl works, and lighttable repl run out memory? |
| 20:20 | mbcev | antoineB: correct |
| 20:20 | antoineB | http://himera.herokuapp.com/index.html here is a javascript vm repl |
| 20:22 | antoineB | that give me a result |
| 20:23 | mbcev | I'll look into the windows instances of emacs and hooking that into lein, also Himera. Thanks guys. Bleh; I use windows for a ton of stuff so as much as I love myself some linux; it's just too much of a pain in the butt for me to be dualbooting or cygwin and managing that stuff. Nothing is "simple" in the windows world (imho) and I hate it, but I gotta deal for now. |
| 20:24 | tanzoniteblack | mbcev: Ubuntu in a virtual box isn't bad, but you might also consider an alternative ide like counterclockwise for eclipse if you're not already familiar with emacs |
| 20:25 | seangrove | Wondering if shoreleave pubsub could be extended a bit so that listeners could only listen to some subset of nodes on a map |
| 20:25 | seangrove | Probably would be an easy helper function |
| 20:25 | hcumberdale | ,(first [nil, "x", nil]) |
| 20:25 | clojurebot | nil |
| 20:27 | mbcev | tanzoniteblack: maybe I'll setup ubuntu in a VM and setup seemless mode on my laptop or something. I'm familiar with emacs&vim, I just have never had good experience with them in windows so I just didn't really want to bother. |
| 20:36 | Sgeo__ | wtf |
| 20:36 | Sgeo__ | "When we map* a function over a channel, we’re effectively saying that the original channel exists to feed messages into the downstream channel." |
| 20:36 | Sgeo__ | Maybe I want to use the channel's results directly for other reasons? |
| 20:37 | Sgeo__ | This is utterly bizarre. |
| 20:38 | Sgeo__ | It's effectively mutating its input |
| 20:38 | Sgeo__ | map* I mean effectively mutating the input channel |
| 20:41 | tomoj | yes |
| 20:41 | tomoj | it's tricky |
| 20:41 | tomoj | I mean, I think it's tricky to write a library like that without bizarreness |
| 20:43 | tomoj | also then I think if you close the map channel, the source closes, by default? |
| 20:54 | mefisto | maybe a noobish question... so you got ns3 which has a symbol "thingy" in it . ns2 does :use ns3, and ns1 does :use ns2. can you refer to "thingy" without any ns qualifier in ns1? |
| 20:54 | tomoj | no |
| 20:55 | mefisto | so ns1 would have to use ns3 directly for that? |
| 21:02 | tomoj | yeah |
| 21:03 | mefisto | tomoj: ok thanks |
| 22:03 | Sgeo__ | If I make a thing with reify and pass it into a function that is ultimately C code, do I have to worry about the thing I made being garbage collected? |
| 22:07 | Sgeo__ | What's the equiv. for Java? |
| 22:08 | Sgeo__ | All I really need to do is color black or green pixels based on a data structure |
| 22:08 | brehaut | Sgeo__: java2d ? |
| 22:09 | Sgeo__ | Oh hey Java has something built in I think |
| 22:09 | jyu | is clojure run on osgi? |
| 22:09 | brehaut | jyu: clojure _web_ stuff? |
| 22:10 | jyu | a typical restful service, is it possible run the clojure program on the osgi as a bundle |
| 22:11 | brehaut | you can run it from anything that wants a .war if you want |
| 22:11 | brehaut | eg tomcat |
| 22:11 | brehaut | but you dont have to |
| 22:11 | TimMc | jyu: I'm not really clear on what OSGI is, but I know nDuff has been working with it. |
| 22:12 | jyu | equinox |
| 22:12 | brehaut | TimMc: i dont think anyone is 'clear' on what osgi is ;) |
| 22:13 | brehaut | i think its fair to say that clojure programmers prefer to avoid crazy-pants complication where possible |
| 22:16 | bbloom | is there a quick function to create a comparer from a key? ie if I want to compare two maps by the value of an :ordinal key or something like that? |
| 22:16 | bbloom | the best i got is: #(compare (:ordinal %1) (:ordinal %2)) |
| 22:16 | seangrove | I'm trying to pass the contructor to another function in cljs as an argument |
| 22:17 | bbloom | seangrove: you should pass a factory function instead |
| 22:17 | seangrove | e.g (new-control! goog.ui.Zippy (css-node ".header") (css-node "content")) |
| 22:17 | seangrove | woops, goog.ui.Zippy. |
| 22:18 | seangrove | bbloom: So I'd have to wrap all of the constructors I'd like to pass with another function and pass that? |
| 22:18 | bbloom | seangrove: yeah, because the call site needs to use the "new" operator |
| 22:18 | seangrove | damn |
| 22:18 | bbloom | unless you know what you're going to get is ALWAYS a constructor |
| 22:18 | seangrove | I can make it a macro though |
| 22:18 | bbloom | in that case you might be able to use the 'new keyword |
| 22:18 | seangrove | Yeah, just trying to DRY up some of the google closure ui stuff internally |
| 22:18 | bbloom | er special form |
| 22:19 | brehaut | (comp (partial apply compare) (partial map :ordinal)) ;; bbloom |
| 22:20 | brehaut | ; (not serious) |
| 22:20 | bbloom | seangrove: (Foo. bar) is shorthand for (new Foo bar), but Foo. is not shorthand for "new Foo" |
| 22:20 | bbloom | brehaut: heh |
| 22:20 | seangrove | Ah, I see |
| 22:21 | brehaut | actually, its not quite right (comp (partial apply compare) (juxt (comp :ordinal first) (comp :ordinal second))) |
| 22:22 | brehaut | bah |
| 22:22 | brehaut | (comp (partial apply compare) (partial map :ordinal) vector) |
| 22:22 | brehaut | i think thats it |
| 22:22 | seangrove | bbloom: I suppose that if new is a special form, it's not going to be easy to do something like: |
| 22:23 | seangrove | (defn new-control! [class args] (apply new [class args])) (new-control goog.ui.Zippy "arg-1" "arg-2" true) |
| 22:23 | bbloom | brehaut: far simpler: (defn key-comparer [key] (fn [a b] (compare (get a key) (get b key)))) |
| 22:23 | seangrove | (typos aside) |
| 22:23 | brehaut | bbloom: free all the points! |
| 22:23 | bbloom | seangrove: heh yeah that won't work at all |
| 22:23 | hcumberdale | good n8 |
| 22:23 | hcumberdale | ;) |
| 22:23 | seangrove | Macro would do fine though, I think |
| 22:23 | bbloom | seangrove: factory functions are going to be preferable to work with in almost every way |
| 22:25 | seangrove | Yeah, I could probably do it without too much hassle |
| 22:26 | bbloom | brehaut: I want these in core :-) https://www.refheap.com/paste/7131 |
| 22:26 | bbloom | I use sorted collections pretty frequently |
| 22:27 | bbloom | i wish that sorted collections printed differently... |
| 22:44 | am2605 | Noob paredit question: How do I remove an extra set of [], eg [[abc] [def]] - I want to remove the outer ones? |
| 22:45 | brehaut | M-s |
| 22:45 | echo-area | am2605: So it becomes [abc def]? |
| 22:45 | brehaut | with the whatsitecalled not inside one of the inner forms |
| 22:46 | am2605 | brehaut: thanks! that worked |
| 22:46 | am2605 | echo-area: I was after [abc] [def] |
| 22:46 | echo-area | Oh |
| 22:47 | nside | anyone has experience with building a runtime seesaw canvas path? |
| 22:52 | jyfl987 | is there any db represent like a tree db? |
| 22:52 | nside | here's a snippet of my path-building macro http://pastebin.com/QTCMhDsa |
| 22:52 | nside | jyfl987: what do you mean by represent? |
| 22:53 | jyfl987 | looks? act? |
| 22:53 | jyfl987 | i am sorry, english is not my native language |
| 22:53 | seangrove | jyfl987: firebase, kind of, if I understand you correctly |
| 22:53 | seangrove | I think I'm slowly recreating the declarative ui wheel here... |
| 22:54 | jyfl987 | let me explain it, do you know redis? |
| 22:54 | nside | you could serialize the entire tree in a text file |
| 22:54 | seangrove | But maybe that's not a bad thing, I don't know |
| 22:54 | nside | redis i know |
| 22:54 | jyfl987 | then you know the dict type , isnt it? |
| 22:55 | jyfl987 | but the dict's value couldnt be any complex type, what i want is something like redis's dict type which support store another dict in its value |
| 22:55 | jyfl987 | i think its like a tree |
| 22:56 | jyfl987 | when i read practical common lisp, it has the example by using lisp itself as the db |
| 22:57 | jyfl987 | but its just load/store the entire db in a file, which i think for really use case, its not a good solution |
| 22:57 | nside | by dict are you referring to a specific redis binding? |
| 23:00 | jyfl987 | wait i'll check redis's term |
| 23:00 | nside | redis itself is a key value store (probably what you're referring to as a dict) |
| 23:01 | jyfl987 | nside: its hashes in redis Term |
| 23:01 | jyfl987 | i am a python engineer, so i call all hash as dict :] |
| 23:01 | nside | what are you trying to serialize? |
| 23:02 | nside | a tree? a map? |
| 23:04 | bbloom | is there a reasonable way to get a sorted-map which is sorted by values |
| 23:06 | nside | bbloom: there's an example there http://clojuredocs.org/clojure_core/clojure.core/sorted-map-by |
| 23:06 | bbloom | nside: that example seems bugged… results doesn't change, so if you assoc a new value in, it won't keep the map sorted |
| 23:07 | nside | bbloom: that makes sense |
| 23:08 | nside | why not resort after insertion? |
| 23:10 | bbloom | nside: i'm implementing an incremental algorithm that would have to re-sort at each step |
| 23:10 | bbloom | nside: was hoping to keep the collection sorted during the process |
| 23:11 | nside | how large is your map? |
| 23:12 | bbloom | nside: i'm expecting the upper bound to be roughly 200 or so |
| 23:12 | nside | that tiny. unless that's in a render loop or something similar i'd just re-sort every time |
| 23:13 | jkkramer | bbloom: https://github.com/clojure/data.priority-map |
| 23:13 | nside | nice |
| 23:14 | bbloom | nside: it's an N^2 algorithm, so it may be up to 40,000 iterations |
| 23:14 | bbloom | nside: although it should be roughly linear in practice |
| 23:14 | bbloom | jkkramer: thanks! i'll look at that |
| 23:14 | nside | seems like that lib will work |
| 23:15 | bbloom | nside: jkkramer: I was looking at PersistentTreeMap.java and it seems like everywhere the comparer is called, both keys and values are available. it's kinda a shame that the built in maps don't support sorting by value |
| 23:16 | nside | afaik sorting by key is the common implementation for most platforms |
| 23:17 | bbloom | nside: yeah, but the underlying data structure can support both. it's just not exposed |
| 23:17 | nside | i hear you |
| 23:17 | nside | can someone help me with a very simple macro? i've posted it here http://pastebin.com/QTCMhDsa |
| 23:18 | nside | this is to create a seesaw canvas path runtime |
| 23:18 | nside | i suspect i need to delay the evaluation of move-to or something like that |
| 23:19 | bbloom | nside: is 'path a macro too? |
| 23:19 | nside | yep |
| 23:19 | nside | it's at the bottom |
| 23:19 | nside | of the paste |
| 23:19 | bbloom | nside: ah below, yeah, need these ordered correctly in your source files :-) |
| 23:20 | nside | this macro is in seesaw |
| 23:20 | nside | i might just re-implement it actually |
| 23:20 | nside | without the lookup to path-ops |
| 23:20 | bbloom | nside: what is move-to ? |
| 23:22 | nside | something that gets translated into .moveTo |
| 23:22 | bbloom | nside: why bother making it a macro? |
| 23:23 | nside | i was wondering that too |
| 23:23 | bbloom | heh |
| 23:23 | bbloom | i'd need much more context to debug this |
| 23:23 | bbloom | but in general: the fewer macros the better |
| 23:23 | nside | yeah but seesaw forces that one on me |
| 23:23 | bbloom | and if your macro gets complex at all, make a function and then call that function from the macro |
| 23:23 | jkkramer | nside: (defmacro make-path [[x y]] `(path [] (~'move-to ~x ~y))) |
| 23:24 | Raynes | Cause that makes it all okay again |
| 23:24 | Raynes | ;) |
| 23:25 | nside | jkkramer: that worked! |
| 23:25 | jkkramer | nside: it's looking up the path op by symbol, and it seems you're passing it a fully qualified symbol ('some-ns/move-to) instead of an unqualified one ('move-to) |
| 23:27 | nside | i'm new to this clojure business but i love it |
| 23:28 | nside | what ide are people using? |
| 23:36 | TimMc | nside: I don't know about IDEs, but emacs and vim are ever-popular. |
| 23:37 | nside | i'm curious about light table |
| 23:37 | TimMc | Counterclockwise (CCW) is an Eclipse plugin, if that's your poison. |
| 23:37 | nside | is anyone using it? |
| 23:37 | nside | i tried vim and CCW so far |
| 23:38 | TimMc | Light Table isn't even close to done. Interesting to play with, though. |
| 23:38 | TimMc | I won't find it useful until it has paredit. |
| 23:41 | nside | k |
| 23:41 | Raynes | Doesn't mean it isn't useful. |
| 23:41 | Raynes | If it works for you, go for it. |
| 23:43 | nside | i'm too green to use it in its current state i think |
| 23:43 | Raynes | I have some blue paint here if you need it. |
| 23:43 | Sgeo__ | Lamina + protocol-monads + ??? = PROFIT |
| 23:44 | TimMc | Sgeo__: Have you been huffing paint fumes? |
| 23:44 | nside | :) |
| 23:44 | Sgeo__ | Maybe 3 lines of code to bring Lamina into the monad world |
| 23:45 | TimMc | "Protocol monads" sounds like the wild ravings of someone on a psychedelic trip. I must say I'm intrigued, however... |
| 23:45 | Sgeo__ | TimMc, it's Jim Duey's monads implementation |
| 23:49 | wingy | i have a datomic query that should fetch all items belonging to a item type (which is of type "db.type/ref") .. what should i put as value in :where [?item :item/item-type ?item-type] |
| 23:49 | wingy | should it be the id or the item type entity? |
| 23:56 | jyfl987 | nside: i am not trying to serialize, but just store/request them like redis |
| 23:57 | nside | jyfl987: i'll need more context to help |
| 23:58 | jyfl987 | nside: redis's hash type can only store string/int as its value, right? |
| 23:58 | jyfl987 | it cant store complex type |
| 23:58 | nside | cant you send it a blob? |
| 23:59 | jyfl987 | nside: cant , because i might change partly each time just like redis's hash should be used |