2015-07-06
| 00:17 | turbofail | man. figwheel is pretty awesome |
| 04:12 | singa2015 | hi |
| 05:01 | wombawomba | I'm having a hard time splitting a vector of numbers into sequential parts (i.e. [1 2 3 5 6 8] -> [[1 2 3] [5 6] [8]]) |
| 05:01 | wombawomba | What's a good way of doing this? |
| 05:10 | namra | (doc partition) |
| 05:10 | clojurebot | "([n coll] [n step coll] [n step pad coll]); Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap. If a pad collection is supplied, use its elements as necessary to complete last partition upto n items. In case there are not enough padding elements, return a partition with less than n items." |
| 05:11 | TEttinger | ,(doc partition-by) |
| 05:11 | clojurebot | "([f] [f coll]); Applies f to each value in coll, splitting it each time f returns a new value. Returns a lazy seq of partitions. Returns a stateful transducer when no collection is provided." |
| 05:11 | namra | cool even better |
| 05:11 | justin_smith | , (partition-by (partial apply -) (partition 2 1 [1 2 3 5 6 8])) |
| 05:12 | clojurebot | (((1 2) (2 3)) ((3 5)) ((5 6)) ((6 8))) |
| 05:12 | TEttinger | ,(reductions #(= % (dec %2)) [1 2 3 5 6 8]) |
| 05:12 | clojurebot | (1 true false false false ...) |
| 05:12 | justin_smith | not the full answer, but close... |
| 05:12 | TEttinger | ,(reductions #(= % (dec %2)) 0 [1 2 3 5 6 8]) |
| 05:12 | clojurebot | (0 true false false false ...) |
| 05:12 | TEttinger | hm |
| 05:12 | justin_smith | TEttinger: that reductions is comparing true or false to a number |
| 05:12 | TEttinger | right |
| 05:13 | TEttinger | ,(reductions #(- % (dec %2)) 0 [1 2 3 5 6 8]) |
| 05:13 | clojurebot | (0 0 -1 -3 -7 ...) |
| 05:13 | TEttinger | ,(reductions #(- % (dec %2)) [1 2 3 5 6 8]) |
| 05:13 | clojurebot | (1 0 -2 -6 -11 ...) |
| 05:13 | TEttinger | hm |
| 05:14 | TEttinger | ,(map - [1 2 3 5 6 8] [2 3 5 6 8]) |
| 05:14 | clojurebot | (-1 -1 -2 -1 -2) |
| 05:16 | TEttinger | ,(let [base [1 2 3 5 6 8]] (map - base (drop (cycle base)))) |
| 05:16 | clojurebot | #<IllegalArgumentException java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.core$drop$fn__4606> |
| 05:17 | TEttinger | (doc drop) |
| 05:17 | clojurebot | "([n] [n coll]); Returns a lazy sequence of all but the first n items in coll. Returns a stateful transducer when no collection is provided." |
| 05:17 | justin_smith | ,(#(apply conj (reduce (fn [[runs part] i] (if (= i (inc (peek part))) [runs (conj part i)] [(conj runs part) [i]])) [[] [(first %)]] (rest %))) [1 2 3 5 6 8]) |
| 05:17 | clojurebot | [[1 2 3] [5 6] [8]] |
| 05:17 | TEttinger | ,(let [base [1 2 3 5 6 8]] (map - base (drop 1 (cycle base)))) |
| 05:17 | clojurebot | (-1 -1 -2 -1 -2 ...) |
| 05:17 | TEttinger | nice justin_smith! |
| 05:17 | TEttinger | (inc justin_smith) |
| 05:17 | lazybot | ⇒ 270 |
| 05:18 | justin_smith | TEttinger: fundamentally that algorithm needs two accumulators, and that's easiest to do with a reduce or loop |
| 05:18 | justin_smith | a simple lazy stream doesn't carry two states as easily |
| 05:19 | justin_smith | (though you could use lazy-seq by hand I think? Not easily though) |
| 05:21 | amalloy | justin_smith: it doesn't seem particularly hard to do lazily |
| 05:21 | justin_smith | OK |
| 05:21 | amalloy | you just have a recursive function with two arguments |
| 05:22 | wombawomba | I managed to solve it, but it seems there should be a neater approach: https://gist.github.com/aeriksson/b6f5e29a1e55fe83aa18 |
| 05:27 | rritoch | What's the normal naming convention for a clojure "hello world" application? Would it be clj-mytech-helloworld or clj-mytech-hello-world ? |
| 05:28 | oddcully | isn't the "clj" prefix only used if you wrap something with the same name? |
| 05:29 | justin_smith | wombawomba: I think a lazy-seq version is doable (I am trying), but I think my reduce is beats that |
| 05:30 | wombawomba | justin_smith: yeah seems like it :) |
| 05:32 | rritoch | oddcully: The clj prefix just helps me visually isolate clojure apps from other apps. Anyhow, the only hello world I could find used hello-world so I guess that's what I'll use. It just looks like it's a bit too wordy that way. |
| 05:37 | justin_smith | wombawomba: my lazy version, does not fit in a one liner nicely https://www.refheap.com/105337 |
| 05:37 | justin_smith | wombawomba: it works, and may be shortenable |
| 05:40 | justin_smith | wombawomba: just edited and removed some duplicated logic, still works, still too verbose https://www.refheap.com/105337 |
| 05:43 | oddcully | and somewhere else the battle rages on whether to indent with tabs or spaces... |
| 05:51 | namra | yea what is actually the prefered indentation for clojure (tabs/spaces and how many) |
| 05:52 | justin_smith | namra: two spaces |
| 05:53 | namra | k using that |
| 05:53 | oddcully | this was targeted on the creative use of `,` to indent |
| 05:53 | namra | ^ |
| 05:53 | justin_smith | oddcully: haha, yeah, total hack |
| 05:53 | oddcully | the problem: my brain read `..` |
| 05:53 | oddcully | and gone, what?! why?! |
| 05:54 | justin_smith | oddcully: I promise I didn't invent using ,, in cond |
| 05:59 | wombawomba | justin_smith: cool, thanks! |
| 05:59 | TEttinger | gaaaaah |
| 05:59 | TEttinger | ,(let [base [1 2 3 5 6 8]] (reduce (fn [stack [a b]] (if (= (- a b) -1) (conj (last stack) a) (conj (conj (last stack) a) [[b]]))) [[]] (partition 2 1 base))) |
| 06:00 | clojurebot | #error {\n :cause "java.lang.Long cannot be cast to clojure.lang.IPersistentCollection"\n :via\n [{:type java.lang.ClassCastException\n :message "java.lang.Long cannot be cast to clojure.lang.IPersistentCollection"\n :at [clojure.core$conj__4114 invoke "core.clj" 82]}]\n :trace\n [[clojure.core$conj__4114 invoke "core.clj" 82]\n [sandbox$eval389$fn__391 invoke "NO_SOURCE_FILE" 0]\n [clojure.... |
| 06:00 | TEttinger | there's no conj-in |
| 06:00 | TEttinger | so I don't know how to append to an inner element in a nested vector |
| 06:00 | TEttinger | and get back the whole vector |
| 06:00 | justin_smith | TEttinger: update-in v [idx] conj foo |
| 06:00 | justin_smith | ? |
| 06:01 | TEttinger | needs to be past the end |
| 06:01 | TEttinger | end can change |
| 06:01 | TEttinger | oh! |
| 06:01 | hyPiRion | or just (update v idx conj foo) with 1.7 |
| 06:01 | hyPiRion | yay update |
| 06:02 | TEttinger | ,(let [base [1 2 3 5 6 8]] (reduce (fn [stack [a b]] (if (= (- a b) -1) (update stack (dec (count stack)) conj a) (conj (update stack (dec (count stack)) conj a) [b]))) [[]] (partition 2 1 base))) |
| 06:02 | clojurebot | [[1 2 3] [5 5 6] [8]] |
| 06:02 | TEttinger | odd! |
| 06:03 | TEttinger | ,(let [base [1 2 3 5 6 8]] (reduce (fn [stack [a b]] (if (= (- a b) -1) (update stack (dec (count stack)) conj a) (conj (update stack (dec (count stack)) conj a) []))) [[]] (partition 2 1 base))) |
| 06:03 | clojurebot | [[1 2 3] [5 6] []] |
| 06:03 | TEttinger | hm |
| 06:05 | justin_smith | (update stack (dec (count stack)) conj a) is (conj (pop stack) (conj (peek stack) a)) |
| 06:05 | justin_smith | dunno, I kind of like the latter better |
| 06:14 | vlvx | gday |
| 06:15 | vlvx | what os do you girls use? |
| 06:16 | wasamasa | vlvx: /join ##windows |
| 06:20 | vlvx | oksu |
| 06:26 | oddcully | oh goody, clojuretv got updated |
| 06:53 | dstockto1 | last week oddcully, still waiting for day 2 |
| 06:59 | oddcully | dstockto1: seems i didn't got the memo. well cron ftw |
| 07:28 | tdammers | library/tooling question here |
| 07:29 | tdammers | I'm looking for a mocking library or framework that allows me to mock an SQL database at the query level |
| 07:29 | tdammers | is there a go-to thing for that? |
| 07:42 | rritoch | Whats the best way to load a clojure namespace from java? I called Namespace.findOrCreate(someNamespace) && then called invoke on Clojure.var(namespace,ifn) but I'm getting an illegal state exception because the function (namespace) was never loaded, though it should be available in the currentContextClassloader |
| 07:45 | rritoch | I believe I'm looking for the java equivalent of (require 'some-namespace) |
| 08:06 | puredanger | http://clojure.github.io/clojure/javadoc/clojure/java/api/Clojure.html |
| 08:11 | rritoch | puredanger: Thanks, but that's what I am using. I'm going to try "invoke |
| 08:24 | rritoch | Yay! It worked. |
| 08:28 | rritoch | https://github.com/rritoch/clj-osgi-namespaces > is now successfully calling a clojure "loader" by specifying the namespace in the bundle "Clojure-Activator" header, the activator must have start [ctx] and stop [ctx] functions similar to a regular java activator or else there will be some problems. |
| 08:29 | rritoch | No way to know yet if the "Clojure-Imports" and "Clojure-Exports" headers are working yet though. |
| 08:33 | TimMc | $mail arohner In your post "Why Clojure Is Awesome, Without Using the L-Word" I do think this line is a bit silly: "A person has identity, because they have a name." -- people's names change too. :-) |
| 08:33 | lazybot | Message saved. |
| 08:39 | rritoch | I uploaded the hello world app to > https://github.com/rritoch/clj-osgi-namespaces-hello-world which is 100% java free and executes with the help of the clj-osgi-namespaces bundle |
| 09:04 | aztak | wrong channel probably - but I'll try.. anyone using Spacemacs to hack Clojure and have the cider-debug stuff working? :) |
| 09:05 | aztak | I can instrument a method, but I can't act using the n,i,c etc. keys when a break-point gets activated. I suspect it's related to evil-bindings in Spacemacs. |
| 09:06 | luxbock | aztak: yeah you have to switch to emacs-state to use it |
| 09:07 | aztak | luxbock: really? you know if it's something that will be fixed or if it's something that can't be changed because of how cider is implemented? |
| 09:07 | luxbock | aztak: I believe there is an issue for it |
| 09:07 | luxbock | although it is for emacs lisp |
| 09:08 | aztak | luxbock: thanks for the info - I'll give it a try :) |
| 09:08 | luxbock | it is rather annoying so I've almost got my hands dirty a few times but everytime I get that itch I'm usually working on something else so never got around to it |
| 09:08 | aztak | C-z to enter emacs-state, and then ?? to switch back? :) |
| 09:09 | wasamasa | C-z again |
| 09:10 | aztak | ah, there's '\' to execute on cmd in emacs-state. |
| 09:10 | aztak | wasamasa: thanks! |
| 09:10 | wasamasa | aztak: spacemacs has a gitter channel for support |
| 09:10 | wasamasa | aztak: what you were asking for is part of evil as is, so I've answered it |
| 09:11 | aztak | wasamasa: I know - I posted the same question there an hour ago, but everyone seems to be sleeping right now *grin* |
| 09:11 | wasamasa | aztak: as for the specific issue with keys, perhaps you can make use of one my tweaks for edebug (which is what the cider debugger is modeled after) |
| 09:11 | wasamasa | aztak: https://github.com/wasamasa/dotemacs/blob/master/init.org#keymap-hacking |
| 09:13 | aztak | wasamasa: wow, that's a lot of good stuff there.. I'll bookmark that page - thanks :) |
| 09:13 | aztak | and the emacs-state switcharoo solved the issue with cider-debug. Thanks guys! |
| 09:24 | wasamasa | aztak: well, that's my emacs config |
| 09:24 | wasamasa | aztak: feel free to favourite it |
| 10:06 | rritoch | aztak: There are lots of updates to the osgi system I'm working on @ https://github.com/rritoch/clj-osgi-namespaces , The hello world app is functional, my next stage of development is to test the import/export functionality by using the exports of hello world in a hello-world-user bundle. |
| 10:06 | rritoch | Hmm, seems he's gone. |
| 10:08 | rritoch | Is it ok if I lazybot mail him? |
| 10:32 | rritoch | Anyhow, the imports and exports do seem to be working, it's time to send this off to the clojure mailing list so others can use (break) it. I'm sure the tickets will pile up on this one since OSGI itself isn't easy to use. |
| 11:18 | crocket | Is clojure ok for a command line utility that's executed every 5 minutes? |
| 11:18 | crocket | Not sure how I would write a command line utility with clojure. |
| 11:19 | justin_smith | crocket: -main will get any args provided to your uberjar |
| 11:20 | justin_smith | and stdin and stdout are straightforward enough (via *in* and *out*) |
| 11:20 | justin_smith | though for a repeated task you may want to consider just leaving the clj process running with a timed task |
| 11:25 | crocket | justin_smith, Does JVM not use a lot of memory for a simple DDNS client that updates DNS entires every 5 minutes? |
| 11:26 | crocket | It would consume at least 128MB after optimization. |
| 11:27 | justin_smith | crocket: the memory usage is another consideration. Just a nitpick: the memory usage is not the JVM's fault. It's 100% clojure's fault. |
| 11:27 | crocket | On the other hand, Gogs, written in Go, consumes 32MB of OS memory. |
| 11:27 | crocket | Gogs is ridiculously light. |
| 11:27 | justin_smith | Clojure is not optimized for memory usage, at all |
| 11:28 | crocket | I'd consider using pixie, but it is not mature enough yet. |
| 11:28 | crocket | It's not even ready for a simple DDNS client for home. |
| 11:28 | crocket | I'm stuck with a nodejs DDNS client I wrote a year ago. |
| 11:29 | crocket | justin_smith, What is clojure optimized for? |
| 11:29 | crocket | A large web application? |
| 11:29 | justin_smith | crocket: correctness, speed |
| 11:29 | justin_smith | those things are good for large web apps, sure. |
| 11:29 | crocket | For clojure to suit CLI apps, it needs to consume little memory and start up fast. |
| 11:30 | crocket | pixie fills that niche. |
| 11:30 | justin_smith | right, and clojure is not good at either of those things |
| 11:30 | crocket | Do you know pixie? |
| 11:30 | justin_smith | yes, I've played with it quite a bit |
| 11:31 | crocket | I plan to pick up Racket for that... |
| 11:31 | justin_smith | crocket: if you want a functional language that starts up fast and uses little RAM, OCaml is probably your best bet. |
| 11:31 | justin_smith | unless you start using the janestreet libs, but you don't need those |
| 11:31 | crocket | Janestreet is known for OCaml. |
| 11:32 | justin_smith | yes, and their libs are amazingly huge |
| 11:32 | crocket | It reflects their organizational structure. |
| 11:32 | crocket | What was the relevant law? |
| 11:33 | crocket | Right, conway's law |
| 11:33 | crocket | huge, slow, etc... |
| 11:34 | crocket | justin_smith, I wonder what I'll use clojure for in the future. |
| 11:34 | crocket | Probably some AIs |
| 11:35 | wasamasa | lol |
| 11:35 | wasamasa | work, really |
| 11:37 | rritoch | crocket: Why would you want to relaunch a java/clojure app at a certain interval? There is a lot of overhead to starting the JVM and you can just leave it running, in this case instead of a cron you would probably use a ExecutorService |
| 11:40 | crocket | rritoch, As I said above, a simple DDNS client in clojure would consume at least 128MB. |
| 11:40 | crocket | Gogs consumes 32MB. |
| 11:41 | justin_smith | crocket: sure, but none of us here are going to be able to fix that any time soon, and I don't think the heap usage is even on the agenda for the clojure.core dev team as something that needs fixing. |
| 11:42 | rritoch | crocket: 128MB is nothing, considering Firefox uses anywhere from 1GB to 2GB |
| 11:42 | crocket | rritoch, Except it's a simple DDNS client that should occupy less than 2MB. |
| 11:43 | crocket | My server doesn't run firefox. |
| 11:43 | justin_smith | if that's your constraint, then of course you can't use clojure, (unless maybe you port your node version to cljs?) |
| 11:44 | markmm | Are you running on embedded device or some memory constraint environment? |
| 11:44 | rritoch | crocket: Are you using leiningen? |
| 11:44 | crocket | rritoch, I usually do |
| 11:44 | crocket | markmm, no |
| 11:45 | crocket | But, I appreciate little memory usage. |
| 11:45 | justin_smith | crocket: lein should not be used at runtime, it's a dev/build tool |
| 11:45 | crocket | I appreciate how little memory Gogs consumes. |
| 11:45 | justin_smith | and not using it will reduce your ram usage and startup time quite a bit |
| 11:45 | wasamasa | markmm: he's in the trolling environment |
| 11:45 | crocket | It is fast and light. |
| 11:45 | crocket | justin_smith, I won't use lein in production. |
| 11:45 | rritoch | crocket: So try setting :jvm-opts ["-Xms:2m"] that should reduce JVM down to 2m on startup |
| 11:46 | justin_smith | but clojure simply doesn't fit in 2m |
| 11:46 | markmm | crocket: ok I see, try C then |
| 11:46 | rritoch | justin_smith: That's assuming your using all of clojure |
| 11:46 | wasamasa | markmm: to satisfy all of its constraints you must present a fast, functional, memory-cautious and elegant language which ideally spits out binary executables that start up fast and comes with loads of libraries and a wonderful community |
| 11:46 | rritoch | justin_smith: Either way, starting at 2m which is his goal, it will expand up if clojure really needs more space. |
| 11:47 | justin_smith | rritoch: if you are willing to accept the huge perf hit of the lazy-loading branch, you can do that I guess |
| 11:47 | wasamasa | markmm: I did get pretty close to that, but then they started an offtopic comment how they dislike design by committee |
| 11:47 | wasamasa | markmm: so I'm pretty sure it's just a troll |
| 11:47 | rritoch | justin_smith: I'm perfectly happy with a 128MB footprint, it's crocket who's looking for a micro-environment, and changing java options is one way to do that. |
| 11:48 | justin_smith | rritoch: but the way clojure operates (always loading it's full lang / compiler) undo any benefit that setting would give. Unless you use the lazy-loading branch and accept the degraded performance that goes with that. |
| 11:49 | markmm | wasamasa: Ah has this been going on a while |
| 11:49 | wasamasa | markmm: yeah, in other channels as well |
| 11:50 | wasamasa | markmm: including #emacs and #scheme |
| 11:56 | crocket | wasamasa, Are you a troll that trolls other trolls? |
| 11:59 | TimMc | crocket: The only solution is to write your own language. |
| 11:59 | crocket | It's weird |
| 11:59 | crocket | If I point out weakness of clojure in #clojure, it's considered trolling. |
| 12:00 | TimMc | This *is* how new languages get created, you know. |
| 12:00 | crocket | If I point out weakness of something in #something, it's also considered trolling. |
| 12:00 | crocket | TimMc, That's how pixie is being created as far as I know. |
| 12:00 | justin_smith | crocket: you can point out the weakness, then we acknowledge it... it's weird when the conversation is expected to continue? I mean what can we offer other than other languages you could use? |
| 12:00 | wasamasa | crocket: you could, like, accept that no language is perfect? |
| 12:00 | crocket | I know that no langauge is perfect. |
| 12:01 | crocket | I was just following through the conversation. |
| 12:01 | wasamasa | then just stop, it's getting tiring |
| 12:02 | crocket | The problem is that pointing out weakness of something seems to invalidate people's ego. |
| 12:02 | rritoch | justin_smith: Well, starting with "-Xms2m" my repl still uses 94M to 104M |
| 12:03 | justin_smith | rritoch: yeah, that was kind of what I meant. The small Xms is just going to slow startup, not prevent the repl from using more RAM. Is that a lein repl or a clojure.main repl btw? |
| 12:03 | wasamasa | crocket: it's like you've got nothing better to discuss than weaknesses of languages |
| 12:03 | rritoch | justin_smith: lein repl |
| 12:04 | crocket | wasamasa, That's your perception, but not my intention. |
| 12:04 | wasamasa | crocket: I have logs of you doing this for weeks |
| 12:04 | wasamasa | crocket: so, nope |
| 12:04 | crocket | wasamasa, What do you talk about on IRC? |
| 12:04 | rritoch | Bah |
| 12:04 | rritoch | NEVER trust the garbage collector! |
| 12:05 | crocket | The JVM garbage collector doesn't return memory to OS. |
| 12:05 | wasamasa | ... |
| 12:05 | rritoch | Memory usage before garbage collection, 94M, after 101M, wtf |
| 12:05 | rritoch | That was running (System/gc) |
| 12:06 | wasamasa | crocket: why don't you just lurk and observe |
| 12:06 | wasamasa | crocket: like, most people on IRC |
| 12:06 | crocket | wasamasa, I do not commute to IRC to observe. |
| 12:07 | crocket | I observe when there are clearly things to learn. |
| 12:07 | justin_smith | rritoch: crocket: 75m for a non-lein clojure.core 1.7 repl |
| 12:08 | crocket | wasamasa, I think you're over-reacting. |
| 12:08 | rritoch | justin_smith: And after (System/gc)? lol |
| 12:09 | justin_smith | rritoch: also, remember that "lein repl" creates two processes, and you should be counting them both |
| 12:09 | justin_smith | rritoch: 93m after gc :) |
| 12:10 | crocket | Again, the garbage collector cleans up garbages inside JVM. |
| 12:10 | rritoch | justin_smith: Yeah, I'll never trust the garbage collector again. |
| 12:10 | crocket | JVM itself doesn't return memory to OS. |
| 12:10 | justin_smith | rritoch: the gc is optimized for runtim perf by default, not neccessarily minimizing heap usage |
| 12:10 | justin_smith | rritoch: it reorganizes things in memory so that future processing happens faster |
| 12:10 | justin_smith | even if that means using more RAM |
| 12:10 | crocket | If you want a runtime environment that returns memory to OS, JVM is not it, yet. |
| 12:11 | justin_smith | crocket: likely never will be. It's not a community proirity for the JVM or for Clojure. |
| 12:11 | crocket | I think server markets were the priority for Oracle. |
| 12:13 | crocket | wasamasa, I just wonder what you would get by observing conversations in any IRC channel for extended periods of time. |
| 12:13 | crocket | The profit lies in bidirectional communication. |
| 12:14 | justin_smith | crocket: well, Oracle is only the most recent owner of Java, but yeah, the Java project has been run by various companies that sell and support large complex systems with a lot of resources, and for a long time has been optimized for these sorts of environments |
| 12:14 | justin_smith | crocket: they are optimizing for the very common case where RAM chips are cheaper than the lost perf from using less RAM |
| 12:14 | crocket | I guess I'll keep learning languages. |
| 12:15 | justin_smith | as I mentioned before, OCaml does a great job of doing awesome perf, with low heap usage, in a sane functional language |
| 12:15 | crocket | justin_smith, That makes sense if your program always uses a lot of RAM most of the time. |
| 12:15 | wasamasa | justin_smith: that might be the case, but it's not enough to satisfy crocket |
| 12:16 | justin_smith | crocket: the point is that there are generic methods to speed up performance by using more RAM. The JVM exploits these |
| 12:17 | justin_smith | crocket: there are other methods that get speed by using less RAM, OCaml takes that approach more often |
| 12:17 | crocket | I think performance is more than just speed. |
| 12:18 | justin_smith | crocket: do tell |
| 12:18 | crocket | performance metrics include memory usage, speed, etc... |
| 12:19 | crocket | I think Racket and OCaml will just do fine for my small CLI scripts. |
| 12:19 | justin_smith | racket's pretty slow, but that likely doesn't matter for your use case, yeah. |
| 12:20 | crocket | Racket's still noticeably faster then python 3. |
| 12:20 | crocket | So, it still satisfies my performance requirements. |
| 12:22 | puredanger | it's almost like a single language can't satisfy every possible application |
| 12:22 | wasamasa | unbelievable, is it |
| 12:22 | chouser | puredanger: yet |
| 12:22 | puredanger | YET |
| 12:22 | chouser | :-) |
| 12:22 | wasamasa | not every language can look like clojure either |
| 12:22 | TimMc | crocket: You should use gherkin. |
| 12:22 | justin_smith | crocket: for comparison, I'm working on a corparate app that does large scale data crunching (working on the parallelizing / multi host part right now, using onyx). We really don't care how much RAM is used, but if we can make a task take only an hour instead of 7 hours to do a computation, that would be awesome. |
| 12:22 | crocket | TimMc, Why? |
| 12:22 | TimMc | Fast + parens. |
| 12:22 | wasamasa | lol |
| 12:23 | crocket | TimMc, Parens themselves do not interest me much. |
| 12:23 | TimMc | https://github.com/alandipert/gherkin |
| 12:23 | TimMc | You know what I mean. |
| 12:23 | wasamasa | TimMc: please don't troll back |
| 12:23 | markmm | crocket: You looked at Rust? |
| 12:23 | TimMc | Actually, I have no idea if it's fast, but it compiles to bash and that's not too shabby. :-P |
| 12:24 | crocket | markmm, yes |
| 12:24 | justin_smith | TimMc: depends what "fast" means - low startup time, sure, any sort of perf speed? not likely |
| 12:24 | markmm | crocket: It's supposed to be as fast as C++ and has nice modern features |
| 12:25 | markmm | crocket: I didn't like all the pointery stuff |
| 12:25 | crocket | markmm, I wouldn't use it over pixie. |
| 12:25 | crocket | I'm acutually waiting for pixie to satisfy my quick scripting needs. |
| 12:25 | justin_smith | crocket: what's pixie lacking then? |
| 12:25 | TimMc | Waiting is a good strategy. |
| 12:26 | crocket | justin_smith, pixie is still very experimental. |
| 12:26 | crocket | It doesn't even have a proper documentation. |
| 12:26 | crocket | It is a new language. |
| 12:26 | justin_smith | sounds like OCaml or Racket are you best bets then, yeah |
| 12:26 | crocket | I think it'll take 1-2 years for pixie to become useable for average programmers. |
| 12:26 | wasamasa | lol |
| 12:27 | crocket | Until then, pixie is for pioneers. |
| 12:27 | wasamasa | does it even have libraries? |
| 12:27 | wasamasa | or interop abilities with python? |
| 12:27 | justin_smith | wasamasa: it can use C libs directly |
| 12:27 | justin_smith | wasamasa: no, no python interop, only C / system interop |
| 12:27 | wasamasa | well then |
| 12:27 | justin_smith | there is no python at pixie runtime, it's only used to generate the vm |
| 12:28 | crocket | RPython was used to bootstrap pixie. |
| 12:28 | justin_smith | still is |
| 12:28 | justin_smith | unless pixie started self-hosting while I wasn't looking |
| 12:28 | crocket | Will pixie start self-hosting? |
| 12:29 | justin_smith | I doubt it |
| 12:29 | justin_smith | it's not on their list of goals at least |
| 12:29 | crocket | The main dev seemed to be fond of RPython. |
| 12:29 | wasamasa | https://github.com/pixie-lang/pixie/issues/338 |
| 12:29 | wasamasa | why doesn't this surprise me at all |
| 12:30 | crocket | I still think PyPy tool chain is better than bootstraping on C. |
| 12:30 | crocket | or LLVM |
| 12:30 | crocket | wasamasa, You're very good at tracking other people's lives. |
| 12:30 | crocket | I dare you to be better than tracking my life. |
| 12:31 | crocket | wasamasa, You say I'm a troll, but your behaviors are more problematic than you think I am. |
| 12:31 | wasamasa | crocket: I click its issue tracker and see a ticket by you at the very top |
| 12:32 | xemdetia | that is an awful bug title |
| 12:32 | wasamasa | inorite |
| 12:32 | xemdetia | I have threatened physical violence at people for less |
| 12:32 | crocket | wasamasa, Is talking about personal behaviors your main topic on IRC? |
| 12:33 | crocket | issue is more than a list of bugs. |
| 12:33 | TimMc | Man, I'm just going to ignore the both of you. Don't care if you're trolls, just not interested. |
| 12:34 | crocket | wasamasa, If you keep pointing out my personal behaviors at every opportunity, I'll have to ignore you. |
| 12:34 | xemdetia | forgive me TimMc I am in a release stretch |
| 12:34 | xemdetia | my temper is about as cool as a volcano |
| 12:37 | wasamasa | \o/ |
| 12:37 | uris77 | is there a way to copy an sexp in emacs? |
| 12:38 | uris77 | a keybinding? |
| 12:38 | TimMc | xemdetia: Haha, no worries! Smite away. |
| 12:51 | amalloy | uris77: you can select a sexp with C-M-SPC |
| 12:51 | amalloy | and then copy as usual with M-w |
| 12:52 | Bronsa | TimMc: ha, me too |
| 12:52 | Bronsa | I do C-M-k C-y |
| 12:53 | TimMc | C-y? I do C-/ |
| 12:53 | TimMc | (it puts me back where I started) |
| 12:54 | Bronsa | oh, nice |
| 12:54 | TimMc | but really I should learn how to package this up into a single keybinding |
| 12:57 | uris77 | amalloy: thank you |
| 12:58 | uris77 | Bronsa: I don't want to cut-paste, but thank you. That is also handy :) |
| 13:02 | wasamasa | uris77: you could mark the sexp at point, then use M-w |
| 13:03 | TimMc | uris77: It's the same number of keystrokes. :-P |
| 13:05 | uris77 | TinMc: yes |
| 13:05 | uris77 | but I really wanted to copy, didn't want to cut |
| 13:05 | uris77 | but thank you, I'll need to cut-paste too :) |
| 13:05 | justin_smith | uris77: in evil mode I can do it with "y%" |
| 13:05 | justin_smith | (inc evil) |
| 13:05 | lazybot | ⇒ 0 |
| 13:05 | justin_smith | haha |
| 13:05 | TimMc | It ends up on your clipboard either way... and it doesn't result in your buffer being any different afterwards... |
| 13:06 | uris77 | TimMc: yes, you are right. |
| 13:06 | justin_smith | I think evil, as usual, wins the keybinding golf contest |
| 13:07 | uris77 | it comes down to muscle memory. I'm trying to do it the 'Emacs Way' as much as possible. (I am a long time vim user) |
| 13:07 | justin_smith | uris77: long time emacser here, evil saves my wrists so much pain |
| 13:08 | wasamasa | uris77: the emacs way is writing your own crappy command for it |
| 13:08 | wasamasa | uris77: or rather, customizing generally (which includes using some other way of inputting it than a vanilla install would, including evil) |
| 13:10 | justin_smith | wasamasa: evil isn't crappy :P |
| 13:10 | wasamasa | justin_smith: I didn't write that |
| 13:11 | justin_smith | wasamasa: perhaps I was over-applying some transitive logic to your statements |
| 13:11 | wasamasa | justin_smith: tune down the aggressiveness of your inferer? |
| 13:11 | justin_smith | yeah, probably :) |
| 13:11 | uris77 | your type inference is buggy |
| 13:11 | justin_smith | haha |
| 13:11 | xemdetia | I just abuse emacs keybindings to my function keys |
| 13:12 | xemdetia | so I can program like it's 1974 |
| 13:12 | justin_smith | xemdetia: as if emacs was brand new, and vi doesn't exist yet, and most people are using line editors? |
| 13:12 | xemdetia | justin_smith, yes |
| 13:13 | xemdetia | but really I don't know why people don't use function keys for that class of moderately used commands |
| 13:13 | xemdetia | things like f10 for hide-show-toggle |
| 13:13 | xemdetia | is really nice |
| 13:14 | justin_smith | xemdetia: because they are so far from the home row (that's my excuse at least) |
| 13:14 | justin_smith | perhaps if my fingers were longer... |
| 13:14 | TimMc | You just need longer tentacles: http://fc04.deviantart.net/fs71/i/2011/029/8/3/emacs_user_at_work_by_earlcolour-d38aj2x.jpg |
| 13:14 | xemdetia | to be fair my hands are massive |
| 13:15 | justin_smith | (inc TimMc) |
| 13:15 | lazybot | ⇒ 100 |
| 13:15 | xemdetia | I have an external keyboard in front of my laptop and I can use the touchpad with the heels of my palms resting on the external keyboard below the space bar |
| 13:15 | TimMc | hha wow |
| 13:16 | xemdetia | I do have a slim external though compared to most |
| 13:16 | justin_smith | xemdetia: kinesis freestyle 2 (the one that's split in half) with a trackball in the middle of the two halves, with the two halves of the keyboard tented |
| 13:17 | xemdetia | justin_smith, belkin $10 special straight from a dumpster, glazed with two unique spills of coffee |
| 13:17 | justin_smith | TimMc: it's funny that the caption says emacs user, but the mug has a blender logo |
| 13:17 | justin_smith | xemdetia: sweet |
| 13:19 | xemdetia | but yeah I love my function keys |
| 13:19 | justin_smith | xemdetia: I have a half-baked 1/4 completed project that ties a midi controller to emacs |
| 13:19 | xemdetia | f3 for grep-find, f4 for neotree, f6 for magit status and f10 for hs |
| 13:19 | xemdetia | that I remember off the top of my head |
| 13:20 | justin_smith | xemdetia: so I can use things like my foot pedal board, or a drum pad controller for functions... |
| 13:20 | bja | I eventually gave up on function keys for space and space space as leader/localleader |
| 13:20 | xemdetia | justin_smith, I always hear of people trying to use foot pedals for things but I just can't figure out what key I would put on it |
| 13:20 | justin_smith | xemdetia: one example - a rocker pedal as absolute mode scroll bar |
| 13:21 | xemdetia | yeah but generally at that point I shift back to coffee/mouse interface and scroll |
| 13:21 | justin_smith | for evil, a footpad for escape, and another for : |
| 13:21 | justin_smith | xemdetia: foot pedals for control / alt / shift |
| 13:21 | justin_smith | like a clutch for emacs |
| 13:22 | justin_smith | this is all theoretical for now, maybe it's totally unusable :P |
| 13:22 | xemdetia | yeah but honestly compared to some people I really don't use that many extended key chords that not just using a finger to do it wouldn't be adequate |
| 13:22 | xemdetia | that's the use case I've struggled with |
| 13:22 | justin_smith | one of those "it's the weekend and I had way too much coffee and wouldn't this be neat" kind of things |
| 13:22 | xemdetia | yeah |
| 13:22 | xemdetia | I mean you have things like C-x v l for source control log |
| 13:23 | xemdetia | so you just hit the pedal for one key press? |
| 13:23 | xemdetia | my brain can't do that |
| 13:25 | blakew | Anyone using Wildfly? Or just me. =P |
| 13:25 | xemdetia | I feel like rigging up some sort of external pad for extra functions to slap and maybe a large lever for save would be more effective than a pedal and more appealing |
| 13:26 | justin_smith | I often talk about how awesome component is, but I just found another way it is awesome. I am adding onyx to my webapp, and by defining an alternate (optional) main namespace, I can use the same uberjar as used for the http server, with a different set of components, reusing the shared functionality and config. Win! |
| 13:26 | bja | blakew. I'm using undertow |
| 13:26 | bja | not full on wildfly though |
| 13:27 | justin_smith | xemdetia: sure, the midi thing would work the same with floor or table devices, the rest is just wiring up the bindings. |
| 13:28 | blakew | bja: Hmmm. I might check it out. I'm trying to debug a Widlfly situation and finding my Clojure WAR, when I deploy it, ends up with Wildfly routing 8080->8443 (and not working). Just trying to tease out what the problem is. (I've been deploying for a while.) |
| 13:29 | justin_smith | blakew: is this via immutant? |
| 13:29 | bja | blakew, I've been meaning to move to this: http://immutant.org/documentation/2.0.0-beta1/apidoc/immutant.web.html but am currently running via https://github.com/piranha/ring-undertow-adapter |
| 13:30 | blakew | justin_smith: Nah. I just lein ring uberwar my compojure app. |
| 13:30 | blakew | bja: Yeah, I'm planning to switch to immutant. |
| 13:30 | justin_smith | ahh, so just using it like it was any other app container, interesting |
| 13:30 | bja | fwiw, ring-undertow-adapter does seem to work well, but I'm deploying an uberjar proxied behind nginx |
| 13:30 | blakew | bja: Good to know. |
| 13:31 | blakew | justin_smith: Yeah, it's been working fine. But I've got an issue and have been trying to rollback to a working situation, and realize I don't know enough about Wildfly to know how to debug. |
| 13:32 | justin_smith | blakew: I never really got tomcat working reliably with hotswaps, and just gave in and restarted the app when redeploying. It felt like a defeat, but it worked. |
| 13:32 | justin_smith | not that immutant has the same issues, and for all I know the fix might have been simple but something I haven't tried yet |
| 13:33 | bja | heh, just checking my codebase and noticed my new-web-server constructor for my wildfly component has a docstring of "Creates an HTTP-Kit component with an injectable ring handler" |
| 13:33 | justin_smith | ~comments |
| 13:33 | clojurebot | comments is http://www.cc.gatech.edu/computing/classes/cs2360/ghall/style/commenting.html |
| 13:33 | justin_smith | clojurebot: broken link, yo |
| 13:33 | clojurebot | excusez-moi |
| 13:33 | blakew | heh |
| 13:34 | blakew | justin_smith: We've been live-swapping with Wildfly for months without trouble. |
| 13:35 | justin_smith | nice! |
| 13:36 | jcrossley3 | blakew: are you seeing the problem on a vanilla WF install? what version? |
| 13:36 | TimMc | justin_smith: Hmm, you think it was originally a joke about Blender? |
| 13:37 | blakew | jcrossley3: I was using clean Wildfly 8.2, then I tried 9. I'm not 100% sure what I'm using on my other servers. |
| 13:37 | justin_smith | TimMc: they do have crazy keybindings... but blender is also a tool that would be used to create an image like that regardless of the target of its mockery... |
| 13:37 | TimMc | haha |
| 13:37 | justin_smith | ~blender |is| the emacs of 3d |
| 13:37 | clojurebot | Ik begrijp |
| 13:37 | TimMc | Or it could be... "OK, I need to put something on the mug, need a logo... here we go." |
| 13:38 | justin_smith | yeah |
| 13:39 | xemdetia | blender really is the emacs of 3d though |
| 13:39 | xemdetia | so much python doing all sorts of magic |
| 13:39 | justin_smith | and the wacky keybindings (though more chaining than chording I guess) |
| 13:39 | jcrossley3 | blakew: not sure off the top of my head, but do you by chance have a security-constraint in your war's web.xml that might be triggering the reroute? |
| 13:42 | blakew | jcrossley3: Maybe. It's root and it looks like root ends up covered by the default. |
| 13:43 | blakew | Wait...could this be an upgraded lein thing? |
| 13:44 | jcrossley3 | blakew: not sure, but maybe a later version is adding the security constraint to the web.xml it produces? |
| 13:56 | blakew | jcrossley3: Yeah, I think that's gotta be it. |
| 13:56 | jcrossley3 | blakew: easy enough to check. remove the <security-constraint> :) |
| 13:57 | blakew | jcrossley3: Heh. Can I do that inside the WAR? |
| 13:58 | jcrossley3 | blakew: well, unpack it, edit web.xml and repack. emacs makes that trivial, if you're using it. |
| 13:59 | blakew | jcrossley3: Dammit. If it's that, then how come I get it on old versions? They're all using the project.cljs used to create them previously, so they should work. |
| 13:59 | blakew | I guess the real question is what creates that web.xml? |
| 14:01 | jcrossley3 | lein-ring, but it doesn't appear to add a security-constraint: https://github.com/weavejester/lein-ring/blob/master/src/leiningen/ring/war.clj#L103 |
| 14:02 | jcrossley3 | blakew: i would start by confirming you actually have one in your web.xml |
| 14:02 | blakew | jcrossley3: I do. And I've taken out and am trying to redploy. |
| 14:06 | blakew | Welp, that fixed it. So...now I just gotta figure out how I'm putting it in there. |
| 14:07 | clojer_ | A Reagent app with :optimizations :advanced produces a 446Kb file containing React 13 minified but the Reagent code isn't minified. Are there any other settings I need to get the file size down? |
| 14:18 | justin_smith | clojer_: you may get a better answer on #clojurescript |
| 14:21 | dnolen | clojer_: doesn't really sounds plausible, what build tool? |
| 14:59 | seangrove | Anyone have a lobsters invite? |
| 15:04 | blakew | jcrossley3-away: OK, my web.xml is the thing with the security constraint. I've been using the same one for 5 months but now it's a problem. :-/ |
| 15:25 | joschka | TL;DR can you look at my first clojure code and tell me what you think? http://sprunge.us/FLgK Hi there, I just began learning clojure and started by solving an easy to solve problem in clojure. I wrote most of the functions in a recursive manner, trying to stick to the functional coding style as close as possible. My question is: should I do this everywhere in clojure? Does this benefit performance or is it |
| 15:25 | joschka | generally better to write in a 'procedural' style? |
| 15:27 | amalloy | cfleming: the cursive plugin is refusing to load, saying the version i'm using has expired and i should download a new one. this seems like a crazy policy for a plugin to have, but i'm fairly sure you are not crazy so i would love it if you could tell me why this happens |
| 15:29 | justin_smith | joschka: in general we don't often write recursive code in clojure, we have nice higher level functions that wrap that sort of thing (reduce, map, iterate) |
| 15:29 | justin_smith | joschka: in particular, most code that is recursive and takes the rest of some seq at each step can likely be expressed as a map or reduce |
| 15:30 | amalloy | you also have this pattern repeated twice: (if x true (if y false z)), which is better written as (or x (and (not y) z)) |
| 15:30 | joschka | thank you this kind of advice actually helps me a lot |
| 15:31 | justin_smith | joschka: additionally, the rare code that needs to be directly recursive should, if possible, use recur instead of self calls, clojure does not do self tail call optimization automatically, but only when explicitly invoked with recur |
| 15:31 | joschka | can you point me to any well written, easy to entry clojure project that could teach me a couple of good techniques? |
| 15:32 | amalloy | here is some code you should probably never write: (if (= 0 (count seq)) ...). if you are counting a seq, you can't process it lazily; and if you're counting it N times you are turning an O(N) algorithm into an O(N^2) one |
| 15:32 | justin_smith | joschka: 4clojure exercises introduce a bunch of good basics, and if you follow some of the more active users you will see good solutions |
| 15:33 | justin_smith | amalloy: joschka: yeah, in the same paste you have (empty? sq) which is the right way to do it |
| 15:33 | joschka | justin_smith: yeah, I probably recognized this myself later on in the process :P |
| 15:36 | blakew | So, I'm getting warnings because I defined a database namespace with an "update" command. Actually, I get two: The first apparently because I'm using monger.collection, and it has its own "update" function, then in myown.mongo, because it has an "update" function, too. |
| 15:37 | blakew | Thoughts? Bad form? OK because for everyone who uses them, it's always "alias/update"? |
| 15:38 | amalloy | it's a little tacky to share a name with a core function, but not a big problem. you should do so in a way that doesn't produce a warning, though, by managing your (ns) better |
| 15:38 | Bronsa | blakew: exclude update from :refer-clojure and don't refer to monger.collection |
| 15:39 | blakew | Bronsa: Is ":refer-clojure" implicit? |
| 15:40 | blakew | Bronsa: Also, I only refer to monger.collection with an alias. I mean, I do need the functionality, so I have "monger.collection :as mc" in a require. No :refer. |
| 15:40 | Bronsa | blakew: all of clojure.core is implicitly refer'ed, to avoid referring to one of its sym you have to use :refer-clojure, like so: (ns my-ns (:refer-clojure :exclude [update])) |
| 15:41 | justin_smith | blakew: you'll get that warning if monger.collection gets loaded. If you make a replacement that doesn't define "update" or at least uses an :exclude in the ns form I would use it :P |
| 15:41 | Bronsa | blakew: then it's possible that the warning comes from monger.collection itself, it probably defines update but doesn't exclude it from clojure.core. |
| 15:42 | Bronsa | blakew: update was added to clojure.core in 1.7, many libs defined their own without any need to exclude it, nothing you can do about it unfortunately |
| 15:42 | justin_smith | Bronsa: yeah, that is definitely the case (get the same warning in our app right now) |
| 15:43 | blakew | Bronsa, justin_smith: Aha...thanks. |
| 15:46 | blakew | I am finding some odd stuff with 1.7. |
| 15:54 | puredanger | if you're the first to find the duck wearing a hat, you get a star |
| 16:26 | blakew | I'd like a star. |
| 16:28 | blakew | I lost one when our chef died. |
| 16:28 | seangrove | "#clojure - where the chat is indistinguishable from markov bot chatter" |
| 16:28 | dmitrig01 | justin_smith: instead of (def queen-indicator (first (seq "*"))) you can do just (def queen-indicator \*) |
| 16:30 | dmitrig01 | justin_smith: also for valid?, you can do (defn valid? [[head & tail]] …), that way you save yourself from manually parsing that out |
| 16:31 | justin_smith | dmitrig01: you probably meant to direct those to joschka |
| 16:31 | dmitrig01 | ack, you’re right :-) |
| 16:31 | dmitrig01 | joschka: ^ |
| 16:31 | joschka | dmitrig01: thanks :P |
| 16:32 | dmitrig01 | (+ 1 x) is shorter as (inc x) |
| 16:33 | dmitrig01 | (if (= 0 (count seq)) nil (col seq 0)) can be more concisely expressed as (when-not (empty? seq) (col seq 0)) |
| 16:33 | joschka | dmitrig01: yes amalloy told me about that one :P |
| 16:34 | dmitrig01 | empty? yes - but i’m pointing you to when-not as well :-) |
| 16:34 | amalloy | dmitrig01: that is much better written as (when (seq xs) (col xs 0)) |
| 16:34 | amalloy | combining not and empty? is a sin |
| 16:35 | dmitrig01 | ah, you’re right |
| 16:35 | dmitrig01 | joschka: also for your (cond) inside pair-diag?, you can just use (or (= y1 y2) (= x1 x2) (= 1 (/ (abs (- x2 x1)) (abs (- y2 y1)))) |
| 16:36 | joschka | yes probably better |
| 16:40 | Mongey_1 | hey, am I supposed to require something to use rename-keys ? |
| 16:40 | dmitrig01 | joschka: overall - nice work! |
| 16:40 | rasmusto_ | Mongey_1: isn't it in clojure.set? |
| 16:40 | Mongey_1 | I'm getting 'Unable to resolve symbol: rename-keys in this context' |
| 16:40 | rasmusto_ | (for some strange reason) |
| 16:41 | dmitrig01 | joschka: also an algorithmic question - colrow and rowcol end up with the same result, right? |
| 16:41 | joschka | dmitrig01: yes |
| 16:41 | dmitrig01 | joschka: i might just pick one and stick to it then, no need to allow both :-) but that’s more of a personal pref, depends on yoru goals |
| 16:43 | dmitrig01 | joschka: also any reason to use (list) instead of a vector? |
| 16:43 | joschka | yeah this happened during the process and was needed for some other steps that were deleted during the process |
| 16:43 | Mongey_1 | I guess I'm just requiring it incorrectly |
| 16:44 | joschka | no reason at all, a purely naive choice :D |
| 16:44 | dmitrig01 | ah. it’s almost always recommended to use vectors instead of lists |
| 16:44 | joschka | okay |
| 16:44 | dmitrig01 | also! your addr-seq function can be expressed more concisely as just a map over the line-seq |
| 16:44 | dmitrig01 | as far as i understand |
| 16:45 | dmitrig01 | i know they were takling about that earlier :-) |
| 16:45 | dmitrig01 | but it looks like a pretty textbook map to me |
| 16:45 | joschka | yes they did :> |
| 16:46 | joschka | In the future I am probably going to avoid writing recursive functions for every single problem and look at reduce, map iterate |
| 16:47 | amalloy | recursion is pretty standard for n-queens though, isn't it |
| 16:52 | joschka | sneaky 4clojure, teaching me the recursion again :> https://www.4clojure.com/problem/57 |
| 16:53 | justin_smith | joschka: it gets to the other fun stuff too :) |
| 16:53 | justin_smith | joschka: also, after the first bunch, the difficulty isn't always in order |
| 18:58 | eriktjacobsen | Any ideas on why something like: (pmap (partial foo (first id-list) :param) array-list) works fine but (map #(pmap (partial foo % :param) array-list) id-list) just hangs, never goes into the fn and just sits there forever until ctrl-c? |
| 18:59 | justin_smith | eriktjacobsen: is id-list infinite? |
| 18:59 | eriktjacobsen | Nope, just 8 items, already realized / computed |
| 19:00 | eriktjacobsen | each of the 8 is about 200 strings with max length 40 char… (so pretty small) |
| 19:01 | amalloy | eriktjacobsen: are you typing exactly this expression into the repl, or using it in some larger expression? are you using the results of this map, or just doing it for side effects? |
| 19:02 | eriktjacobsen | Exactly this expression, so the results of the map should go into repl. the function “foo” hits a web REST api, so I am looking for it actually hit that. And the former (without the extra map) does hit just fine and runs all the results into the repl |
| 19:03 | eriktjacobsen | Not sure if it matters, but the function foo does exectute 6 separate request all in futures that are realized in the result. |
| 19:03 | eriktjacobsen | but doing the function foo in the pmap works fine one at a time, I just can’t get repl to iterate over it |
| 19:09 | monsta | Does anyone here had work with JavaFx8, I would like to know how can reload a scene after a make some change in the repl |
| 19:16 | justin_smith | eriktjacobsen: so instead of printing the result of the map, the repl just hangs? |
| 19:16 | justin_smith | eriktjacobsen: you could try running jstack on the jvm to see what all your threads are trying to do |
| 19:24 | eriktjacobsen | justin_smith: right. I have a println for instance as the first line in “foo”, and it never prints anything. doesn’t seem to be even running the inner map |
| 19:26 | eriktjacobsen | justin_smith: thanks will look into that. If have any guides on how to see what repl threads are trying to do that would be helpful, normally it takes a lot of effort to run jvm profilers including using jar directly (no repl) and some pause statements to get anything meaningful out, because otherwise its a bunch of clojure internals that dont seem to mean anything |
| 20:11 | joschka | why is ({:a 4 :b 5} :a) a function (PersistentArrayMap) and how may I find the documentation of that form? |
| 20:17 | tyler569 | For some reason I'm struggling to find documentation for you, but essentially you can call things like maps as functions, pass a key as argument, and get the value at that key |
| 20:17 | tyler569 | it just ends up being more convenient |
| 20:18 | tyler569 | if your keys are keywords it works the other way too |
| 20:18 | tyler569 | (:a {:a 5 :b 6}) will return 5 |
| 20:19 | joschka | tyler569: nice, thank you! |
| 20:20 | joschka | in clojure there seem to be a lot of those convenient features :P |
| 20:21 | tyler569 | it also works for maps ([3 8 2] 1) -> 8, sets (#{:a :b} :a) -> :a, while (#{:a :b} :c) -> nil |
| 20:21 | tyler569 | and any seqable as far as I know |
| 20:21 | icedp | Why does partition-by doesn't work here instead of filter and remove? https://gist.github.com/9129621df3037383e8b8 |
| 20:49 | justin_smith | icedp: ##(partition-by even? (range 10)) |
| 20:49 | lazybot | ⇒ ((0) (1) (2) (3) (4) (5) (6) (7) (8) (9)) |
| 20:49 | justin_smith | icedp: that's different from filter/remove isn't it? |
| 20:50 | Cr8 | ,(partition-by #(quot % 3) (range 10)) |
| 20:51 | clojurebot | ((0 1 2) (3 4 5) (6 7 8) (9)) |
| 20:51 | Cr8 | ,(partition-by identity "leeeerooooy") |
| 20:51 | clojurebot | ((\l) (\e \e \e \e) (\r) (\o \o \o \o) (\y)) |
| 20:53 | Cr8 | icedp I think what you wanted was split-with? |
| 20:53 | Cr8 | ,(split-with #(< % 6) (range 10)) |
| 20:53 | clojurebot | [(0 1 2 3 4 ...) (6 7 8 9)] |
| 20:53 | justin_smith | ,(split-with even? (range 10)) |
| 20:53 | clojurebot | [(0) (1 2 3 4 5 ...)] |
| 20:53 | justin_smith | Cr8: only works if the subseq is sorted already |
| 20:54 | justin_smith | and if it's sorted already, you're done :P |
| 20:54 | Cr8 | ah, prolly *aaaactually* wanted split-at then |
| 20:54 | justin_smith | Cr8: there's no builtin that does what he wants |
| 20:54 | Cr8 | ,(split-at 6 (range 10)) |
| 20:54 | clojurebot | [(0 1 2 3 4 ...) (6 7 8 9)] |
| 20:54 | icedp | ,(let [f #(< % 5), xs (range 15)] (partition-by f xs)) |
| 20:54 | clojurebot | ((0 1 2 3 4) (5 6 7 8 9 ...)) |
| 20:54 | justin_smith | Cr8: once again, only makes sense with a partially sorted input |
| 20:55 | icedp | ,(let [f #(< % 5), xs (range 15)] (list (filter f xs) (remove f xs))) |
| 20:55 | clojurebot | ((0 1 2 3 4) (5 6 7 8 9 ...)) |
| 20:55 | Cr8 | split-at doesn't look at the values at all -- which is what you actually want, i think? |
| 20:55 | justin_smith | icedp: ##(let [f #(< % 5), xs (shuffle (range 15))] (partition-by f xs)) ;; breaks on unsorted inputs |
| 20:55 | lazybot | ⇒ ((8 9 14 12) (2 3) (7 6) (4) (10 11 5) (0 1) (13)) |
| 20:55 | Cr8 | its a qsort impl? |
| 20:55 | justin_smith | icedp: just use filter/remove |
| 20:56 | icedp | Cr8: yes |
| 20:56 | icedp | justin_smith: I just wonder why it doesn't work. maybe partition-by doesn't support some lazy-cat 'stuff' |
| 20:56 | justin_smith | ,((juxt filter remove) (partial < 5) (shuffle (range 10))) |
| 20:56 | clojurebot | [(9 6 7 8) (3 4 5 1 2 ...)] |
| 20:56 | justin_smith | icedp: that's not how partition-by is meant to work |
| 20:57 | justin_smith | (juxt filter remove) is likely the most elegant result you'll get |
| 20:57 | icedp | interesting |
| 20:57 | justin_smith | icedp: partition-by splits the input at each change in value, but never re-orders input elements |
| 20:58 | icedp | ah, now I got it |
| 20:59 | icedp | ,(partition-by (partial > 5) [1 2 3 2 1]) |
| 20:59 | clojurebot | ((1 2 3 2 1)) |
| 20:59 | icedp | ,(partition-by (partial > 5) [1 2 3 6 1 ]) |
| 20:59 | clojurebot | ((1 2 3) (6) (1)) |
| 21:03 | icedp | ,(vals (group-by (partial > 5) [1 2 3 6 1 ])) |
| 21:03 | clojurebot | ([1 2 3 1] [6]) |
| 21:04 | Cr8 | the order those come out in could be either though |
| 21:07 | icedp | then I guess group-by and two get's. It's supposed to be faster then filtering two times filter + remove, right? |
| 21:10 | Cr8 | ,(let [p 5 in (shuffle (range 10))] (reduce (fn [[l g] i] (if (< i p) [(conj l i) g] [l (conj g i)])) [[] []] in)) |
| 21:10 | clojurebot | [[0 1 2 3 4] [7 9 6 5 8]] |
| 21:11 | Cr8 | not really using any clever built-in seq stuff, but if you want a single pass split-filter |
| 21:14 | icedp | I see, great |
| 21:16 | justin_smith | yeah, lazy-sort doesn't make a whole lot of sense anyway |
| 21:26 | weavejester | Does anyone happen to know why alter-var-root doesn't work with vars defined as part of a protocol, unless you explicitly use them as vars? |
| 21:27 | amalloy | weavejester: protocols do some nasty stuff to their vars |
| 21:27 | justin_smith | weavejester: when would alter-var-root work on something that isn't explicitly a var? |
| 21:27 | justin_smith | amalloy: oh, interesting, for the method slot logic I guess? |
| 21:28 | amalloy | i don't really know what you mean by method slot logic |
| 21:28 | amalloy | but it keeps information about implementations of the protocol function inside the var's metadata |
| 21:28 | justin_smith | amalloy: the protocol is backed by an interface that needs methods backed by the protocol methods, right? |
| 21:28 | amalloy | well it doesn't *need* them. you can choose to never use that interface |
| 21:29 | amalloy | weavejester: if the compiler detects that you are calling a function which is a protocol function, it emits code that, instead of calling the thing in the var, fiddles around with its metadata |
| 21:29 | weavejester | amalloy: I was afraid it would do something like that :) |
| 21:32 | dnolen | Bronsa: with the all various optimizations, cljs.tools.reader is within 3X of the JVM version under JavaScriptCore |
| 21:33 | dnolen | ~130ms to read cljs.core on my desktop machine, not too shabby :) |
| 21:33 | clojurebot | Gabh mo leithscéal? |
| 21:37 | Bronsa | dnolen: wow, impressive. didn't know js performances were this close to jvm |
| 21:38 | dnolen | Bronsa: can probably get w/in 2X with some more work |