2012-01-09
| 00:14 | mrevil | F333: there are some docs in the forthcomming "Clojure Programming" which you can get via rough cuts. |
| 00:22 | lnostdal | ,(. (int 261) equals 261) |
| 00:22 | clojurebot | true |
| 00:22 | lnostdal | ah, so it differs between clojure versions |
| 00:22 | lnostdal | ..on 1.4.x from git this yields false |
| 00:24 | technomancy | lnostdal: it's not that .equals is behaving differently, it's that 261 is evaluating differently |
| 00:24 | technomancy | err--reading differently |
| 00:24 | technomancy | anyway, if you want correct equality semantics you won't get them from .equals; that's what RT/equiv is for |
| 00:24 | amalloy | technomancy: no, i think it's that (int 261) is boxing differently |
| 00:25 | amalloy | they changed it back to boxing int as Integer in 1.4 |
| 00:25 | technomancy | oh, right. anyway, relying on .equals is just going to cause problems |
| 00:26 | amalloy | yes, .equals is contractually required to suck |
| 00:28 | lnostdal | yeah, i'd never use equals like that; i'm using an external (java) library for weak hash-table support |
| 00:29 | lnostdal | hm, but perhaps there are other ways? .. i haven't found weak hash-table support "tuned for" clojure |
| 00:29 | lnostdal | what i do now though is (let [id (long id)] ...) around my put and gets vs. the hash-table .. to make sure everything's the same with regards to type |
| 00:31 | amalloy | lnostdal: that's not a good way to use int/long |
| 00:31 | lnostdal | ok? |
| 00:31 | amalloy | they're only guaranteed to be useful for creating primitive int and long locals inside a function |
| 00:32 | amalloy | if you want to force boxing in a particular way, use (Integer. blah) |
| 00:32 | lnostdal | ah, yeah, i'm ok with the actual object "on the outside" still being something not a long |
| 00:33 | lnostdal | that way i don't have to deal with casting/coercing _everywhere_ some number might be created |
| 00:33 | amalloy | but...if you pass it to put/get, it's not local |
| 00:33 | lnostdal | the let i mentioned above is code inside the (my) put/get function |
| 00:33 | lnostdal | (defn my-put [id ..] (let [id (long id)] ...call java hash-table thing here..)) |
| 00:34 | lnostdal | ..like that or so |
| 00:34 | amalloy | right, which is exactly what i'm saying you can't count on |
| 00:34 | lnostdal | "count on"? |
| 00:34 | amalloy | because you have to box the thing up to call a method on it |
| 00:34 | lnostdal | count on for what? .. i need ID to always be LONG |
| 00:34 | amalloy | so it's not used only in the local scope |
| 00:35 | lnostdal | i'm ok with it only being used in this local scope! |
| 00:35 | amalloy | but it *isn't* used only in this local scope! you're giving it right to this other hashtable lib |
| 00:35 | lnostdal | yes, as a java.lang.Long |
| 00:35 | lnostdal | always |
| 00:36 | amalloy | if you want to be sure it's always a Long you should use (Long. x), not (long x) |
| 00:36 | lnostdal | why? .. what does (long ..) do if not cast it to java.lang.Long?? |
| 00:36 | lazybot | lnostdal: What are you, crazy? Of course not! |
| 00:36 | lnostdal | lazybot, shut up now |
| 00:36 | lnostdal | :P |
| 00:36 | amalloy | &(class (int 5)) |
| 00:36 | lazybot | ⇒ java.lang.Long |
| 00:37 | amalloy | the int/long hints are *only* hints for letting the compiler do primitive arithmetic on numbers that don't leave your scope |
| 00:37 | lnostdal | (class (int 5)) => java.lang.Integer here |
| 00:37 | amalloy | on 1.4, yes |
| 00:37 | lnostdal | *sigh* |
| 00:37 | amalloy | on every version of clojure that i'm aware of, (long x) happens to be boxed into a Long, and i can't really see it changing anytime soon, but (Long. x) is more semantically-correct if your goal is to make sure the boxed type is correct |
| 00:38 | lnostdal | wtf. is up with this stuff .. ok, (let [id (Long. id)] ...) it is then .. so god damn stupid |
| 01:00 | gmarceau | What would be idiomatic clojure for loop down two list at the same time? Is this how you would do it? (for [[fst snd] (map list (cons nil s) s) |
| 01:00 | gmarceau | :when (not= fst snd)] snd) |
| 01:01 | gmarceau | this is an expression that removes duplicate adjacent to each other in a list. |
| 01:09 | amalloy | (map first (partition-by identity s))? |
| 01:11 | amalloy | that probably breaks on an empty list but should work for everything else |
| 01:14 | gmarceau | Neat. but I'm actually curious for the general case. |
| 01:16 | gmarceau | (for [[fst lst] (map list firstNames lastNames)] (concat fst " "lst)) |
| 01:17 | gmarceau | or to give number to lines |
| 01:17 | gmarceau | (for [[n ln] (map list (range) lines)] (concat (str n) " " lines)) |
| 01:21 | clj_newb | i recently discovered somethign as awesome as clojure |
| 01:25 | amalloy | *nod* if you want the general case *and* you want to use a for-expression, you probably want to map list |
| 01:25 | amalloy | i think for all of your examples there's a nicer way, though |
| 01:26 | amalloy | (map #(str %1 " " %2) first-names last-names), (map-indexed (fn [n line] (str n " " line))) |
| 01:28 | gmarceau | ah, awesome. |
| 01:29 | gmarceau | but if I need for's :when feature as well, then I should use keep-index I suppose? |
| 01:30 | amalloy | and i think your first for-expression fails, right? if s is '(nil 1 2 3), you drop the nil out from the beginning |
| 01:31 | amalloy | for walking a single list in pairs, i generally use (for [[a b] (partition 2 1 coll)] ..) |
| 01:51 | gmarceau | awesome |
| 01:52 | clj_newb | I consider it a crime against humanity that I can not run clojure on my ipad. |
| 02:13 | notostraca | clj_newb, iPads are crimes against humanity, in a more literal sense http://www.thisamericanlife.org/radio-archives/episode/454/mr-daisey-and-the-apple-factory |
| 02:25 | markerdmann | notostraca: do you know if there's a transcript of the audio somewhere? |
| 02:25 | notostraca | markerdmann, sure i will check |
| 02:28 | Raynes | clj_newb: I bet tryclj.com works. Not exactly a substitute for a REPL, but beggars can't be choosers. |
| 02:44 | notostraca | markerdmann, no luck, too new for a human to have transcribed it. |
| 02:47 | amalloy | it's pretty captivating to listen to though |
| 03:07 | Magnars | idiomatic way of checking if a list has just one element? |
| 03:07 | amalloy | exactly one, or at most one? |
| 03:08 | Magnars | in my case I've already checked if it is empty |
| 03:08 | amalloy | (not (next x)) |
| 03:08 | Magnars | thanks! |
| 03:11 | Magnars | how about exactly one then? |
| 03:12 | Magnars | (= 1 (count x)) ? |
| 03:12 | amalloy | &(= 1 (count (range))) |
| 03:12 | amalloy | no good |
| 03:12 | Guest82940 | Execution Timed Out! |
| 03:12 | amalloy | haha Raynes, lazybot has lost his login |
| 03:12 | clojurebot | It's greek to me. |
| 03:13 | Raynes | amalloy: That's pretty awesome. |
| 03:13 | amalloy | Magnars: (and (seq x) (not (next x))), i suppose |
| 03:14 | Magnars | aye, more performant than count |
| 03:17 | amalloy | if the thing happens to implement Counted, then you might do slightly better with the <= version |
| 03:18 | Magnars | sometimes I miss cadr cddr and its ilk ^^ |
| 03:18 | amalloy | it's pretty easy to write them, of course, especially with macros |
| 03:19 | Magnars | yeah, but I'm trying to learn idiomatic clojure :) |
| 03:19 | Magnars | but then again, there's second and nnext - it's just that I have to go digging after what they're called |
| 03:26 | amalloy | indeed, i don't encourage it. but you might enjoy https://gist.github.com/1581911, which defines all the cadrs and cadaadars you could ever want in just a couple lines |
| 03:28 | amalloy | Magnars: ^ |
| 03:29 | Raynes | amalloy: Traitor. |
| 04:08 | bart1 | hello |
| 04:08 | bart1 | how to get clojure.lang.Compiler.load(new StringReader(text)); to string? It outs output to console |
| 04:10 | bart1 | don't know why, but this: http://pastebin.com/TwjxYmaK works only at first time |
| 04:50 | kral | hi pals |
| 05:01 | Blkt | good (late) morning everyone |
| 05:05 | gf3 | GOOD LATE MORNING |
| 06:03 | casperc | What is the idiomatic in clojure to spawn a thread to update a GUI component? |
| 06:04 | casperc | Is it just passing a function to Thread? |
| 06:08 | G0SUB | casperc: you could use an agent. |
| 06:11 | bart1 | how to get clojure.lang.Compiler.load(new StringReader(text)); to string? It outs output to console |
| 06:11 | bart1 | don't know why, but this: http://pastebin.com/TwjxYmaK works only at first time |
| 06:11 | casperc | G0SUB, i was thinking about that, but what would i put in the agent? The GUI component itself? |
| 06:12 | G0SUB | casperc: possible, or the function can two args and ignore the first one (the agent) |
| 06:12 | G0SUB | casperc: the GUI can be in a global var as well. |
| 06:14 | casperc | G0SUB: yeah, I might try keeping my gui components in a global map and then using send-off every time i want to update it |
| 06:14 | G0SUB | right |
| 06:15 | casperc | the is there any way to interrupt a previous thread working on the agent though? |
| 06:15 | G0SUB | casperc: why would you want to do that? |
| 06:16 | casperc | say i am in the process of updating a component and i get a new event to update the same component |
| 06:16 | casperc | maybe i am overthinking it though |
| 06:16 | G0SUB | casperc: all fns sent off to an agent are serialised. they are performed in order. |
| 06:18 | casperc | G0SUB: yeah, so if one is long running it would block the other one until done. What I would really want in a GUI is for the new event to stop existing and execute itself instead |
| 06:19 | G0SUB | casperc: hmm, that could be a problem. may be you need to rethink your solution. |
| 06:19 | G0SUB | casperc: if you are not doing IO, the function shouldn't be "long running". |
| 06:21 | casperc | G0SUB: I agree, but it might be slightly slower than realtime. Again i think i am just overthinking the problem, so I will try the agent solution you suggested :) |
| 06:21 | G0SUB | :-) |
| 06:21 | casperc | G0SUB: thanks alot for the input |
| 06:21 | G0SUB | casperc: my pleasure. |
| 06:35 | Vinzent | lein-clojurescript? |
| 06:42 | broquaint | For building clojurescript -> JS IIRC. |
| 10:44 | jsabeaudry | What is the status of clojure on android? Hve the initial problems been resolved? |
| 10:45 | AWizzArd | I would like to add to that question: isn't it possible to install a full JVM on Android? Todays devices should be powerful enough I guess. |
| 10:48 | jsabeaudry | AWizzArd: Yes it it but a lot of them are not very stable |
| 10:48 | jsabeaudry | AWizzArd: Shark and Cacao sometimes crash |
| 10:48 | jsabeaudry | AWizzArd: Jamvm seems more stable but slower |
| 10:52 | jkkramer | jsabeaudry: AWizzArd: Daniel Gomez seems to be leading the charge on that front. He gave an excellent presentation at clojure conj about it. This is probably the state of the art: https://github.com/sattvik/neko |
| 10:54 | jsabeaudry | jkkramer: Thanks! |
| 13:02 | TimMc | Since the room is fairly quiet, a Git question: I sent a pull request to merge mine:topic-branch into someone:version-branch. Should I have merged my changes first into the version-branch, or is everything gonna be OK? |
| 13:04 | nlew | TimMc: Not sure I follow. Are you asking if you should first have merged them into your local copy of version-branch? |
| 13:05 | TimMc | yep |
| 13:06 | TimMc | Or is it OK, since the topic branch came off the version branch. |
| 13:06 | nlew | Ah, then you're fine. The only branches considered are the ones being merged together. |
| 13:06 | TimMc | (I've gotten gun-shy about intuition and git...) |
| 13:07 | TimMc | nlew: Phew. I already screwed up 2 pull requests and was going to give up forever if this one went wrong too. |
| 13:07 | nlew | Github will show you specifically which commits will be pulled in by your merge, which is quite helpful to make sure you at least didn't mess anything up. |
| 13:08 | TimMc | Yeah, the diff looks fine, but I don't know git enough yet to tell if this could lead to a giant conflict later. |
| 13:57 | clj_newb | fn Foo calls fn Bar. Bar throws an exception e = (throw (Throwable. "Some string")). Now, I want Foo to catch e, and change "Some string" to "in Foo, from Bar: Some string". Now, I know how to use try/catch. My question is the following, given "e", how do I extract the "Some String" out of it? |
| 13:58 | Vinzent | ,(.getMessage (Exception. "foo")) |
| 13:58 | clojurebot | "foo" |
| 13:58 | clj_newb | Vinzent: nice; thanks |
| 13:59 | Vinzent | clj_newb, see javadoc for the Exception class |
| 14:06 | clj_newb | is there a name for (fn [a b c] (a b c)) ? |
| 14:06 | technomancy | list? |
| 14:07 | kumarshantanu | Hi, is it possible to detect the current environment -- CLJS or CLJ? |
| 14:08 | clj_newb | no, the a is a funtion, applied to args b & c |
| 14:08 | Vinzent | clj_newb, (a b c)? :) |
| 14:08 | technomancy | oh right |
| 14:08 | TimMc | clj_newb: Do you know about partial? |
| 14:08 | clj_newb | Vinzent: it needs to be a function I pass to map. |
| 14:08 | technomancy | I think amalloy had a trick for that |
| 14:08 | jhirn | Anyone here familiar with Pinot for cljs? |
| 14:08 | clj_newb | ,(doc partial) |
| 14:08 | clojurebot | "([f arg1] [f arg1 arg2] [f arg1 arg2 arg3] [f arg1 arg2 arg3 & ...]); Takes a function f and fewer than the normal arguments to f, and returns a fn that takes a variable number of additional args. When called, the returned function calls f with args + additional args." |
| 14:09 | clj_newb | wait wait wait |
| 14:09 | clj_newb | I think this is called eval |
| 14:09 | clj_newb | ,(eval '(+ 1 2 3)) |
| 14:09 | clojurebot | #<Exception java.lang.Exception: SANBOX DENIED> |
| 14:09 | Vinzent | clj_newb, you don't need eval |
| 14:09 | clj_newb | saying that I don't need Eval is like saying that I don't need nukes to kill ants |
| 14:10 | TimMc | clj_newb: I think you want #(% %2 %3) |
| 14:10 | clj_newb | TimMc: lol; nice |
| 14:10 | kumarshantanu | technomancy: trick to detect CLJS or CLJ? |
| 14:10 | technomancy | kumarshantanu: (resolve 'var) maybe? |
| 14:10 | technomancy | no idea; I've never used cljs |
| 14:12 | kumarshantanu | technomancy: CLJS doesn't have true vars, so no resolve |
| 14:12 | technomancy | derp |
| 14:14 | technomancy | maybe try to add a bunch of integers together and if you don't get floating-point errors introduced you must not be on JS =) |
| 14:16 | TimMc | kumarshantanu: (defn cljs? [] (string? :a)) |
| 14:16 | TimMc | That's a bit of a dirty trick, so don't come running when it stops working... :-P |
| 14:17 | kumarshantanu | TimMC: (string? :a) returns false on the CLJS REPL |
| 14:18 | TimMc | Huh. Another thing to investigate in my Try-CLJS code. |
| 14:19 | TimMc | kumarshantanu: What happens if you write (clojure.core/string? :a) ? |
| 14:19 | TimMc | I mean, should be the same... |
| 14:20 | kumarshantanu | TimMC: It is the same |
| 14:21 | TimMc | kumarshantanu: OK, there's a chance there's a difference between compiled and REPL'd CLJS. I give up. |
| 14:21 | OgMaciel | hi, first question here: if I have a defn that takes [foo {:keys [baz bar]}], how do I pass the second arg to another defn that has the same signature as this one? |
| 14:22 | Vinzent | TimMc, https://groups.google.com/forum/#!topic/clojure/dGMJrztg-C0 |
| 14:22 | TimMc | OgMaciel: Check out the :as option. |
| 14:23 | kumarshantanu | TimMC: I remember that keywords used to be just strings, but no idea if that's still the case |
| 14:23 | OgMaciel | TimMc, cool, I'm guessing that I'd change the signature to give the second arg an "alias" that can be used then to pass it along? |
| 14:24 | TimMc | OgMaciel: Right, it's something like {:keys ... :as arg2}. By the way, the signature doesn't change -- it's still a binary function. |
| 14:24 | OgMaciel | TimMc, thanks a bunch... learning Clojure coming from Python :) |
| 14:31 | abp | hi, why isn't there a interleave-all function in clojure.core? |
| 14:36 | abp | for sure because there are other ways to solve problems |
| 14:37 | abp | but with my current skill in fp and clojure i'm not able to find them without help |
| 14:42 | TimMc | abp: What would interleave-all do? |
| 14:42 | TimMc | I guess (interleave-all '[a b] [1 2 3 4 5]) would be '[a 1 b 2 3 4 5] |
| 14:42 | abp | TimMc: combine seqs of different lengths |
| 14:43 | abp | TimMc: yes |
| 14:43 | TimMc | Like the reverse of how I eat Skittles. |
| 14:45 | TimMc | If that's not already a problem on 4Clojure, it should be. |
| 14:46 | jkkramer | abp: i have a version of interleave-all coded if you want it |
| 14:46 | abp | jkkramer: yes, found one, could write one, but why isn't it in core? |
| 14:48 | TimMc | abp: Not enough people had the need. |
| 14:48 | abp | TimMc: oh ok |
| 14:49 | TimMc | I doubt there's any philosophical reason for that one. |
| 14:49 | abp | TimMc: so how would i go about different length input seqs, transforming them and reducing the results in steps until *nothing* is left |
| 14:51 | TimMc | abp: I think I would use the lazy-seq macro for this, dropping input seqs as they run out of elements. |
| 14:54 | abp | TimMc: but this would be interleave-all, i just getting accustomed to hofs and then there are some missing, leaving me searching and thinking i'am doing something wrong before implementing it myself |
| 14:56 | Vinzent | then there should be map-all, mapcat-all, etc |
| 14:57 | abp | Vinzent: sure, but what level do you thereafter? map + map-all is like single- and multi-arity implementation, or not? |
| 14:59 | abp | TimMc, jkkramer, Vinzent: and i wonder what is considered more idiomatic now, implementing or searching for interleave-all once, or writing my lazy-seqs whenever i need them |
| 14:59 | Vinzent | abp, no, arity is the number of arguments of a function (and both map and map-all takes any number of args) |
| 14:59 | TimMc | Vinzent: map-all's f would take a variable number of args |
| 15:01 | Vinzent | TimMc, indeed. But I thought abp was talking about arity of map and map-all |
| 15:03 | TimMc | Oh, I see. |
| 15:03 | abp | Vinzent: No, that was just a kind of analogy, I need interleave and interleave-all, just like sometimes I need functions with single and multiple arity |
| 15:04 | Vinzent | abp, ah, ok. Yeah, it's definitely kind of pattern |
| 15:05 | abp | Sorry for confusing the hell out of everyone. |
| 15:10 | OnResolve | is there a working plugin for clojure with the newest version of netbeans(prerequisite is a must) that anyone can recommend? |
| 15:12 | amalloy | technomancy: my trick for (fn [a b] (a b)) only works for one-arg functions: that happens to be how deliver is implemented |
| 15:15 | technomancy | you keep telling me that, and I keep forgetting it |
| 15:16 | amalloy | i'll tell you about fnil too if you want |
| 15:17 | amalloy | i liked fnil before it was cool |
| 15:17 | Raynes | You broke 4clojure with fnil before it was cool. |
| 15:17 | amalloy | haha that's sorta true |
| 15:17 | Raynes | Only for developers with empty databases. |
| 15:17 | TimMc | $findfn + 8 8 |
| 15:17 | Raynes | But still. |
| 15:17 | lazybot | [clojure.core/max-key clojure.core/cond clojure.core/dosync clojure.core/sync clojure.core/char-escape-string clojure.core/deliver clojure.core/with-loading-context clojure.core/*clojure-version* clojure.core/case clojure.core/min-key clojure.core/and clojure.core/lo... https://refheap.com/paste/217 |
| 15:18 | TimMc | So many options! |
| 15:18 | amalloy | and it wasn't really my code either. it was a pull request i OKed because i didn't see the issue |
| 15:18 | amalloy | &(case + 8 8) |
| 15:18 | lazybot | java.lang.IllegalArgumentException: No matching clause: clojure.core$_PLUS_@aaff8e |
| 15:18 | Raynes | TimMc: All of them neatly organized in a lovely pastebin for your consumption. |
| 15:18 | TimMc | No more gist? |
| 15:19 | amalloy | TimMc: you didn't hear? Raynes bought github |
| 15:19 | TimMc | Hmm, that test was wrong. |
| 15:19 | Raynes | Heh |
| 15:20 | TimMc | $findfn - 2 -2 |
| 15:20 | lazybot | [clojure.core/deliver clojure.core/trampoline] |
| 15:21 | TimMc | $findfn + 2 3 5 |
| 15:21 | lazybot | [clojure.core/trampoline] |
| 15:28 | clj_newb | is there something like with-handler in clojure? |
| 15:33 | amalloy | aha, trampoline. an even better hack than deliver, as long as you don't want to return a function |
| 15:34 | TimMc | trampoline: No good in lambda calculus |
| 15:43 | troydm | is cljr not maintained any more? |
| 15:43 | troydm | what's the best way to start using clojure ? |
| 15:44 | amalloy | $google technomancy leiningen readme |
| 15:44 | lazybot | [technomancy/leiningen - GitHub] https://github.com/technomancy/leiningen |
| 15:44 | amalloy | troydm: ^ |
| 15:45 | troydm | amalloy: i see i thought you need to have clojure already installed to use leiningen |
| 15:45 | troydm | troydm: so i was looking for something like rvm for ruby |
| 15:45 | troydm | only for clojure |
| 15:46 | amalloy | nope. installing clojure is something you only do if you're confused (and a lot of people are, when they get here) |
| 15:46 | troydm | amalloy: i see, thx |
| 16:06 | Vinzent | abp, are you still here? It seems like I found an interesting solution for your interleave-all problem, see https://gist.github.com/1584947 (warning, the code is a bloody mess) |
| 16:07 | choffstein | If I am in emacs and connected to lein via lein swank, and I discover I need to add a new dep to my project, is there a more efficient way than having to close down swank, edit my project file, call `lein deps`, then start swank again? |
| 16:07 | TimMc | Vinzent: Unfortunately, that will realize all the input seqs. |
| 16:08 | troydm | how do i get clojure version when using lein repl |
| 16:08 | TimMc | troydm: *clojure-version* |
| 16:08 | troydm | i want to know what version of clojure i'm using |
| 16:08 | troydm | TimMc: thx |
| 16:08 | TimMc | Probably 1.2.1 if you aren't inside a project. |
| 16:09 | Vinzent | TimMc, yeah, but it's not intended for a real use :) |
| 16:11 | troydm | TimMc: yes it's 1.2.1 |
| 16:13 | TimMc | troydm: Leiningen itself uses 1.2.1, so that's the default repl's version of Clojure. I recommend creating ~/tmp and running `lein new adhoc` from there to create a project you can use for experimentation. |
| 16:13 | TimMc | (And edit the project.clj in there to use 1.3.0) |
| 16:13 | troydm | TimMc: i see, thx |
| 16:22 | troydm | as i see leiningen is something like maven only for clojure projects? |
| 16:22 | troydm | or i'm missing something? |
| 16:24 | FrankS | appreciate any repl-guru who could shed some light on how to programmatically exit/end a leon-repl session... |
| 16:24 | troydm | FrankS: type (exit) |
| 16:24 | FrankS | see http://tinyurl.com/87743lz for details |
| 16:24 | troydm | FrankS: ot |
| 16:24 | TimMc | troydm: That's basically correct -- it's a dev and build environment. |
| 16:27 | FrankS | troydm: what ns is that exit function located? |
| 16:27 | TimMc | FrankS: It should already be refer'd. |
| 16:28 | TimMc | FrankS: (var exit) to find out |
| 16:28 | troydm | FrankS: i know Common Lisp a bit, so it'll basicly be in cl-init or something like that |
| 16:28 | FrankS | troydm: cljsh.core=> (exit) CompilerException java.lang.RuntimeException: Unable to resolve symbol: exit in this context, compiling:(NO_SOURCE_PATH:1) cljsh.core=> |
| 16:28 | TimMc | That's unusual... |
| 16:28 | troydm | FrankS: that's cljsh, does lein use cljsh ? |
| 16:29 | jsabeaudry | lein noir new popo; cd popo; lein uberjar; java -jar popo...-stadalone.jar could not find the main class popo.server! Am I missing something here? |
| 16:30 | TimMc | FrankS: Ah, I see. Anyway, just use Ctrl+d |
| 16:30 | troydm | does lein repl start swank server or it has some custom server and i have to start swank using other method? |
| 16:30 | FrankS | troydm: cljsh is my ns |
| 16:30 | djh__ | I get the unresovled symbol error too when I run (exit) |
| 16:30 | jowag | use (System/exit 0) |
| 16:30 | TimMc | djh__: You probably have a :main specified in your project. |
| 16:30 | FrankS | TimMc: i know about ctrl-d :-), this is about doing it programmatically |
| 16:30 | TimMc | People, it's a shell -- just use Ctrl + d. |
| 16:31 | troydm | i type lein repl |
| 16:31 | djh__ | TimMc - interesting I see |
| 16:31 | troydm | and it starts repl |
| 16:31 | FrankS | see http://tinyurl.com/87743lz for details |
| 16:31 | troydm | and then i type |
| 16:31 | troydm | user=> (exit) |
| 16:31 | troydm | and it exists it |
| 16:32 | djh__ | I like the way you can quit GHCI (haskell repl) by just typing :q |
| 16:32 | troydm | so my question is can i connect to lein's repl socket using swank from emacs? |
| 16:32 | TimMc | FrankS: And System/exit is not an option? |
| 16:32 | djh__ | but I guess that's a VIM thing |
| 16:32 | jsabeaudry | Can anyone tell me if this works on your side? lein noir new popo; cd popo; lein uberjar; java -jar popo...-stadalone.jar |
| 16:32 | Somelauw | (exit) doesn't work when using slime for me (System/exit 0) does work on the other hand |
| 16:32 | troydm | djh__: it's more like ghci in that context |
| 16:33 | troydm | djh__: rather than vi |
| 16:33 | TimMc | jsabeaudry: You haven't specified a :main in your project. |
| 16:33 | FrankS | troydm: i do not want to quit/exit the jvm, only the repl session |
| 16:33 | troydm | FrankS: ohh i see |
| 16:33 | jsabeaudry | TimMc: Yes there is a :main, its made by lein noir new |
| 16:33 | FrankS | troydm: what do you get for (var exit)? |
| 16:33 | TimMc | Ah, missed the noir bit. |
| 16:33 | troydm | #'leiningen.core/exit |
| 16:35 | TimMc | jsabeaudry: Open up the jar and check if the .class files are there. |
| 16:36 | FrankS | troydm: looking at the source code, that leiningen.core/exit does bring down the whole jvm... |
| 16:37 | technomancy | troydm: control-d is the way to close a repl session |
| 16:37 | technomancy | in pretty much anything |
| 16:37 | jsabeaudry | TimMc: I'm definitely not a java expert but there is a server$_main.class in the jar |
| 16:37 | FrankS | technomancy: sorry, but i want to do it programmatically... |
| 16:38 | troydm | technomancy: doesn't C-d brings the JVM down too |
| 16:38 | technomancy | FrankS: oh, oops. are you the one who wrote to the mailing list? |
| 16:38 | FrankS | yup |
| 16:38 | technomancy | troydm: if it's the main repl session, yes. if you're telnetting into a "lein repl" server, no. |
| 16:39 | troydm | technomancy: yes i mean in main repl |
| 16:39 | technomancy | FrankS: I don't know of a way with the currently-released one, but I'll make it possible in 1.7.0 |
| 16:39 | technomancy | FrankS: the trick is to both close *in* and return request-exit# when the kill-switch is entered |
| 16:40 | jsabeaudry | technomancy: Any known issue with uberjar in lein 1.6.2? |
| 16:40 | troydm | well you could try doing control-z and the bg %1 but it's not good way to do it |
| 16:40 | technomancy | well, no way to do it in 1.6.2 apart from closing the actual socket, but apparently you want to do it by sending something along the socket |
| 16:41 | technomancy | jsabeaudry: sure: https://github.com/technomancy/leiningen/issues/search?q=uberjar&state=open&assignee= |
| 16:41 | FrankS | technomancy: (close *in*) generates a loong stack trace - not very "graceful"... |
| 16:41 | jsabeaudry | technomancy: Thanks, problem must not be with lein |
| 16:42 | technomancy | jsabeaudry: or it's a problem that's not known |
| 16:42 | technomancy | FrankS: that's why you need to do both |
| 16:42 | FrankS | technomancy: i'm using 1.7.0 |
| 16:43 | technomancy | FrankS: check the latest commit on the 1.x branch |
| 16:45 | gtrak` | troydm: C-d sends an EOF character |
| 16:48 | jsabeaudry | TimMc: Ah thanks for your help, I just figured out that I forgot the (:gen-class) |
| 16:48 | FrankS | technomancy: tried (do (.close *in*) request-exit) before seeing you patch... funny :-) |
| 16:49 | technomancy | nice =) |
| 16:49 | FrankS | technomancy: but that seems to work - thanks!!! |
| 16:49 | technomancy | no problem |
| 16:52 | TimMc | jsabeaudry: Oh, I figured it would set that up too! |
| 16:53 | jsabeaudry | TimMc: same I had just assumed that it did! Especially if it sets up :main... I guess I'll talk with chris or send him a pull request |
| 16:58 | FrankS | technomancy: sorry... it worked for "bye-bye", but what do i specify as command for your patch - ::exit doesn't seem to work (evils to :cljsh.core/exit) |
| 17:02 | FrankS | technomancy: :leiningen.repl/exit works (just read your post...) |
| 17:02 | technomancy | FrankS: it's expanded at compile-time, so it's :leiningen.repl/exit |
| 17:04 | TimMc | FrankS: ::foo is reader sugar for :this-namespace/foo |
| 17:08 | mattmitchell | is there a "built-in" that does this kind of grouping? https://gist.github.com/1585231 |
| 17:10 | mattmitchell | partition-by-relative-diff etc..? |
| 17:11 | TimMc | I can pretty much guarantee: No. |
| 17:11 | mattmitchell | Yeah, thought so :) |
| 17:11 | TimMc | What constitutes near? How many groups? Max group size? |
| 17:12 | mattmitchell | TimMc: near means, how close in value it is to a neighbor. No limit on groups/group-size |
| 17:13 | TimMc | mattmitchell: How would you group this? [1 2 4 8 16 32 64 128 256] |
| 17:14 | mattmitchell | ... thinking |
| 17:14 | TimMc | The best I could come up with for a *formal* definition of grouping was "every number goes with the closest neighbor", but that gets into problems like the middle number in [10 30 50 70 90] |
| 17:14 | amalloy | yeah, that gist reads as group-by-psychic-powers |
| 17:15 | mattmitchell | ... malfunction |
| 17:15 | TimMc | heh |
| 17:15 | mattmitchell | haha, yeah, your example throws that off a bit |
| 17:16 | TimMc | It's fair to say "My data will always be clumpy, pathological cases won't matter". |
| 17:16 | TimMc | ...but you still have to have a heuristic of some sort. |
| 17:16 | TimMc | (Side note, I was all set to type "frequencies" before I read your gist.) |
| 17:16 | amalloy | the best way i could interpret the gist was like "introduce a break between Xn and Xn+1 if Xn is closer to Xn-1 than it is to Xn+1", but it doesn't quite work even on the example input |
| 17:17 | mattmitchell | amalloy: yeah that was the wording i had in my thoughts too |
| 17:17 | amalloy | mattmitchell: in that case you put 50 in the wrong group :P |
| 17:18 | mattmitchell | amalloy: yes you're right, i fixed that |
| 17:18 | TimMc | 50 should be by itself |
| 17:18 | amalloy | right, your original version is correct given the definition i made up. your correction breaks the rule |
| 17:18 | mattmitchell | ahh actually, it would make sense to have it by itself, yes |
| 17:19 | TimMc | Its neighbor deltas are way higher than the next deltas. |
| 17:19 | amalloy | anyway, an algorithm for doing this is not actually that easy to imagine |
| 17:21 | mattmitchell | it would seem so. I'm "just" trying to cluster close values into their own group as an exercise, really |
| 17:22 | TimMc | It's a domain-dependent problem. |
| 17:23 | amalloy | mattmitchell: you might like to take a look at https://github.com/flatland/useful/blob/develop/src/useful/seq.clj#L191 as a jumping-off point - it only allows for knowledge about two nearby numbers rather than three, but i suspect you can use a similar approach |
| 17:23 | mattmitchell | amalloy: hey thanks, that sounds very close to what i'd like to do |
| 17:25 | FrankS | TimC: thanks for the clarification |
| 17:32 | mattmitchell | amalloy TimMc: thanks for your help! |
| 17:55 | zzach | How to terminate a Clojure CLR session? (. System exit 0) is not working. |
| 17:58 | hiredman | zzach: that is a static method on a class provided by the jvm (the System class) you'll need to figure out what the C#/CLR call is |
| 18:07 | zzach | hiredman: Thanks for reply. (Environment/Exit 0) seems to work. |
| 18:11 | FrankS | technomancy: it's still a little raw, but I'd love your (early) feedback on "https://github.com/franks42/cljsh" |
| 18:46 | technomancy | FrankS: hey, I was wondering if you'd looked into jark at all: http://icylisper.in/jark/ |
| 18:52 | FrankS | technomancy: I did, but the OCaml dependency put me off... using the repl-server directly thru socat/netcat-like tools seemed like a more simple approach... it was also an exercise/challenge to see if this approach would work - if there is no interest or if there is another better tool, I will gladly use that - what is your take on this? |
| 18:55 | Raynes | FrankS: You shouldn't put closing parens on their own lines. They get lonely down there. |
| 18:55 | Raynes | FrankS: Not sure what editor you're using, but that indentation is definitely not standard. |
| 18:56 | technomancy | jark's got a fair bit of momentum. |
| 18:56 | technomancy | (but maybe I'm just biased towards ocaml?) |
| 18:56 | Raynes | Should have been done in Haskell. Let's have a bias party! |
| 18:57 | technomancy | haskell? for something that's basically all I/O? I think not =P |
| 18:59 | amalloy | technomancy: i haven't really gotten the impression that jark has any momentum. when someone asks about persistent repls or whatever, i say "hey maybe you should try jark". but i've never heard of anyone actually using it successfully |
| 18:59 | Raynes | That's pretty stereotypical limiting. |
| 18:59 | amalloy | Raynes: it's cool, technomancy only uses clojure for things that are basically all parens |
| 18:59 | Raynes | Haskell is fine for I/O heavy tasks. They have this whole monad for it! |
| 18:59 | FrankS | Raynes: thanks for the esthetics feedback - didn't do a lot of lisp coding for 20+ years - i'll see if i can make my parens to behave more sociable ;-) |
| 19:00 | Raynes | :) |
| 19:00 | technomancy | maybe momentum is the wrong word |
| 19:00 | technomancy | it has an existing codebase |
| 19:00 | Raynes | And it theoretically does... things. |
| 19:04 | FrankS | Raynes: are your the "Raynes" from fs? if so, (set-prompt repl-cwd-prompt) will give you a file-path prompt in the repl ;-) |
| 19:14 | FrankS | technomancy: since this afternoon this cljsh has a codebase too ;-) - but seriously, I am not pushing - just interested to see if this cljsh approach holds water - the only advantage that made me pursue this prototype was the inherent simplicity to interact with your repl server thru stdin/stdout |
| 19:16 | technomancy | yeah, right now jark's lack of activity and packaging make it annoying. long-term I would love to see it take off, but the problem it's trying to solve is more difficult. |
| 19:18 | technomancy | the simplest thing, of course, is just the shell equivalent of (comp rlwrap (partial netcat "localhost" $LEIN_REPL_PORT)) |
| 19:18 | technomancy | and this lies somewhere between those two |
| 19:22 | FrankS | technomancy: exactly - this cljsh just adds some syntactic sugar to make it appear more like a unix'y shell/filter |
| 19:23 | FrankS | technomancy: btw, couldn't make nc/netcat behave well on macosx - wouldn't listen to ctrl-d and other weird behavior - may work better on other unix-variants (?) |
| 19:25 | technomancy | weird. did you have to get it through a package manager, or is it built-in? |
| 19:27 | FrankS | technomancy: believe an old version comes with the OS, but i tries to get newer ones from macport - no success with those either (?) - then socat worked as a charm so didn't go back to see if it could be fixed |
| 19:29 | technomancy | I was going to guess weird gnu/bsd differences, but apparently the canonical netcat is released under a nonsense non-license. |
| 19:30 | technomancy | "It is freely given away to the Internet community in the hope that it will be useful, with no restrictions except giving credit where it is due..." yeah, the courts will love that. |
| 19:34 | FrankS | technomancy: if it comes with the OS, then all should be ok, and it's apple/M$/RH's issue - otherwise your point is well taken - i see it's in my /usr/bin, so Apple put it there - although there seem to be many different version out there in the wild |
| 19:36 | technomancy | oh, not saying it's a problem for the end user at all |
| 19:36 | technomancy | it's just surprising that it didn't raise a red flag for the OS vendors |
| 19:57 | TimMc | "This software is released under the GPLv3 if the Higgs Boson exists, otherwise it is released under the EPL v1.0. |
| 19:57 | TimMc | " I guess |
| 20:22 | arohner | is it possible to make midje stub an apply call? |
| 20:23 | arohner | i.e. (provided (apply foo anything) => 42) |
| 20:43 | brudrick | good day |
| 20:43 | brudrick | I'm working on repurposing noir-blog into a regular website, with the added benefit of being able to edit the pages using a wysiwyg editor. |
| 20:45 | brudrick | and, so what would be blog posts are instead regular pages. I'm spitting those out into a menu. |
| 20:45 | brudrick | Thing is, I'd like to have categories to my navigation menu. |
| 20:45 | brudrick | the "about" section... the "Concepts" section, "Resources" etc. |
| 20:46 | brudrick | the simple.db is already managing 3 different datastructures and something like an atom |
| 20:47 | brudrick | And I'm wondering where to stick this new catagory information... I could add it as another attribute of the posts themselves.. but |
| 20:48 | brudrick | I'd like the user to be able to easily add and remove categories, and manage the organization of pages within the navigation menu |
| 20:48 | brudrick | so I'm wondering how to attack this |
| 20:51 | brudrick | in terms of ordering of pages in categories: [[1 2 3] [4 5] [6 7 8 9]] or {1 [1 2 3] 2 [4 5] 3 [6 7 8 9]} ?? |
| 20:51 | lazybot | brudrick: Uh, no. Why would you even ask? |
| 20:51 | Raynes | Heh. |
| 20:51 | Raynes | lazybot: Don't be mean. |
| 20:51 | brudrick | droids these days |
| 20:52 | brudrick | and I could have a post called "welcome!" with a post ID of 2. |
| 20:54 | brudrick | and then have a ":nav" key on that post that has a mapping of where it belongs: {:nav {:about 1}} which would place it in the "About" section as the first page. |
| 20:54 | brudrick | but I'm not sure how complex the logic would need to be to keep all posts in the correct state at all times. |
| 20:55 | brudrick | building the nav menu means iterating across all posts, every time, to generate the menu |
| 20:57 | brudrick | whereas the other option is another datastructure. One which is always in the correct order and which the user/admin edits (like in the examples above) |
| 20:59 | brudrick | I'm in favor of "one datastructure, many functions" |
| 21:01 | brudrick | but I'm worried about maintaining consistency / ensuring the derived structure is never in an invalid state |
| 21:03 | brudrick | If post 5 takes the place of post 2, in the same category, post 2, 3 and 4 need to move to their later positions. moving post 2 to another category affects all subsequent indexes of the current category, plus the other category, depending on where it went. |
| 21:03 | brudrick | sorry to be half thinking out loud |
| 21:04 | brudrick | so given that situation, please advice if there are any pearls of wisdom that apply |
| 21:04 | brudrick | *advise |
| 21:09 | brudrick | plus, if I don't use another datastructure, what says what order the categories go in? |
| 21:34 | kcin | sometime when i tried to (use 'clojure.repl) in slime it gave me class not found error, why? (slime connected to 'lein swank') |
| 21:37 | tmciver | kcin: are you running lein swank from a project directory? |
| 21:37 | kcin | tmciver: yes |
| 21:38 | tmciver | kcin: hmm, don't know then. I usually 'clojure-jack-in' (essentially the same thing) and it works for me. |
| 21:39 | amalloy | you probably forgot the ' in 'clojure.repl |
| 21:40 | amalloy | &(require clojure.repl) |
| 21:40 | lazybot | java.lang.ClassNotFoundException: clojure.repl |
| 21:40 | amalloy | &(require 'clojure.repl) |
| 21:40 | lazybot | ⇒ nil |
| 21:41 | kcin | amalloy: I'm not, anyway it actually works after i move (,cd from slime) to project dir after connecting. ^_^ |
| 21:44 | TimMc | Ooh, surprise benefit: I think uberjar-jit is faster than uberjar. It should be, since it doesn't have to compile as much... |
| 21:52 | tmciver | kcin: I don't believe the current directory in emacs matters; only the directory from which you start swank. |
| 21:57 | kcin | tmciver: I did run lein swank inside project dir though, i can't even run lein swank outside project dir, it will gives me "Couldn't find project.clj, which is needed for swank" error if i did. |
| 22:10 | blong | What is the correct way to go about setting up a namespace for various helper functions or macros? I'm not really very familiar with the way Java handles things so I'm a bit lost when it comes to the correct way to do this kind of thing with Clojure. |
| 22:11 | isak_ | why does (contains? ["A" "B" "C"] "A") => false? considering (= "A" "A") => true |
| 22:12 | isak_ | oh, its a key, never mind |
| 22:12 | TimMc | blong: One namespace per file in Clojure (and vice versa), so create a util.clj in your project and :require/:use it. |
| 22:13 | blong | thanks TimMc |
| 22:13 | TimMc | blong: If you have a bunch of helpers you want to use in multiple projects, create a "useful" lib and add it to your projects as a dependency. |
| 22:15 | bkpattison | in clojurescript, how do i convert a javascript array to a seq? |
| 22:20 | TimMc | bkpattison: seq isn't enough? |
| 22:20 | bkpattison | yeah, i would have thought (seq my-js-array) would have done it |
| 22:21 | bkpattison | get an not I-Sequable error |
| 22:21 | TimMc | ew |
| 22:22 | TimMc | *sigh* CLJS is very not mature. |
| 22:22 | bkpattison | yeah, it has some growing pains yet |
| 22:22 | bkpattison | its still better than javascript |
| 22:25 | bkpattison | Uncaught Error: No protocol method ISeqable.-seq defined for type number: |
| 22:26 | amalloy | bkpattison: seq on a native array works for me in cljs |
| 22:27 | amalloy | ClojureScript:cljs.user> (seq (js/Array 1 2)) ;; returns (1 2) |
| 22:27 | bkpattison | hmm, seq on a native array works? so i probably got something else wrong -- let me double check -- thanks |
| 22:29 | amalloy | sounds like you're seq'ing a number, not an array |
| 22:30 | TimMc | "This seems like a big oversight though." <-- forgot to actually hit enter |
| 22:31 | TimMc | But you can tell from how quickly I believed it was unimplemented just how low my opinion of cljs is at the moment. |
| 22:32 | amalloy | eh. i'm not really interested in cljs as a product, and it's not polished, but it's a *lot* lower-friction than jvm-clojure |
| 22:33 | amalloy | cljs missing a feature you want? submit a patch, dnolen will merge it later tonight |
| 22:33 | amalloy | jvm-clojure missing a feature you want? if you can't do it "locally" with macros you're probably better off crying into your beer, because a patch will take a lot of patience |
| 22:35 | brudrick | working example: http://www.cringely.com/2009/03/parrot-secrets/ |
| 22:35 | brudrick | oops :) |
| 22:35 | brudrick | wtf? |
| 22:35 | TimMc | No, no -- I, Cringely is always a good read. |
| 22:35 | bkpattison | yep, i use (seq my-js-array) worked -- it wasn't passing in an js/array |
| 22:36 | brudrick | why did I paste that? |
| 22:36 | brudrick | I probably read that article a long time ago |
| 22:36 | brudrick | anyway: working example: http://strong-fog-4203.herokuapp.com/blog/view/the-book |
| 22:37 | brudrick | blog/admin takes one to the login |
| 22:37 | brudrick | and when one posts a new article, it shows up in the nav bar |
| 22:38 | brudrick | of the book cover |
| 22:38 | brudrick | '/blog/' should should only show the first / splash page though |
| 22:38 | brudrick | of the book cover |
| 22:38 | brudrick | its a site I'm building for my dad, so he can edit it himself. Current version here: questforthekingdom.com |
| 22:39 | brudrick | its his book. |
| 22:41 | adiabatic | "Quest for the Kingdom" would make for better <title> contents than "QFTK" |
| 22:44 | TimMc | brudrick: A year from now you'll look up from your full-featured Content Management System and think, "Where did I go wrong? Could there have been another way?" |
| 22:45 | TimMc | :-) |
| 22:45 | adiabatic | heh |
| 22:45 | TimMc | This is always where it starts: Modifying blog software to add non-timeline pages. |
| 22:49 | amalloy | adiabatic: anyone who doesn't know what kwufftick means doesn't deserve to read my blog |
| 22:50 | adiabatic | How appropriate. You fight like a cow. |
| 22:50 | adiabatic | (challenge/response failure) |
| 22:52 | brudrick | adiabatic: I'm trying to make a meme out of qftk... very unique, I think. "hey, did you hear about qftk?" |
| 22:52 | brudrick | TimMc: I just neeed something simple so my dad can update pages, rather than asking me to all the time |
| 22:52 | adiabatic | well, you appear to have all its Googlejuice |
| 22:52 | brudrick | zactly |
| 22:54 | brudrick | k'well, gotta roll.. will let y'all know when I make improvements.. Once I have some halfway clean code, too, I'll throw it up on github |
| 22:55 | brudrick | memorable phrase/word? |
| 22:56 | adiabatic | just keep examining every low bid quoted for zinc etchings |
| 22:57 | jodaro | this lsu/alabama game is painful to watch |
| 23:18 | adiabatic | ( |
| 23:20 | adiabatic | I'm doing my-nth again, this time with loop and recur. Can I do (fn my-nth [coll idx] (loop [coll coll, idx idx, acc 0] ; … with the inside-the-loop names the same as the outside-of-the-loop names? Will that screw anything up? |
| 23:22 | amalloy | "try it and see" seems like the best answer here |
| 23:23 | adiabatic | An adventure! |
| 23:23 | amalloy | (let [x 1] (loop [x x] (if (zero? x) :done, (recur (dec x))))) ;; what do you expect this to do? |
| 23:27 | adiabatic | Now that I think about it, I have a strong hunch it won't work like I want it to because I except both 'x's of [x x] to be, um, evaluated at the same time |
| 23:32 | amalloy | welp, advice still stands. try it out, and whatever it does you'll have improved your mental model of How Things Work |
| 23:44 | adiabatic | Hunh. I got away with it. Makes sense, since all the macro stuff I've heard about but haven't touched yet has facilities for evaluating things at different points… |
| 23:45 | clj_newb | after (defrecord Dog [name age]) and (defn new-dog ... (Dog. ... )) is there a way to hide Dog. ? I.e. I want the only way to create Dog objects is via new-Dog. If not, is there a way to give (defrecord Dog ... )a constructor? |