2009-12-22
| 00:00 | arohner | the way you can tell a new feature is good: when you want it everywhere |
| 00:00 | arohner | I want pre and post conditions on multimethods now |
| 00:15 | chouser | arohner: I believe they're planned for protocols |
| 00:33 | chouser | anyone up for a pop quiz? |
| 00:33 | scgilardi | and how! |
| 00:34 | chouser | ok! where, in legal clojure code, does # by itself indicate a comment until the end of the line? |
| 00:34 | scgilardi | *raises my hand* |
| 00:34 | chouser | hm, maybe more of a riddle than a quiz. |
| 00:35 | chouser | yes, Mr. Gilardi? |
| 00:35 | scgilardi | On the first line of a file to be loaded |
| 00:36 | scgilardi | We support the shebang |
| 00:37 | chouser | ah, but I specifically said "# by itself" You're right that #! is a comment to the end of the line. |
| 00:37 | scgilardi | d'oh! |
| 00:37 | chouser | this is too hard. |
| 00:38 | _mst | hm, does #_ fail for the same reason then? |
| 00:38 | chouser | It's not really fair to ask such questions when I just stumbled on an answer that I didn't know myself. |
| 00:38 | scgilardi | let's keep the floor open for a while |
| 00:38 | chouser | _mst: right. #_ requires the _ and is also only to the end of the form, not the end of the line. |
| 00:39 | chouser | I have a couple hints that I think wouldn't give it completely away. |
| 00:39 | _mst | right, yep |
| 00:39 | scgilardi | fair enough |
| 00:39 | chouser | hint now, or wait a bit? |
| 00:40 | scgilardi | I'd say wait a bit |
| 00:48 | chouser | ok, first hint: |
| 00:49 | chouser | though the comment extends until the end of a line according to the applicable docs, there is actually one other character than can end the comment early. |
| 00:51 | scgilardi | yep, that didn't give it away. :-) |
| 00:51 | danlarkin | scgilardi loves his quizzes |
| 00:54 | chouser | :-) |
| 00:55 | scgilardi | is this behavior present in the 1.1 release candidate? |
| 00:55 | chouser | yes. Also 1.0 and 'new' |
| 00:56 | chouser | you're all going to hate me. |
| 00:56 | chouser | ok! thanks! |
| 00:57 | chouser | ah well |
| 00:57 | chouser | second hint: |
| 00:58 | chouser | I very much doubt Rich would be able to answer this. |
| 00:58 | scgilardi | now there's an intriguing hint |
| 00:59 | tomoj | I can't even see how you can have a # by itself at all |
| 01:00 | danlarkin | does this work? #\n(comment ...) |
| 01:00 | chouser | tomoj: oh? do go on... |
| 01:01 | chouser | danlarkin: you get "No dispatch macro for:" ... either \ or an actual newline char, depending on how you meant that. |
| 01:01 | chouser | ...which is I suppose what tomoj is referring to. |
| 01:02 | chouser | The only other hint I can think of is to say what the "other character" is in the first hint. |
| 01:06 | scgilardi | what kinds of reads bypass the normal reader? |
| 01:06 | chouser | excellen question! |
| 01:06 | chouser | excellent, even. |
| 01:07 | scgilardi | regex springs to mind... |
| 01:08 | danlarkin | this is tricky, I'm running out of ideas |
| 01:10 | scgilardi | hehe |
| 01:10 | chouser | scgilardi: you found it? |
| 01:11 | scgilardi | I think so. checking |
| 01:12 | scgilardi | when compiling a Pattern using #", with COMMENTS mode on: In this mode, whitespace is ignored, and embedded comments starting with # are ignored until the end of a line. |
| 01:12 | scgilardi | not sure exactly how to construct that yet |
| 01:13 | chouser | scgilardi: ha! beautiful! |
| 01:13 | lisppaste8 | Chouser pasted "Where in Clojure code # by itself indicates a comment to the end of the line" at http://paste.lisp.org/display/92465 |
| 01:14 | scgilardi | very nice1 |
| 01:14 | scgilardi | and very nice! too! |
| 01:15 | chouser | scgilardi: quite impressive. I really don't think I could have done it from your end. |
| 01:16 | chouser | I needed a comment in my regex and had to go look it up when my first guess of /* comment */ failed. :-P |
| 01:17 | scgilardi | :) thanks! |
| 01:17 | scgilardi | I had no idea the pattern compiler supported humans. |
| 01:17 | scgilardi | The Rich Hickey hint was a good one. |
| 01:18 | chouser | learned about the "x" flag when doing very evil perl things. |
| 01:19 | scgilardi | so the "other character" is "e ? |
| 01:20 | scgilardi | (spelled the usual single character way...) |
| 01:20 | chouser | scgilardi: right |
| 01:20 | scgilardi | very cool. time to sleep while I'm ahead. Thanks for the fun. |
| 01:20 | chouser | ,(re-find #"(?x)foo # comment until the quote" "foobar") |
| 01:21 | clojurebot | "foo" |
| 01:21 | replaca | _ato: are you in channel? |
| 01:21 | chouser | scgilardi: good night, thanks for playing. -) |
| 01:21 | scgilardi | :) |
| 01:21 | chouser | :-) |
| 03:36 | hiredman | ya'll wanna see something cool? |
| 03:36 | hiredman | http://www.thelastcitadel.com/images/Screenshot-Clojure.png |
| 03:36 | piccolino | So if I have multiple threads working and I want to serialize their writes to a file, the way to do that is with a regular Java lock? |
| 03:36 | hiredman | piccolino: seems like most people would use an agent |
| 03:36 | piccolino | Ah, that was my first thought, but the agent docs said that the functions should be side-ffect free. |
| 03:37 | hiredman | I think I would use a linkedblockingqueue |
| 03:38 | piccolino | How so? |
| 03:38 | hiredman | piccolino: that doesn't seem to stop people from using agents for that kind of thing |
| 03:39 | piccolino | I see. Don't agents have the possibility of re-trying? |
| 03:39 | hiredman | piccolino: not that I recall |
| 03:40 | hoeck | hiredman: which toolkit is this, SWT? |
| 03:42 | piccolino | Looks like Dr Scheme. |
| 03:46 | hiredman | swing |
| 03:52 | hiredman1 | ugh |
| 03:55 | piccolino | Ah, I see, their state should be an immutable object, but they don't need to be side-effect free. |
| 03:57 | replaca | piccolino: you might want to take a look at cloure.comtrib.seq-utils/fill-queue |
| 03:58 | replaca | piccolino: mmm, that probably doesn't do exactly what you want, but you might get a good idea from it |
| 04:01 | hiredman | ~ping |
| 04:01 | clojurebot | PONG! |
| 04:05 | piccolino | Hm, yeah, I'm afraid I'm not quite sure how to use this for what I want to do. |
| 04:08 | scottj | hiredman: what I think would be cool in a graphical repl is displaying sql query results in a sortable table |
| 04:12 | cark | hiredman : you're going for a "lisp machine style" repl ? |
| 04:13 | cark | or CLIM style |
| 04:24 | johnmn3 | hiredman: looks cool! |
| 04:26 | johnmn3 | some of the boxes look a little awkward, but that can probably be fixed. |
| 04:27 | hiredman | it is very awkward |
| 04:28 | cark | you need inspectable return values now =) |
| 04:29 | ordnungswidrig | what did I miss? Graphical Repl? |
| 04:29 | johnmn3 | yea, looks cool |
| 04:33 | hiredman | cark: that sounds painful |
| 04:33 | johnmn3 | hiredman: are you going to leave the gray background on there? |
| 04:33 | hiredman | johnmn3: I don't know |
| 04:34 | johnmn3 | embed JTrees. Could Rich's inspector work? |
| 04:34 | cark | hiredman : http://en.wikipedia.org/wiki/File:Listener.png |
| 04:35 | hiredman | http://gist.github.com/261648 |
| 04:36 | johnmn3 | yea, that's a little more advanced. |
| 04:36 | cark | wew i'm trying to find ome pictures of a clim repl with inspectable content, and google already has my last sentenses int here |
| 04:36 | cark | that's scary =/ |
| 04:38 | cark | anyways what i mean is : you get a textual response from your repl, but you may click it to get an inspector |
| 04:38 | cark | that would aleviate the infinite sequence printing problem |
| 04:39 | johnmn3 | what's with the *->ops convention you use? what does that mean? |
| 04:40 | johnmn3 | does bq stand for Blocking Queue? |
| 04:47 | hiredman | yes |
| 04:47 | hiredman | blockingqueu to outputstream |
| 04:48 | hiredman | ack, the code I gisted is broken |
| 04:48 | hiredman | I was adding scaling to images |
| 04:49 | johnmn3 | pretty sweet. I like how short your programs are (that you've listed here). after a little bit I can understand it.. useful learning examples. |
| 04:51 | hiredman | :) |
| 04:51 | johnmn3 | and they're actually useful too. |
| 05:22 | alexott | i have short question - how i can create instance of java class, that is internal in other java class? |
| 05:22 | alexott | so for example, in java it created as M.Class(), but how i can create it in clojure? |
| 05:23 | cark | (new M$Class) i think |
| 05:25 | alexott | cark: thanks, I'll try |
| 05:27 | alexott | cark: hmm, doesn't work |
| 05:27 | cark | try fully qualifying your outer class |
| 05:28 | alexott | cark: ok, with fully qualified name it works. thank you |
| 05:29 | ordnungswidrig | I shouldn't try (repeat 1) in the graphical repl, though... |
| 05:29 | cark | the thing is : you need to import the inner class the same way you do for the outer one |
| 05:30 | cark | then you can use the short hand version |
| 05:32 | alexott | cark: ok, thank you... I'm not java programmer, so i don't know much details :-( |
| 05:34 | cark | me neither =) |
| 05:57 | johnmn3 | this trick: |
| 05:57 | johnmn3 | (future |
| 05:57 | johnmn3 | (while true |
| 05:57 | johnmn3 | never would have guessed I could do that. |
| 05:58 | johnmn3 | does that spawn a thread? |
| 05:58 | Chousuke | yes. |
| 05:59 | johnmn3 | hmm |
| 05:59 | Chousuke | you might want to include some way to stop the thread :P |
| 05:59 | Chousuke | (while @*running* ...) is one way |
| 05:59 | Chousuke | where *running* is a global atom |
| 06:00 | johnmn3 | ok |
| 06:00 | johnmn3 | in this instance, it's a repl running on a gui.. hiredman's gui repl |
| 06:02 | johnmn3 | illustrative use of a defmulti in there. |
| 08:09 | prhlava | hello, I have solved one usage scenario for usage of gridgain and clojure, the modification: Var.intern(CLOJURE_NS, Symbol.create("*use-context-classloader*"), F) in RT.java made peer class loading work under gridgain. Is class loading in clojure due to overhaul at some time? |
| 08:10 | Jules_ | How would you represent algebraic data types in Clojure? For example regular expressions like type regex = Char of char | Comp of regex * regex | Alt of regex * regex | Star of regex |
| 08:11 | Jules_ | Should I use maps with a :type field that is :char, :comp, :alt or :star? |
| 08:13 | interferon | is there a way to start clojure with *print-level* set to 2? |
| 08:13 | interferon | user.clj doesn't let me set! variables |
| 08:14 | prhlava | interferon: put it into "init.clj" file and call clojure with --init argument. |
| 08:15 | interferon | actually, is there a way to do it just from slime? |
| 08:15 | rhickey | java -cp clojure.jar clojure.main -e "(set! *print-level* 2)" -r |
| 08:17 | ilowry | Hello! Could anybody help me with Emacs clojure-mode & slime please? |
| 08:18 | ilowry | I've just intalled them, but every time I try to execute any expression in slime it just hungs. |
| 08:18 | ilowry | In the same time I able to execute the same form from *inferior-lisp* buffer |
| 08:19 | prhlava | ilowry: i did this (under debian and arch linuxen): http://riddell.us/tutorial/slime_swank/slime_swank.html |
| 08:20 | interferon | rhickey: thanks |
| 08:24 | ilowry | prhlava: thanks. I suppose I've done something similar. My config is here: http://paste.org/pastebin/view/13408. I use separately installed slime |
| 08:26 | prhlava | ilowry: what happens (in emacs) when you do?: M-x slime |
| 08:26 | prhlava | ilowry: do you get clojure prompt? |
| 08:27 | ilowry | prhlava: Yes I get clojure prompt and able to type something there. But nothing happens when I hit Enter. |
| 08:29 | ilowry | btw, swank-clojure I've got gave me WARNINGS about deprecated ^ macro, until I patched it to use (meta ..) instead |
| 08:30 | prhlava | ilowry: one thing - i use the latest repository versions for all: clojure-mode, slime, swank-clojure . Emacs is: GNU Emacs 23.1.1 . Is it possible that slime would be too old (they develop rapidly)? |
| 08:32 | prhlava | ilowry: I get the same warning about ^ but it works. But I do not use paredit... |
| 08:34 | ilowry | prhlava: yes, I've got the latest versions of the all from repositories. |
| 08:35 | prhlava | ilowry: :-/ |
| 08:35 | ilowry | prhlava: the problem appeared before I added paredit |
| 08:36 | prhlava | ilowry: :-/ :-/ is this clojure 1.0 or 1.1? I am using 1.1 snapshot at the moment (but could try with 1.0 easily).... |
| 08:37 | ilowry | prhlava: it is 1.1. got it from github |
| 08:37 | ilowry | prhlava: built it with 'ant clean jar' and just 'ant' |
| 08:40 | prhlava | ilowry: pretty much what I did. For me, I pretty much followed the short guide (in the above link) and it just worked. I do update clojure-mode, slime, swank-clojure regularly and so far it just works. One thing I noticed that you do not use absolute paths in your config... |
| 08:40 | prhlava | ilowry: but it starts, so :-/ |
| 08:41 | ilowry | prhlava: I'm under Mac OS X 10.5 and emacs (23.1.90) is from http://emacsformacosx.com/ |
| 08:45 | ilowry | prhlava: it maybe that something in my Emacs init file interferes with swank clojure. I need to look at it more carefully. Thanks for your help |
| 08:45 | prhlava | ilowry: my work os is linux (debian or archlinux). Both work. My experience with macs is close to zero... But as far as I understand slime works over network socket, so maybe some security/firewall thing? |
| 08:45 | prhlava | ilowry: you are welcome.... |
| 08:47 | prhlava | I would need to do (def clojure.core/*use-context-classloader* false) from code, but this does not work from user name space) Do I have to switch to clojure.core namespace or there is a way to set this symbol? |
| 08:48 | ilowry | prhlava: not sure this is a socket problem, as the other slime clients (sbcl, clozure CL) work fine, but I'll check |
| 08:49 | prhlava | ilowry: aha, then I am still puzzled. Good luck. |
| 08:49 | ilowry | prhlava: thanks |
| 08:51 | prhlava | have to go |
| 08:53 | Xenon1 | ilowry: Maybe you could try this : http://github.com/citizen428/ClojureX It installs everything you need for using clojure with Emacs and TextMate. It worked flawlessly for me (both with Aquamacs and Emacs for MacOSX) |
| 08:55 | ilowry | Xenon1: Thanks for the link. I'll look it. But I just can not understand what is wrong with my current setup |
| 08:58 | Xenon1 | ilowry: Well, if you install ClojureX you might compare the two setups and spot the problem ;) |
| 08:59 | ilowry | Xenon1: it maybe. thanks :) |
| 09:29 | LauJensen | Was ForkJoin included in JDK7 ? |
| 09:35 | LauJensen | ~ google forkjoin included in jdk 7 |
| 09:35 | clojurebot | First, out of 819 results is: |
| 09:35 | clojurebot | fahd.blog: JDK 7 - Fork-join and ParallelArrays |
| 09:35 | clojurebot | http://fahdshariff.blogspot.com/2008/04/jdk-7-fork-join-and-parallelarrays.html |
| 09:43 | ilowry | puff! Just solved the hung problem with closure-mode & swank-closure in Emacs. The reason seemed to be in slime-fancy module. After I removed it from the list given to (slime-setup ...) function in my Emacs init file, I was able to interact with clojure in slime. Just in case it can help somebody else. |
| 10:14 | chouser | with the same pride as one might reinvent the wheel |
| 10:14 | chouser | perhaps I should read about it a bit first |
| 10:23 | cburroughs | Following java practices I have namspaces that look like tld.company.foo.bar.bax.qux.partIactuallyCareAbout. This looks really annoying in the repl. Is there any way to shorten that in general (or just in slime)? |
| 10:27 | chouser | there are some advocating abandoning the Java conventions and going for more of a uniquepackage.PartThatMatters |
| 10:27 | chouser | and you can use 'import' -- that's about it, I'm afraid. |
| 10:30 | cburroughs | As someone working with lots of java people, I think the convention is for the best. I just want a way to mitigate the pain of a 60+ character promt |
| 10:33 | chouser | oh, just in the prompt? |
| 10:33 | chouser | I think there's a way to fix that. |
| 10:44 | rhickey | package aliases are a possibility |
| 10:45 | chouser | I would love package (and class) aliases. |
| 10:45 | rhickey | chouser: which? |
| 10:46 | chouser | hm? both! |
| 10:47 | rhickey | sounds complicated |
| 10:47 | cemerick | class aliases sound like trouble |
| 10:48 | chouser | for inner classes especially would be useful. |
| 10:48 | rhickey | chouser: these are inner classes with statics or enums, where you need to use the classname often? |
| 10:49 | rhickey | since you could always make an encapsulating ctor function |
| 10:49 | harrison | hm. does reify not support [& rest] methods, or am i just messing it up somewhere? |
| 10:50 | rhickey | harrison: does not |
| 10:50 | cemerick | yeah, I can see that. I've typed Field$Store/YES too much. |
| 10:52 | cemerick | still, just def-ing those constants seems like a better option than classname aliasing |
| 10:53 | rhickey | are we ready for RC2 ? or 1.1? |
| 10:53 | cburroughs | So in summary there is no in clojure solution now, but chouser thinks there might be some sort of slime magic? |
| 10:53 | chouser | rhickey: right, class names used as value (enums, constants) and type hints |
| 11:14 | chouser | cburroughs: in a normal terminal you can launch a repl with a custom :prompt set. I dunno if slime can leverage that or perhaps has something similar. |
| 11:15 | cburroughs | chouser, Thanks, I'll look into it |
| 11:26 | fliebel | Why doesn't await(-for) return the agent? I was surprised when I found out it did not. It's as simple as adding agent to the last line, isn't it? Can't hurt, in my opinion… |
| 11:29 | fliebel | alexyk: How is clojure-twitter doing? |
| 11:30 | alexyk | fliebel: fine, oauth works |
| 11:30 | fliebel | cool |
| 11:38 | chouser | fliebel: await takes any number of agents args. you want it to return a seq of those same agents? |
| 11:39 | fliebel | chouser: Hmmm, in that case it would not be logical to do so, but I think that most of the time you only use one. |
| 11:40 | fliebel | But in this case it would be a nice thing (pritnln (await (some-agent-returning-function))) |
| 11:41 | fliebel | Now I had to do (let [thing (function] (await thing) (println thing)) |
| 11:42 | notostraca | I am new to Clojure, and I have no idea how to package an executable jar -- how do the fine people of #clojure do it? |
| 11:42 | chouser | (doto (return-agent) await println) |
| 11:43 | aking | notostraca: I've started using leiningen - works well. To make a jar, you just type 'lein uberjar' |
| 11:44 | aking | notostraca: details at: http://github.com/technomancy/leiningen/ |
| 11:44 | notostraca | I couldn't figure out how to get it to work on windows |
| 11:44 | fliebel | chouser: would it be very confusing to add this to the end of await? (when (= (count agents) 1) (first agents)) |
| 11:44 | aking | notostraca: I'm not on windows, sorry - but I believe they are working on windows support - check the maillist |
| 11:45 | notostraca | ah |
| 11:45 | chouser | fliebel: you saw my doto idea? |
| 11:47 | fliebel | chouser: yea… it's better, but… It's just not what I expected it to do, just an idea to make Clojure more intuitive or confusing… because I agree that it's not a good thing to return a seq of them. |
| 11:48 | chouser | fliebel: yeah, I'm not sure. fortuately for me my opinion doesn't matter, just rhickey's. :-) |
| 11:48 | lpetit | does anybody have experience with Eclipse RAP ? |
| 11:49 | lpetit | Trying to choose between alternatives to extend our current desktop application to enterprise intranet (low number of users) |
| 11:49 | lpetit | GWT is an option, but would require us to rewrite the whole UI part,and make it more difficult to share existing stuff too |
| 11:50 | lpetit | But GWT would refrain us from adding clojure eventually (or just in the server part) |
| 11:50 | notostraca | hi lpetit, tommy.ettinger here |
| 11:50 | lpetit | notostraca: Hi tommy. Haven't forgotten you, but my "hacking night" is tuesday, so it's tonight :-) |
| 11:51 | notostraca | yay for hacking night :-) |
| 11:51 | lpetit | notostraca: but still at work currently |
| 11:51 | notostraca | ah, can you use clojure there? |
| 11:54 | lpetit | nope |
| 11:54 | lpetit | not yet ;-) |
| 11:54 | lpetit | but thinking about it very har |
| 11:54 | lpetit | d |
| 11:57 | fliebel | chouser: Your doto doesn't work for me for some reason… I tried using an anonymous function, but nothing happened. |
| 12:00 | pdk | hm, what could be wrong with this syntax: (doseq [x enables] (. GL11 glEnable x)) |
| 12:00 | pdk | "unable to resolve symbol: x in this context" |
| 12:01 | pdk | though could it be cause i used into-array to construct enables |
| 12:01 | chouser | ,(doto (agent 6) (send inc) await) |
| 12:01 | clojurebot | #<Agent@5df3c5: 7> |
| 12:02 | fliebel | chouser: hey, the thing returned the agent, so I could put my own function outside the doto. |
| 12:03 | chouser | yes, doto returns it's first arg |
| 12:03 | fliebel | nice... |
| 12:06 | chouser | pdk: that's weird. |
| 12:12 | lpetit | pdk: shouldn't it be (doseq [x enables] (. GL11 (glEnable x))) or even better (doseq [x enables] (.glEnable GL11 x)) ? |
| 12:12 | chouser | probably (GL11/glEnable x) |
| 12:13 | chouser | anything starting with dot and a space should be avoided except perhaps when emiting code |
| 12:13 | pdk | hm changed it around a bit |
| 12:13 | chouser | but that doesn't explain the x error |
| 12:13 | pdk | (doseq [x (range (alength enables))] (. GL11 glEnable (aget enables x))) seems to run now |
| 12:14 | pdk | is this a known issue with doseq's handling of java arrays |
| 12:14 | chouser | no |
| 12:14 | lpetit | ,(doseq [x ["a"]] (. (java.util.ArrayList.) add x) |
| 12:14 | clojurebot | EOF while reading |
| 12:14 | lpetit | ,(doseq [x ["a"]] (. (java.util.ArrayList.) add x)) |
| 12:14 | clojurebot | nil |
| 12:15 | chouser | ,(let [enables (into-array ["1" "2" "3"])] (doseq [x enables] (prn (Integer/parseInt x)))) |
| 12:15 | clojurebot | 1 2 3 |
| 12:16 | chouser | there shouldn't be any way to be inside (doseq [x anything] ...) and have x be undefined |
| 12:32 | jneira | , (reduce + 1 '(1 2 3)) |
| 12:32 | clojurebot | 7 |
| 12:33 | jneira | @src reduce |
| 12:33 | jneira | jum |
| 12:36 | pdk | ,(doseq [x (range 3) y (range 4)] (print (str "x: " x "; y: " y " -- "))) |
| 12:36 | clojurebot | x: 0; y: 0 -- x: 0; y: 1 -- x: 0; y: 2 -- x: 0; y: 3 -- x: 1; y: 0 -- x: 1; y: 1 -- x: 1; y: 2 -- x: 1; y: 3 -- x: 2; y: 0 -- x: 2; y: 1 -- x: 2; y: 2 -- x: 2; y: 3 -- |
| 12:37 | chouser | I'm scared. |
| 12:37 | chouser | I think point-free style is starting to become more attractive to me. |
| 12:37 | chouser | someone help me quick! |
| 12:37 | pdk | point-free as in |
| 12:38 | chouser | (partial deliver p) instead of #(deliver p %) |
| 12:39 | jneira | , (source map) |
| 12:39 | clojurebot | java.lang.Exception: Unable to resolve symbol: source in this context |
| 12:39 | chouser | ~def map |
| 12:39 | pdk | hm |
| 12:39 | jneira | thnxs chouser |
| 12:39 | pdk | is bitwise-right-shift implemented in terms of java >> or >>> |
| 12:39 | jneira | my snd time in irc channel |
| 12:40 | chouser | jneira: except it doesn't seem to work. :-/ |
| 12:40 | chouser | hiredman: I think github changed their line ids. it's #LID1705 now instead of #L1705 |
| 12:40 | pdk | er bit-shift-right that is |
| 12:40 | jneira | the link goes to map definition |
| 12:41 | chouser | jneira: hm, didn't for me. glad it worked for you. :-) |
| 12:41 | powr-toc | chouser: any word on textjure? :-) |
| 12:41 | chouser | powr-toc: dead dead dead |
| 12:42 | chouser | or at least indefinitely abandoned. I just don't have time for it right now. |
| 12:42 | Chousuke | chouser: point-free style is just fine as long as you don't overdo it :P |
| 12:42 | Chousuke | fortunately, it's pretty easy to tell when you are overdoing it. |
| 12:42 | powr-toc | chouser: how far did you get with it? |
| 12:43 | jneira | , (clone chouser) |
| 12:43 | clojurebot | java.lang.Exception: Unable to resolve symbol: clone in this context |
| 12:43 | jneira | jum |
| 12:43 | chouser | powr-toc: a pretty simple swing-based repl with careful output handling |
| 12:43 | devlinsf | ,(let [c (transient {})] |
| 12:43 | clojurebot | EOF while reading |
| 12:43 | devlinsf | (do |
| 12:43 | devlinsf | (assoc! c :a 1) |
| 12:43 | devlinsf | (assoc! c :b 2) |
| 12:43 | devlinsf | (assoc! c :c 3) |
| 12:43 | devlinsf | (persistent! c))) |
| 12:43 | devlinsf | Hmmm... |
| 12:43 | powr-toc | chouser: what do you mean by careful output handling? |
| 12:44 | chouser | powr-toc: errors, printed output, and return values are all colored differently. missing eol's are flagged but formatted nicely anyway. |
| 12:45 | chouser | devlinsf: stop abusing the transient! |
| 12:45 | devlinsf | chouser: Oh Yeah? |
| 12:45 | devlinsf | ,(let [c (transient {})] (assoc! c :a 1) (persistent! c))) |
| 12:45 | clojurebot | {:a 1} |
| 12:45 | chouser | powr-toc: I started working on a flexible keybinding system to support both emacs and vim-style bindings, but got bogged down and distracted. |
| 12:46 | chouser | devlinsf: right, don't do that. |
| 12:46 | powr-toc | chouser: missing eols? |
| 12:46 | devlinsf | chouser: Seriously? |
| 12:46 | chouser | devlinsf: seriously. |
| 12:46 | devlinsf | chouser: what's going on I don't see? |
| 12:46 | devlinsf | chouser: Sorry, I'm trying to check some of the docs |
| 12:47 | chouser | I'm trying to come up with a breaking example. |
| 12:47 | hiredman | chouser: gah |
| 12:47 | devlinsf | chouser: for transients? |
| 12:47 | Chousuke | ,(let [a (transient {})] (dotimes [i 20] (assoc! a i)) (persistent a)) |
| 12:47 | clojurebot | java.lang.Exception: Unable to resolve symbol: persistent in this context |
| 12:48 | Chousuke | ,(let [a (transient {})] (dotimes [i 20] (assoc! a i)) (persistent! a)) |
| 12:48 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: core$assoc-BANG- |
| 12:48 | Chousuke | hm |
| 12:48 | Chousuke | gah |
| 12:48 | Chousuke | ,(let [a (transient {})] (dotimes [i 20] (assoc! a i i)) (persistent! a)) |
| 12:48 | clojurebot | {0 0, 1 1, 2 2, 3 3, 4 4, 5 5, 6 6, 7 7} |
| 12:48 | Chousuke | see |
| 12:48 | devlinsf | Riht |
| 12:48 | devlinsf | Right |
| 12:48 | devlinsf | anyone: There's a statement in the transient docs I don't get |
| 12:49 | devlinsf | From the transient page, at the bottom : "Can't use after returning a persistent version" |
| 12:49 | devlinsf | ,(let [c (transient {})] (assoc! c :a 1) (persistent! c) (assoc! c :b 2) (persistent! c))) |
| 12:49 | clojurebot | {:a 1, :b 2} |
| 12:49 | devlinsf | Is that right? |
| 12:50 | Chousuke | hmm. I thought that would throw an exception :/ |
| 12:50 | chouser | me too |
| 12:50 | devlinsf | So did I |
| 12:50 | devlinsf | Is this a bug? |
| 12:50 | chouser | devlinsf: do you understand the earlier point though? it's important. |
| 12:50 | devlinsf | No |
| 12:51 | chouser | devlinsf: you have to use the return value of assoc!, just like you do with the return value of assoc |
| 12:51 | devlinsf | I see that only 7 items were read |
| 12:51 | devlinsf | Ah |
| 12:51 | hiredman | chouser: #L111 and #LID111 both seem to work |
| 12:51 | Chousuke | devlinsf: transients can't be used to write imperative algorithms |
| 12:51 | devlinsf | Yeah, I know that's what you want |
| 12:51 | Chousuke | devlinsf: they are not quite mutable :) |
| 12:51 | devlinsf | It's not how they behave |
| 12:51 | chouser | hiredman: #L1705 didn't for me in firefox 3.0. *shrug* |
| 12:52 | powr-toc | chouser: what did you mean by missing eols are flagged but formated? |
| 12:52 | devlinsf | Hmmm... oh |
| 12:52 | devlinsf | I now see you example about dotimes |
| 12:52 | hiredman | chouser: firefox and github don't play nice |
| 12:53 | hiredman | at work on windows with firefox 3.5 the line numbers never work for core.clj |
| 12:53 | chouser | powr-toc: I mean at a regular terminal repl, if you do (print "hi"), you actually see "hinil". textjure breaks them onto separate lines but sticks a different-colored marker after hi to indicate there was no newline. |
| 12:53 | devlinsf | Anyway, is my post persistent! modification a bug? |
| 12:53 | chouser | hiredman: ok. sorry for the noise. :-) |
| 12:54 | rhickey | devlinsf: correct use of transients is simple - write it without them, then add transient ,!s and persistent! |
| 12:54 | hiredman | I changed it to #LID anyway |
| 12:54 | chouser | devlinsf: I think so. |
| 12:54 | chouser | ,(let [c (transient [])] (persistent! c) (conj! c :x)) |
| 12:54 | clojurebot | java.lang.IllegalAccessError: Mutable used after immutable call |
| 12:54 | chouser | looks like hash-maps forgot to implement it |
| 12:54 | powr-toc | chouser: ahhh gotcha... I've just fired it up now... Is there a way to eval expressions from the text area in the repl? |
| 12:55 | devlinsf | rhickey: See my assoc! exmple, though? |
| 12:55 | chouser | powr-toc: no, the top text-area is dead. |
| 12:55 | rhickey | devlinsf: which one? |
| 12:55 | devlinsf | (let [c (transient {})] (assoc! c :a 1) (persistent! c) (assoc! c :b 2) (persistent! c))) |
| 12:56 | hiredman | http://www.thelastcitadel.com/images/Screenshot-Clojure.png :D |
| 12:56 | devlinsf | ,(let [c (transient {})] (assoc! c :a 1) (persistent! c) (assoc! c :b 2) (persistent! c))) |
| 12:56 | clojurebot | {:a 1, :b 2} |
| 12:56 | devlinsf | granted, I'm misusing transients |
| 12:56 | rhickey | devlinsf: how would that have bee ncorrect without transient stuff? |
| 12:56 | chouser | powr-toc: someone forked it on github and hooked up the text area to real files (though without my keybinding stuff). But the repo seems to be gone? :-( |
| 12:56 | powr-toc | chouser: ok... so right now the only features it has that seperate it from the standard repl, are that it's swing based and has some fancy(ish) output handling |
| 12:57 | devlinsf | rhickey I'm modifying the map after psersistent! |
| 12:57 | chouser | hiredman: nice! |
| 12:57 | chouser | powr-toc: right. hardly even worth existing. :-/ |
| 12:57 | devlinsf | ,(let [c (transient {})] (-> c (assoc! :a 1) (persistent!) (assoc! :b 2) (persistent!))) |
| 12:57 | clojurebot | java.lang.ClassCastException: clojure.lang.PersistentArrayMap cannot be cast to clojure.lang.ITransientAssociative |
| 12:57 | devlinsf | That works right, though |
| 12:58 | powr-toc | chouser: Well... maybe not :-) |
| 12:58 | devlinsf | So I guess my question is that does my misused behavior constitute a bug? |
| 12:58 | chouser | powr-toc: but keybindings without a repl would have been equally useless. Maybe I should have started with the hard part. -) |
| 12:58 | hiredman | http://gist.github.com/261648 |
| 12:59 | chouser | I do think this is meant to throw an exception. Not sure how important it is. |
| 12:59 | chouser | ,(let [c (transient {})] (persistent! c) (assoc! c :x :y)) |
| 12:59 | clojurebot | #<TransientArrayMap clojure.lang.PersistentArrayMap$TransientArrayMap@104a681> |
| 12:59 | devlinsf | Yup |
| 13:00 | devlinsf | chouser: Saw the same thing this morning at my REPL |
| 13:00 | powr-toc | chouser: I'm a bit tired of not having a good clojure project to get stuck into so I can really learn this lisp and this damn language I find so interesting... anyway I was thinking a paredit style structure editor of somesort might be interesting |
| 13:00 | rhickey | chouser: yes, patch welcome |
| 13:01 | defn | anyone have any better ideas on writing this: http://gist.github.com/261911 |
| 13:02 | defn | quick note: sort-ns doesn't sort anything anymore :) |
| 13:03 | chouser | powr-toc: would love to have that. Though it requires discipline to keep GUIs from ruining the rest of your Clojure code. |
| 13:03 | chouser | rhickey: against 1.1.x? I guess the patch will probably apply fine either way. |
| 13:04 | rhickey | chouser: no, master |
| 13:06 | rhickey | I'd like to cut a 1.1 release soon |
| 13:06 | chouser | what's it blocking on if not bugs? |
| 13:06 | chouser | worse bugs than we're finding? |
| 13:07 | rhickey | yes |
| 13:07 | defn | http://gist.github.com/261913 <---is that indentation correct? |
| 13:07 | rhickey | correctly formed transient code would never create that last bug |
| 13:09 | chouser | yes of course. It's just one of the checks built it to make transients safer to have in the language. |
| 13:12 | rhickey | chouser: the bigger issue is I'm unable to enforce serial usage (as distinct from same-thread) - I'm working on ideas for this. That's one reason I marked transients as alpha |
| 13:14 | chouser | to prevent bashing in place? |
| 13:18 | pdk | ,(print (bit-shift-right -1)) |
| 13:18 | clojurebot | java.lang.IllegalArgumentException: Wrong number of args passed to: core$bit-shift-right |
| 13:18 | pdk | ,(print (bit-shift-right -1 1)) |
| 13:18 | clojurebot | -1 |
| 13:19 | pdk | ,(print (bit-shift-right -255 1)) |
| 13:19 | clojurebot | -128 |
| 13:19 | pdk | so >> |
| 13:20 | pdk | that indentation appears correct defn |
| 13:20 | pdk | though emacs can reindent a line to where it should be if you press tab on the line |
| 13:35 | alexyk | How do you declare map parameters in defns so that you can call like (f :where a :only b) ? |
| 13:36 | hiredman | :( |
| 13:37 | hiredman | apply hash-map |
| 13:38 | hiredman | ,((fn [& a] (let [{:keys [x y]} (apply hash-map a)] [x y])) :x 1 :y 2) |
| 13:38 | clojurebot | [1 2] |
| 13:44 | alexyk | ok! why sour face? |
| 13:44 | chouser | hiredman doesn't like keyword arguments. He wishes people just passed in maps. |
| 13:46 | chouser | don't we? |
| 13:47 | devlinsf | I don't think so |
| 13:47 | stuartsierra | There's a defnk in contrib, haven't looked at it in a while. |
| 13:47 | devlinsf | The use of &variadic-args and &&keyword-args everywhere is awesome |
| 13:48 | devlinsf | I've had this discussion many times with a Python buddy of mine, and I'm convinced it's more straightforward |
| 13:48 | devlinsf | (or is it * and ** ?) |
| 13:48 | chouser | *args **keyargs |
| 13:48 | devlinsf | Ah |
| 13:49 | pdk | chouser's got it |
| 13:49 | devlinsf | Anyway, I think it's the price we pay for being a lisp |
| 13:49 | chouser | hm. |
| 13:49 | pdk | though in python keyargs would become a dictionary and you could supply as many as you wanted |
| 13:49 | chouser | or being compatible with JVM calling conventions. |
| 13:49 | devlinsf | Yeah, not sure which |
| 13:50 | devlinsf | Anyway, the point is keyword args is one of many areas Python handles well |
| 13:51 | devlinsf | Granted, I'm not going to trade parens for whitespace anytime soon. |
| 13:51 | devlinsf | :) |
| 13:51 | fliebel | Quite a lot Python references around here… both pro- and anti-python... |
| 13:51 | devlinsf | If I had to go back to a normal language, it'd be Python |
| 13:52 | devlinsf | I'm coming from a Rails background, too |
| 13:52 | devlinsf | Anyway |
| 13:52 | fliebel | "normal", that sound like Clojure agains the rest of the world... |
| 13:52 | stuartsierra | Lisp always feels embattled. |
| 13:52 | jneira | , (doc pos?) |
| 13:52 | clojurebot | "([x]); Returns true if num is greater than zero, else false" |
| 13:53 | chouser | no longer finding mutable collections or local variable acceptible, the number of languages to choose from has been reduced dramatically for me. |
| 13:53 | devlinsf | Well, right |
| 13:53 | stuartsierra | chouser: basically Clojure, Erlang, and Haskell, right? |
| 13:54 | chouser | nareshov: interesting, isn't it? Wouldn't it be great if the author of the blog would write whole book about Clojure? |
| 13:54 | jneira | scala is out... |
| 13:54 | chouser | er |
| 13:54 | hiredman | now you are unaffected by the paradox of choice |
| 13:54 | chouser | jneira: I meant you, not nareshov. |
| 13:54 | chouser | hiredman: and happy! |
| 13:55 | fliebel | Is there a, well… normal way to add lines to the end of a function in vim? At the moment that involves moving some parens around. |
| 13:55 | jneira | jeje but not alone :-P |
| 13:56 | pdk | ,(doseq [x (into-array [1 2 3])] (print (str x " "))) |
| 13:56 | clojurebot | 1 2 3 |
| 13:56 | chouser | fliebel: (defn f [] ....), put cursor on opening paren, type %i<CR> |
| 13:56 | chouser | fliebel: is that what you mean? |
| 13:57 | alexyk | scala can be easily used in immutable way. Default List and Map is immutable, and so are val's. You have to ask for trouble and import mutable maps explicitly, and even rename themn is you still want to use immutable ones. |
| 13:57 | chouser | I learned immutable locals, collections, and lazy seqs (streams) in scala before picking up Clojure. |
| 13:58 | jneira | val x = new ... |
| 13:58 | alexyk | chouser: ah! a fellow polyglot :) |
| 13:58 | chouser | alexyk: I'm more of a serial polyglot. I leave my old langs behind. |
| 13:58 | chouser | when I can, anyway. |
| 13:59 | chouser | can't shake off this C++ |
| 13:59 | alexyk | chouser: the beauty of JVM is, neighbors don't go away and it's tempting to share. |
| 14:00 | alexyk | chouser: so how did you let go if static typing? :) |
| 14:00 | alexyk | of |
| 14:00 | stuartsierra | Sometimes I wish there were a JVM language with C-like semantics. |
| 14:00 | pdk | c++ reminds me of that old "lose the beer gut" weight loss ad where a guy is getting chased around town by a giant rolling gut |
| 14:00 | chouser | Scala's a pretty good cure for that, actually. "Oh, you want static types? Here take all THIS" |
| 14:00 | alexyk | stuartsierra: C-like means * |
| 14:01 | stuartsierra | C-like means tight control over the size of objects in memory. |
| 14:01 | alexyk | chouser: 2.8.0 is coming along nicely. Growth pains. I bet you jumped ship in a moment of befuddlement. :) |
| 14:01 | alexyk | stuartsierra: which means * :) |
| 14:02 | stuartsierra | alexyk: which means memory locality, more cache hits, better performance, ... |
| 14:02 | chouser | stuartsierra: I'm looking forward to small-vm targets for Clojure. Not sure what that means exactly -- maybe C or C++ with simple GC or maybe just reference counting. |
| 14:02 | jneira | mmm i talked about a clojure implementation in c |
| 14:03 | stuartsierra | chouser: That would definitely be interesting. |
| 14:03 | jneira | with (malloc .. ) |
| 14:03 | jneira | :_P |
| 14:03 | chouser | stuartsierra: I think alexyk means the literal C syntax * for pointers, not asking you to fill in blanks. |
| 14:03 | ieure | Argh. I read a piece on Hacker News last week about a dude who implemented Wide Finder in Clojure and had it running in eight minutes, but I can’t find the link now. Anyone have it handy? |
| 14:03 | alexyk | chouser: anyhow, Scala is a lure for Haskell crowd. And Clojure for Lisp one. So now they coexist, which is fun. I was pondering of a clojure/scala/jruby flow even. |
| 14:03 | chouser | jneira: no, not quite. The immutable collestions fall over if you have to manage memory explicitly. |
| 14:03 | alexyk | stuartsierra: yeah, I mean C is opinter-based, and JVM makes it moot. |
| 14:03 | alexyk | pointer |
| 14:03 | jneira | java = c - - |
| 14:04 | stuartsierra | alexyk: Oh, now I get it. |
| 14:04 | piccolino | http://meshy.org/2009/12/13/widefinder-2-with-clojure.html |
| 14:04 | alexyk | ieure: clojurebot: google concur next |
| 14:04 | ieure | piccolino, Thanks so much. |
| 14:04 | alexyk | member:clojurebot: google concur next |
| 14:05 | slashus2 | What about doing Clojure in the parrot vm? |
| 14:05 | alexyk | clojurebot: google concur next |
| 14:05 | clojurebot | First, out of 500000 results is: |
| 14:05 | clojurebot | ongoing · Concur.next |
| 14:05 | clojurebot | http://www.tbray.org/ongoing/When/200x/2009/09/27/Concur-dot-next |
| 14:05 | cemerick | alexyk: not sure about scala being a lure for the haskell crowd. Those I know that like haskell distinctly dislike scala. |
| 14:05 | fogus | chouser: Creating a small C gc shouldn't be too bad, there are probably dozens laying around the internet for the taking |
| 14:05 | chouser | fogus: right. |
| 14:05 | stuartsierra | Doing GC efficiently is hard, I don't think anything can keep up with the JVM. |
| 14:05 | alexyk | cemerick: #scala presents real practitioners who do both with blue-collar monads (called gonads). |
| 14:06 | chouser | no, the benefits would have to target specifically areas that JVM is weak |
| 14:06 | chouser | startup time, memory footprint |
| 14:06 | stuartsierra | bit-twiddling, multi-dim arrays, ... |
| 14:06 | jneira | and why not in python vm? |
| 14:06 | chouser | stuartsierra: yes, but native libs + jvm can mitigate a lot of that. |
| 14:06 | pdk | "scala coders got balls man" |
| 14:06 | chouser | jneira: sure! |
| 14:07 | alexyk | i.e., haskell people who don't have to do any real-world work (e.g. JVM) have a luxury to not like anything else; if, however, reality dawns, they start liking Scala real fast. |
| 14:07 | stuartsierra | chouser: true |
| 14:07 | fogus | stuartsierra: Probably right; but it would be a nice experiment to create a small C target geared toward Clojure |
| 14:07 | jneira | dysinger siad that python vm isnt mature ... |
| 14:07 | jneira | jum |
| 14:07 | stuartsierra | It's certainly more mature than Ruby, but not on par with the JVM. |
| 14:07 | cemerick | alexyk: from what I hear, F# is a more attractive target there, but that's complete heresay |
| 14:08 | cemerick | hearsay* |
| 14:08 | chouser | perl5 as a vm? |
| 14:08 | jneira | juass |
| 14:08 | jneira | clojure vm? |
| 14:08 | chouser | jneira: you mean write a new one from scratch? :-/ |
| 14:08 | cemerick | chouser: I know a fellow who wrote a scheme in perl5, put it into production @ his company :-) |
| 14:08 | chouser | ha! |
| 14:09 | chouser | beautiful |
| 14:09 | stuartsierra | One certainly can't complain that perl5 isn't mature. |
| 14:09 | jneira | it's a joke..jvm is a god choose |
| 14:09 | cemerick | he's trying to convince the bosses to let him open source it. |
| 14:09 | jneira | *good |
| 14:09 | alexyk | cemerick: I tried to love MS for F#, but it's too much. PowerShell instead of zsh? Instead of all Mac goodies, like, mine sweeper and solitaire? If there's a business need, though, F# is something special, and with all the VS support and task parallel library is finally a viable MS choice. |
| 14:09 | stuartsierra | Ever looked at the source code to Perl 5, though? Scary stuff, man. |
| 14:10 | chouser | jvm is brilliant as a first target platform. I'm looking forward to having other options. C, Objective-C, lua, JavaScript, etc. |
| 14:10 | chouser | golang |
| 14:10 | fogus | I'm looking forward to Clj-in-Clj... can we draw target platforms out of a hat? |
| 14:11 | chouser | :-) |
| 14:11 | pdk | clj for commodore 64 please |
| 14:11 | jneira | mmm .net is the snd platform ... |
| 14:11 | cemerick | js first, then cocoa/objc for some fun UI stuff |
| 14:11 | chouser | the first few will be hard as we run headlong into the kind of stuff Clojure .NET is already starting to deal with. |
| 14:11 | fliebel | fogus: what is the status of clj-in-clj? |
| 14:12 | chouser | Once those issues are resolved, I think the backends will be relatively straightforward to crank out. |
| 14:12 | fogus | fliebel: Don't quote me, but I think the seeds are being planted with reify, types, protocols. I'm not the person to ask |
| 14:14 | harrison | hmm. i was looking at MultiFn. looks like it could be made persistent quite easily. |
| 14:24 | jan__ | I'm trying to set up slime with clojure, but when I start slime in emacs, the embedded clojure can't find swank.clj on it's classpath |
| 14:24 | jan__ | can anyone tell me where I tell slime where it can find swank? |
| 14:25 | grantmichaels | jan__ at the brothel |
| 14:25 | polypus | :) |
| 14:25 | jan__ | ah, doubt that will work :) |
| 14:25 | pdk | http://riddell.us/tutorial/slime_swank/slime_swank.html step to "configure emacs" i think |
| 14:26 | pdk | though if you're on windows you could dl clojure in a box |
| 14:26 | jan__ | running on linux |
| 14:26 | jan__ | tried that "configure emacs" step, but it doesn't work |
| 14:26 | grantmichaels | jan__ you're here for MVCC, i know how you are =) |
| 14:26 | alexyk | back to our sheep |
| 14:27 | alexyk | ,((fn [& a] (let [{:keys [x y]} (apply hash-map a)] [x y])) :x 1 :y 2) |
| 14:27 | clojurebot | [1 2] |
| 14:27 | alexyk | now, if I want default values for x and y, what's the most gorges way to di them? :) |
| 14:27 | alexyk | do |
| 14:28 | cemerick | alexyk: you can provide defaults in map destructuring via :or |
| 14:28 | pdk | ,(let [x (into-array [[(int 1) 2] [3 4]])] (print (str (aget x 1) "; " (aget x 2) "; " (aget x 1 1) "; " (aget x 2 1) "; " x))) |
| 14:28 | clojurebot | java.lang.ArrayIndexOutOfBoundsException |
| 14:28 | pdk | ,(let [x (into-array [[(int 1) 2] [3 4]])] (print (str (aget x 0) "; " (aget x 1) "; " (aget x 0 0) "; " (aget x 1 0) "; " x))) |
| 14:28 | clojurebot | java.lang.IllegalArgumentException: Argument is not an array |
| 14:28 | alexyk | cemerick: where do I stick :or again? |
| 14:30 | pdk | ,(let [x (Integer[][].)] x) |
| 14:30 | clojurebot | java.lang.Exception: Expecting var, but Integer is mapped to class java.lang.Integer |
| 14:30 | jan__ | slime says Clojure 1.0.0--SNAPSHOT |
| 14:30 | jan__ | user=> java.io.FileNotFoundException: Could not locate swank/swank__init.class or swank/swank.clj on classpath: (NO_SOURCE_FILE:0) |
| 14:30 | jan__ | user=> user=> java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:3) |
| 14:30 | jan__ | user=> user=> java.lang.ClassNotFoundException: swank.swank (NO_SOURCE_FILE:5) |
| 14:30 | jan__ | user=> user=> |
| 14:30 | fliebel | What is a good way to learn all the functions that keep me from using loop? Like reduce, map, doseq, etc. It's not very easy to browse the whole api every time I need to write a loop. |
| 14:31 | dysinger | jan__: ! what the heck are you doing in here ? :P |
| 14:31 | chouser | Maybe the bottom half of http://clojure.org/sequences |
| 14:31 | chouser | fliebel: Maybe the bottom half of http://clojure.org/sequences ? |
| 14:31 | pdk | http://java.ociweb.com/mark/clojure/article.html has code examples of various looping constructs |
| 14:32 | fliebel | chouser: hmmmm, I'll look at that, although not very informative it does group them. |
| 14:32 | pdk | ,(let [x (into-array [(ints [1 2]) (ints [3 4])])] (print (str (aget x 0) "; " (aget x 1) "; " (aget x 0 0) "; " (aget x 1 0) "; " x))) |
| 14:32 | clojurebot | java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to [I |
| 14:33 | jan__ | dysinger: trying to see if someone could shed some light on what I'm doing wrong |
| 14:36 | alexyk | when testing destructuring, I currently do it like: ((fn [{k :k :or 10 v :v}] (print k v)) {:k 1 :v 2}) |
| 14:36 | alexyk | does (binding ...) do that too or only vars? |
| 14:37 | alexyk | is there a shorter way to test-destructure? |
| 14:40 | grantmichaels | dysinger: he saw the MVCC sign ... |
| 14:40 | pdk | ok what types can you pass to ints/floats/etc |
| 14:40 | mebaran151 | anybody here use enclojure with the latest clojure plugin |
| 14:40 | fliebel | What is a good implicit loop for going through a list and for every item verify a condition, and if it's true return that item. |
| 14:40 | mebaran151 | *clojure version, 1.1.0 master |
| 14:40 | mebaran151 | fliebel, filter? |
| 14:41 | mebaran151 | (filter verifier list) |
| 14:41 | lpetit | Mr Ettinger ? |
| 14:41 | fogus | fliebel: Are you building a list of the results? If so, then probably `for` |
| 14:41 | chouser | ,((fn [{k :k v :v :or {v 10}}] (print k v)) {:k 1}) |
| 14:41 | clojurebot | 1 10 |
| 14:42 | fliebel | mebaran151: no, I want to return the first match only, not all that match. I might do first on the result, but that seems like a waste of recourses. |
| 14:42 | fliebel | fogus: no, only the first matching item |
| 14:43 | chouser | fliebel: no waste using 'first' -- filter is lazy! |
| 14:44 | mebaran151 | yeah I thought filter was lazy |
| 14:44 | chouser | you could also make 'some' work, though it may be awkward depending on your exact case. |
| 14:44 | fliebel | chouser: so it's going to filter until it finds one match? |
| 14:44 | fliebel | I'll check out some |
| 14:44 | mebaran151 | more like, when you ask for the first element, it'll run through the list until it finds one that matches |
| 14:45 | fogus | ,(some #{3} [1 2 3 4]) |
| 14:45 | clojurebot | 3 |
| 14:45 | chouser | fliebel: not until you call 'first' on it, but yeah. |
| 14:45 | fogus | this is a special case though |
| 14:46 | piccolino | Does send-off create a new thread every time you call it on the same agent? |
| 14:47 | chouser | piccolino: good question! Pretty sure it doesn't, but I'll check. |
| 14:48 | chouser | piccolino: no, it does not. |
| 14:48 | fliebel | There is one problem with filter and some… I need to have state, I need to check if a file exists in a directory, if it does not, move on directory up and try again. |
| 14:48 | piccolino | chouser, OK, thanks for checking. It was a bit difficult to tell from the docs. |
| 14:48 | DeusExPikachu | is parenthesis balancing handled by the reader? |
| 14:49 | johnmn3 | reading that blog (blog.fogus.me).. that usage of :post and :pre.. Might be useful for some kind of input validation template system? |
| 14:49 | johnmn3 | erm |
| 14:49 | johnmn3 | I'm not trying to be cheeky |
| 14:50 | fogus | fliebel: Why is state needed? |
| 14:50 | fliebel | fogus: because I can't think functional I guess… :$ |
| 14:51 | stuartsierra | johnmn3: I think :pre/:post are meant more for code assertions; since they're disabled by default outside the REPL |
| 14:51 | fliebel | fogus: I'll have to rethink my approach I think... |
| 14:51 | johnmn3 | stuartsierra: oh |
| 14:55 | johnmn3 | fliebel: what's the basic algorithm you have in your head for checking for the files existence? |
| 14:55 | mebaran151 | anybody here use enclojure |
| 14:55 | mebaran151 | I can't get the repl to work with 1.1 master |
| 14:55 | mitchellh | Simple question: What is the general method people use to run the clojure program JARs? I mean, if the JAR has 11 other JAR dependencies, how does one setup the class paths? Just setup a bash script for the user and list the deps? |
| 14:56 | mebaran151 | mitchellh, you could just make an uberjar use lein |
| 14:56 | mebaran151 | and then it gets run like a normal jar with main, all dep included |
| 14:57 | fliebel | johnmn3: I'm not sure… but what I want to do is use the most "detailed" file. so first I check for a file in the current directory with a specific name, else I want to have the closest general file. |
| 14:58 | fliebel | johnmn3: I'm now trying to make a seq from a path that goes like a/b/c a/b a |
| 14:58 | mitchellh | mebaran151: Some googling lein = Leiningen ? |
| 14:58 | mitchellh | I'm reading about it now |
| 15:00 | mebaran151 | yeah |
| 15:00 | mebaran151 | it's a nifty buiild tool |
| 15:00 | mebaran151 | someone decided to finally make Maven sane |
| 15:00 | mitchellh | mebaran151: This is great, but what if I'm writing a lib? It would make sense to not make the uberjar there to keep the lib clean. |
| 15:01 | mebaran151 | you can declare dependencies in the lein buildfile |
| 15:01 | mebaran151 | and then make a pom.xml |
| 15:01 | mebaran151 | using lein pom |
| 15:01 | mebaran151 | people who use your library with maven will automagically fetch the required dependencies |
| 15:01 | mitchellh | Fantastic |
| 15:02 | johnmn3 | fliebel: well I'm pretty noob at this, but I'd do that, then get the contents of each of those directories, filter each with regex, stopping at the first one should get you the most "detailed," right? |
| 15:02 | mitchellh | mebaran151: Well, before I ask any other noobish quetsions, I'm going to go read about this and play around with it :) Thanks |
| 15:02 | mebaran151 | yeah |
| 15:02 | mebaran151 | they made it way to easy to install |
| 15:02 | mebaran151 | are you on windows or UNIXy? |
| 15:02 | mitchellh | mebaran151: unix |
| 15:02 | fliebel | johnmn3: yea, that's what I'm aiming at |
| 15:02 | mebaran151 | it's supposed to be broken on windows unfortunately, due to some assumptions about scripting |
| 15:03 | mebaran151 | yeah, then you're set |
| 15:03 | mitchellh | Supporting windows [easily] is something I'm not worried about |
| 15:03 | mitchellh | Thanks |
| 15:03 | fliebel | johnmn3: not sure how to make that seq... |
| 15:03 | johnmn3 | fliebel: ok.. I'm thinking you should be able to do that pretty functionally |
| 15:03 | pdk | the simplest working way i've found so far to create say a java int[][] is basically: (into-array (into-array [1 2]) (into-array [3 4])) |
| 15:04 | pdk | there's probably better eh |
| 15:04 | mebaran151 | mitchellh, the jars will work, the build process will not |
| 15:04 | fliebel | johnmn3: I agree… but how? :D |
| 15:04 | mebaran151 | though I suppose if they don't edit your pom.xml, maven should work on windows |
| 15:04 | mebaran151 | it's mostly interacting with lein itself that would get problematic |
| 15:04 | johnmn3 | fliebel: not sure off the top of my head.. what's java's getPath method? |
| 15:06 | johnmn3 | fliebel: or do you just want to work with the string "a\b\c" ? |
| 15:06 | fogus | stuartsierra: "Disabled outside the REPL"... what do you mean? |
| 15:06 | stuartsierra | fogus: I think *assert* is false by default, except in the REPL |
| 15:07 | fliebel | johnmn3: I don't care, as long as it works... |
| 15:07 | fogus | stuartsierra: I always assumed that was for `(assert)` |
| 15:08 | johnmn3 | fliebel: well this is a start |
| 15:08 | johnmn3 | ,(apply str (drop-last "/a/b/c")) |
| 15:08 | clojurebot | "/a/b/" |
| 15:08 | fogus | If I compile my blog example, it still throws the :post exception |
| 15:08 | fogus | stuartsierra: If I compile my blog example, it still throws the :post exception |
| 15:09 | stuartsierra | someone said that, maybe it's wrong |
| 15:10 | fliebel | johnmn3: the point is that filenames are not 1 char in the real world |
| 15:10 | lisppaste8 | fogus pasted ":pre :post aot" at http://paste.lisp.org/display/92494 |
| 15:11 | defn | How do you get an environmental variable like $HOME into clojure? |
| 15:12 | johnmn3 | fliebel: ah, right |
| 15:13 | fliebel | johnmn3: I'm nearly there... |
| 15:13 | fliebel | ,(seq (.split "abc/def/ghi "/")) |
| 15:13 | clojurebot | EOF while reading string |
| 15:13 | fogus | ,(System/getenv "HOME") |
| 15:13 | clojurebot | java.security.AccessControlException: access denied (java.lang.RuntimePermission getenv.HOME) |
| 15:13 | fliebel | ,(seq (.split "a/b/c" "/")) |
| 15:13 | clojurebot | ("a" "b" "c") |
| 15:14 | fogus | defn: ^^ doesn't work here but should work on your box |
| 15:14 | defn | fogus: thanks |
| 15:15 | fogus | defn: np |
| 15:15 | fliebel | is there something like map that gives me access to the previous item? |
| 15:15 | mebaran151 | i wish there were a way to associate an agent with a given security context |
| 15:15 | stuartsierra | $HOME is also (System/getProperty "user.home") |
| 15:16 | defn | stuartsierra: is one preferred? |
| 15:16 | mebaran151 | I'm sure it exists, but it seems like the threadpool forkjoin clojure uses might not agree with the thread context model |
| 15:16 | defn | over the other i mean... |
| 15:16 | defn | fliebel: sorry for not replying to your email yet, im busy with some work stuff until the holidays |
| 15:16 | stuartsierra | defn: The System property is more portable. |
| 15:16 | johnmn3 | ,(re-split #"/" "/a/b/c") |
| 15:16 | clojurebot | java.lang.Exception: Unable to resolve symbol: re-split in this context |
| 15:16 | johnmn3 | mmm |
| 15:17 | defn | ,(use 'clojure.contrib.str-utils) |
| 15:17 | clojurebot | nil |
| 15:17 | defn | ,(re-split #"/" "a/b/c") |
| 15:17 | clojurebot | ("a" "b" "c") |
| 15:17 | johnmn3 | oh |
| 15:17 | johnmn3 | is there a way to split without losing the delimiter? |
| 15:18 | fliebel | defn: it's fine |
| 15:18 | johnmn3 | you could just add the / back onto it afterwords |
| 15:18 | defn | fliebel: nice parser though :) |
| 15:19 | defn | johnmn3: split-with i believe |
| 15:19 | defn | ,(split-with #"/" "a/b/c") |
| 15:19 | clojurebot | java.lang.ClassCastException: java.util.regex.Pattern cannot be cast to clojure.lang.IFn |
| 15:19 | fliebel | defn: I'm now working on the template stuff |
| 15:19 | johnmn3 | fliebel: oh. didn't see that you'd already split it up there. |
| 15:19 | twbray | ,(. #"/" split "a/b/c") |
| 15:19 | clojurebot | #<String[] [Ljava.lang.String;@1e3d80c> |
| 15:20 | defn | fliebel: cool im excited to see where you're at :) |
| 15:20 | twbray | ,(prn (. #"/" split "a/b/c")) |
| 15:20 | clojurebot | #<String[] [Ljava.lang.String;@f55759> |
| 15:20 | defn | (doc prn) |
| 15:20 | clojurebot | "([& more]); Same as pr followed by (newline). Observes *flush-on-newline*" |
| 15:20 | the-kenny | ,(seq (. #"/" split "a/b/c")) |
| 15:20 | clojurebot | ("a" "b" "c") |
| 15:20 | defn | (doc pr) |
| 15:20 | clojurebot | "([] [x] [x & more]); Prints the object(s) to the output stream that is the current value of *out*. Prints the object(s), separated by spaces if there is more than one. By default, pr and prn print in a way that objects can be read by the reader" |
| 15:21 | defn | ah, cool |
| 15:21 | defn | twbray: ? |
| 15:22 | mtm_ | hmm, leiningen is having trouble resolving a dependency of [org.clojure/clojure "1.1.0-rc1"]. Has 1.1.0-rc1 been added to clojars? |
| 15:22 | fogus | ,(seq (. #"/" split "a/b/c")) |
| 15:22 | clojurebot | ("a" "b" "c") |
| 15:22 | fogus | twbray: ^^ |
| 15:23 | fliebel | is there any looping function that gives me the previous item? |
| 15:23 | hiredman | reduce |
| 15:24 | fliebel | hiredman: like that, but not ending up with one item, but rather using the previous item for computing the present. |
| 15:24 | fliebel | hiredman: like fibonacci… |
| 15:25 | mtm_ | bah, looks like rc1 is not on any of leiningen's default repos. Anyone have any maven coordinates for rc1? |
| 15:25 | fliebel | hiredman: I think I'll use this: http://github.com/richhickey/clojure-contrib/blob/master/src/clojure/contrib/lazy_seqs.clj#L78 |
| 15:25 | stuartsierra | mtm_: I don't think it's been pushed anywhere, but you can download the ZIP and run "ant ci-build" |
| 15:26 | mtm_ | stuartsierra: I'll give it a shot |
| 15:26 | stuartsierra | That will install in your local maven repo. |
| 15:27 | mtm_ | I guess with 1.1.0 final imminent it doesn't make sense to push an rc at this point |
| 15:27 | johnmn3 | ,(use 'clojure.contrib.seq-utils) |
| 15:27 | clojurebot | nil |
| 15:27 | johnmn3 | ,(partition-by #(= \/ %) (seq "/hi/by/my")) |
| 15:27 | clojurebot | ((\/) (\h \i) (\/) (\b \y) (\/) (\m \y)) |
| 15:27 | stuartsierra | ,(map str (partition-by #(= \/ %) (seq "/hi/by/my"))) |
| 15:27 | clojurebot | ("(\\/)" "(\\h \\i)" "(\\/)" "(\\b \\y)" "(\\/)" "(\\m \\y)") |
| 15:27 | stuartsierra | ,(map #(apply str %) (partition-by #(= \/ %) (seq "/hi/by/my"))) |
| 15:28 | johnmn3 | fliebel: I think for allows you to hold on to more than one value of a seq at a time. |
| 15:29 | stuartsierra | mtm_: You'll need to download maven-ant-tasks too. |
| 15:30 | johnmn3 | stuartsierra: my repl says that works just fine. |
| 15:30 | mtm_ | stuartsierra: thanks (hopefully I already have them) |
| 15:30 | fliebel | ,(take 5 (iterate butlast [:a :b :c :d :e])) ; johnmn3: this should do, now only the joining part. |
| 15:30 | clojurebot | ([:a :b :c :d :e] (:a :b :c :d) (:a :b :c) (:a :b) (:a)) |
| 15:31 | johnmn3 | ah-hkha! very nice |
| 15:32 | hiredman | http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Lazy_Fibonacci |
| 15:32 | mtm_ | is the latest rc on origin/master or origin/1.1.x ? |
| 15:32 | stuartsierra | 1.1.x |
| 15:32 | mtm_ | thx |
| 15:32 | mebaran151 | does 1.1 have the local cleaning fix? |
| 15:32 | johnmn3 | ,(for [x (take 5 (iterate butlast "/ab/cd/ef"))] (apply str x)) |
| 15:32 | clojurebot | ("/ab/cd/ef" "/ab/cd/e" "/ab/cd/" "/ab/cd" "/ab/c") |
| 15:33 | mebaran151 | where holding on to the head won't be the headache it currently is |
| 15:33 | johnmn3 | still have to wordify it. |
| 15:33 | fliebel | johnmn3: I can handle it now, thanks for your help. |
| 15:34 | johnmn3 | np |
| 15:34 | stuartsierra | mebaran151: no |
| 15:37 | defn | ,(use 'clojure.contrib.shell-out) |
| 15:37 | clojurebot | nil |
| 15:40 | hiredman | http://www.technologyreview.com/blog/arxiv/24497/ <-- function of the past, eh? |
| 15:40 | johnmn3 | ,(System/getProperty "user.home") |
| 15:40 | clojurebot | java.security.AccessControlException: access denied (java.util.PropertyPermission user.home read) |
| 15:40 | mtm_ | stuartsierra: spiffy, that worked |
| 15:41 | joshua-choi | Hey, is there an easy way to compose two predicates f and g into #(or (apply f %&) (apply g %&))? |
| 15:42 | defn | im trying to get the project root from a nested directory... "/my/project/root/is/not/here" -- I want "/my/project/root/" |
| 15:42 | fliebel | ,(take 5 (map #(apply str (interleave % (repeat "/"))) (iterate butlast (seq (.split "abc/def/ghi/jkl/mno" "/"))))) ; johnmn3 |
| 15:42 | clojurebot | ("abc/def/ghi/jkl/mno/" "abc/def/ghi/jkl/" "abc/def/ghi/" "abc/def/" "abc/") |
| 15:42 | johnmn3 | fliebel: there it is |
| 15:43 | defn | i was thinking something like: |
| 15:43 | johnmn3 | gratifying, isn't it? |
| 15:43 | defn | ,(reverse (drop 2 (reverse (re-split #"/" (sh "pwd"))))) |
| 15:43 | clojurebot | java.security.AccessControlException: access denied (java.io.FilePermission <<ALL FILES>> execute) |
| 15:43 | fliebel | yea |
| 15:43 | lpetit | hello, could someone help me find where emacs lisp (check-parens) definition is in a standard emacs distribution ? (which file ? generally under which folder layout ?) |
| 15:44 | lpetit | it seems it's not part of paredit, probably of some other "mode" ... |
| 15:44 | johnmn3 | i love it when it works.. yea, clojurebot is locked down. |
| 15:44 | fliebel | defn: I'm just fighting paths as well. How is root defined? the dir called root? the nth item form either sides? |
| 15:45 | _ato | defn: use (System/getProperty "user.dir") for pwd |
| 15:45 | defn | _ato: thanks |
| 15:45 | mebaran151 | that's not pwd |
| 15:45 | defn | err so it isnt |
| 15:46 | _ato | mebaran151: ? |
| 15:46 | defn | err it is |
| 15:46 | mebaran151 | user.home isn't |
| 15:46 | johnmn3 | its the home dir |
| 15:46 | mebaran151 | pwd is in Runtime I think |
| 15:46 | defn | user.dir for me works |
| 15:46 | _ato | user.dir, not user.home |
| 15:46 | defn | it's the same as pwd |
| 15:46 | defn | without the ugly \n |
| 15:47 | _ato | http://java.sun.com/j2se/1.5.0/docs/api/java/lang/System.html#getProperties() |
| 15:47 | defn | _ato: how would you get two directories above "user.dir"? |
| 15:47 | mebaran151 | I think though it gets something weird like Application Support in windows |
| 15:47 | defn | like /my/current/working/dir/is/this |
| 15:47 | defn | but i want /my/current/working/dir/ |
| 15:48 | hiredman | (-> (File. (System/getProperty "user.dir")) .getParent .getParent) |
| 15:48 | mebaran151 | oh |
| 15:48 | mebaran151 | much easier way would be |
| 15:48 | hiredman | it may not be called getParent |
| 15:48 | defn | hiredman: awesome, thank you |
| 15:48 | hiredman | but look at the javadoc for File |
| 15:48 | defn | ill figure it out, thanks |
| 15:48 | mebaran151 | (.getCanonicalPath (File. "../../")) |
| 15:48 | mebaran151 | ,(.getCanonicalPath (File. "../../")) |
| 15:48 | clojurebot | java.lang.IllegalArgumentException: Unable to resolve classname: File |
| 15:49 | _ato | ,(.getCanonicalPath (java.io.File. "../../")) |
| 15:49 | clojurebot | java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read) |
| 15:49 | _ato | heh |
| 15:49 | mebaran151 | yeah user.dir maps someplace strange |
| 15:50 | _ato | if it does then "." in java.io.File is also going to map someplace strange ;-) |
| 15:50 | mebaran151 | ah, I think I lied |
| 15:50 | _ato | cause File uses user.dir as the above access exception shows |
| 15:51 | mebaran151 | I would have thought it the other way around, but so is the ways of Java |
| 15:52 | mebaran151 | I thought it mapped to the like where the jar actually was |
| 15:52 | robwolfe | lpetit: C-h f check-parens: check-parens is an interactive compiled Lisp function in `lisp.el'. |
| 15:54 | lpetit | robwolfe: thanks very much. I'm beginning a port of paredit.el to clojure, but I'm a noob with emacs so your help is very much appreciated (I prefer spend my little spare time hacking on paredit.clj than on enhancing my emacs skills :-) ) |
| 15:56 | defn | there we go |
| 15:56 | defn | ,(.. (File. (System/getProperty "user.dir")) getParentFile getParentFile) |
| 15:56 | clojurebot | java.lang.IllegalArgumentException: Unable to resolve classname: File |
| 15:57 | hiredman | (-> "user.dir" System/getProperty File. .getParentFile .getParentFile) |
| 15:58 | fliebel | defn: shouldn't that be java.io.File.? |
| 15:58 | _ato | ,(-> "/home/defn/src/myproject/src/myproject" java.io.File. .getParentFile .getParentFile) |
| 15:58 | clojurebot | #<File /home/defn/src/myproject> |
| 15:59 | defn | _ato: that's nicer, thanks |
| 15:59 | mebaran151 | then arrow macro has made my life much easier |
| 15:59 | mebaran151 | some things are so much clearer with it |
| 15:59 | defn | it's cheating! |
| 15:59 | defn | ;) |
| 16:00 | hiredman | ~clojure |
| 16:00 | clojurebot | clojure is the best way to learn java |
| 16:01 | somnium | hiredman: how did you end up getting auto-complete to start on all .clj files? |
| 16:02 | hiredman | ah |
| 16:02 | somnium | hiredman: I even use it at the repl now |
| 16:02 | hiredman | I don't have my .emacs.el on hand |
| 16:02 | somnium | ok, maybe later |
| 16:03 | somnium | btw, did you get rainbow parens working? |
| 16:03 | hiredman | and I don't know much emacs, but I think ac is a major mode? so you can't just add it to the hooks |
| 16:03 | hiredman | somnium: nope :/ |
| 16:03 | somnium | hiredman: highlight-parens.el, its on elpa! |
| 16:03 | hiredman | there is a var called, maybe ac-modes? and you make it a list of modes you want ac to work with |
| 16:03 | somnium | hiredman: you can customize the faces for each level |
| 16:04 | somnium | hiredman: nice, thanks |
| 16:04 | hiredman | yeah, I have hlp, but I haven't looked at customizing |
| 16:11 | somnium | http://tinypic.com/view.php?pic=2urqmgl&s=6 |
| 16:13 | hiredman | ooo |
| 16:13 | somnium | customize-group -> highlight-parentheses |
| 16:14 | somnium | :) |
| 16:15 | hiredman | the weird part is I don't have a dog |
| 16:15 | the-kenny | I want a "my other car is a cdr" sticker |
| 16:15 | lpetit | ok maybe I'm a little bit tired tonight. Is (cadr x) equivalent to (rest (first x)) in clojure, or the exact inverse ? |
| 16:15 | somnium | a t-shirt with a minified clojure.core would be cool |
| 16:16 | somnium | like _why's camping |
| 16:17 | chouser | ((fn [{k :k (-> (or 10) v) :v}] (print k v)) {:k 1}) |
| 16:17 | pdk | iirc clojure ditches car/cdr etc |
| 16:18 | robwolfe | lpetit: (first (rest x)) |
| 16:18 | robwolfe | ;) |
| 16:18 | hiredman | pdk: he is porting some code |
| 16:18 | lpetit | robwolfe: so I was reading it in the wrong sense ... it composes as it reads a -> first, d -> rest => (first (rest x)), ok thanks ! |
| 16:19 | chouser | alexyk, but he's gone |
| 16:19 | robwolfe | exactly: cdr = rest |
| 16:20 | chouser | (doc fnext) |
| 16:20 | clojurebot | "([x]); Same as (first (next x))" |
| 16:20 | lpetit | chouser: even better, thx |
| 16:20 | LauJensen | Is the funding graph on /funders out-dated, or did the funding stop at about 60% ? |
| 16:20 | lpetit | (doc nnext) |
| 16:20 | clojurebot | "([x]); Same as (next (next x))" |
| 16:20 | lpetit | cool |
| 16:20 | triyo | I have functions that all need to return a result in json form. What the most idiomatic way to reuse this common pattern so that results of all my functions are wrapped in json-str? |
| 16:21 | hiredman | triyo: write a macro |
| 16:21 | stuartsierra | Or just wrap all your functions in json-str. |
| 16:21 | lpetit | chouser: or should it be frest , rrest now ? |
| 16:21 | lpetit | (doc frest) |
| 16:21 | clojurebot | Pardon? |
| 16:21 | lpetit | chouser: or nrest :-) |
| 16:22 | fliebel | Another I-should-know-that question: How can I test if a vector contains a value? |
| 16:22 | triyo | hiredman: macro is what I had in mind thx |
| 16:22 | chouser | next is closer to cdr than rest is |
| 16:23 | chouser | ,(rest '(1)) |
| 16:23 | clojurebot | () |
| 16:23 | triyo | stuartsierra: thats how I have it right now. Its just that I saw that I could abstract the content type away from the actual functions that deal with logic |
| 16:23 | lpetit | ,(next '(1)) |
| 16:23 | clojurebot | nil |
| 16:23 | lpetit | ok |
| 16:24 | chouser | fliebel: if you have a container that you're mostly using to test to see if things are in it, consider using a set instead of a vector. |
| 16:24 | chouser | fliebel: otherwise you have to use an O(n) scan like 'some' or '.contains' |
| 16:25 | fliebel | chouser: It's returned by Java: http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html#listFiles() |
| 16:25 | lpetit | robwolfe: is emacs lisp a lisp-1 or a lisp-2 ? |
| 16:25 | stuartsierra | lisp-1 |
| 16:25 | fliebel | chouser: It's a File[], should I just call set on that? |
| 16:26 | the-kenny | ,(set (make-array Object [(Object.)])) |
| 16:26 | clojurebot | java.lang.ClassCastException: clojure.lang.PersistentVector cannot be cast to java.lang.Character |
| 16:26 | the-kenny | Character? huh? |
| 16:26 | chouser | fliebel: 'some' is probably what you want. |
| 16:27 | lpetit | stuartsierra: oh. so I don't understand this code from paredit.el : |
| 16:27 | the-kenny | ,(doc make-array) |
| 16:27 | clojurebot | "([type len] [type dim & more-dims]); Creates and returns an array of instances of the specified class of the specified dimension(s). Note that a class object is required. Class objects can be obtained by using their imported or fully-qualified name. Class objects for the primitive types can be obtained using, e.g., Integer/TYPE." |
| 16:27 | chouser | fliebel: you've the name of the think you're looking for? |
| 16:27 | the-kenny | ,(set (make-array Object 1)) |
| 16:27 | clojurebot | #{nil} |
| 16:27 | hiredman | that is bizzare |
| 16:28 | fliebel | chouser: I'm looking for default.clj for now |
| 16:28 | lpetit | stuartsierra: http://paste.lisp.org/+1ZDE . could you explain what the put does ? |
| 16:28 | stuartsierra | lpetit: no, I'm only casually familiar with elisp |
| 16:29 | lpetit | ,(make-array Object 1) |
| 16:29 | clojurebot | #<Object[] [Ljava.lang.Object;@1f88953> |
| 16:29 | the-kenny | ,(set (make-array Object 10)) |
| 16:29 | clojurebot | #{nil} |
| 16:29 | chouser | fliebel: (some #(= (.getName %) "default.clj") (.listFiles (java.io.File. "."))) |
| 16:29 | the-kenny | ,(set (seq (make-array Object 10))) |
| 16:29 | clojurebot | #{nil} |
| 16:29 | chouser | that'll return true or nil |
| 16:29 | stuartsierra | lpetit: I'm guessing (put coll x n) places x in coll at position n |
| 16:29 | hiredman | man |
| 16:29 | hiredman | elisp is old |
| 16:29 | hiredman | put is for manipulating property lists |
| 16:29 | hiredman | http://www.chemie.fu-berlin.de/chemnet/use/info/elisp/elisp_8.html#SEC97 |
| 16:30 | fliebel | chouser: thanks |
| 16:30 | lpetit | hiredman: oh, so it's somehow like placing a metadata on the symbol that's used for the macro ? |
| 16:31 | lpetit | hiredman: I think I now remember this from CL |
| 16:31 | hiredman | yeah |
| 16:32 | lpetit | seems weird now that I'm accustomed to clojure, but I understand, thx |
| 16:34 | hiredman | property lists where a big point of contention durring the common lisp standizing effort |
| 16:34 | hiredman | I forget exactly how and why |
| 16:36 | lpetit | oddly enough, I see the property lisp-indent-function set to 2 in the property list of the paredit-do-commands macro, and it's not used anywhere else in the paredit code ... some black magic beyond my powers is at use I guess ... :-( |
| 16:36 | hiredman | lpetit: possibly telling emacs how to indent the code |
| 16:36 | stuartsierra | yes |
| 16:37 | lpetit | hiredman: yes. I thought paredit code was maybe in isolation from the rest, but it's certainly more tightly integrated with emacs than I would like ... we'll see |
| 16:38 | hiredman | I don't think paredit bothers with indentation |
| 16:40 | johnmn3 | I always wondered how a indentation tool would handle all situations, if it had full control over all indentations. |
| 16:41 | johnmn3 | indedit |
| 16:41 | lpetit | it is said in the comments that it tries not to, though it does it sometimes "very locally" |
| 16:42 | lpetit | johnmn3: pprint already does a good job of that I think, albeit working on clojure data structures as code, not on text string as code (thus not preserving user comments, etc.) |
| 16:42 | johnmn3 | I'd imagine a full on indentation tool would make things unwieldly, with fragments extending far to the right |
| 16:42 | johnmn3 | hm |
| 16:42 | stuartsierra | johnmn3: "Vietnamization" |
| 16:43 | chouser | I wonder if comments and spacing could be tucked into metadata in a way that would allow exact reconstruction of the original sources. |
| 16:44 | johnmn3 | couldn't the whole original code string be stored in metadata? |
| 16:44 | hiredman | chouser: where would the metadata go? |
| 16:45 | johnmn3 | seems like a :source metadata string makes sense |
| 16:45 | chouser | I guess I'm thinking at read time so that editors could deal with the data structures at that level. |
| 16:45 | stuartsierra | "Vietnamization: The tendency of Lisp code to wander off to the right, then eventually back to the left, until it resembles the map of Vietnam." |
| 16:45 | johnmn3 | stuartsierra: ah |
| 16:45 | stuartsierra | -YTools docs www.cs.yale.edu/homes/dvm/papers/ytdoc.pdf |
| 16:46 | lpetit | johnmn3: that's what pprint tries to do |
| 16:46 | johnmn3 | I had a hunch it'd be along those lines. |
| 16:46 | chouser | hiredman: since many scalars don't support metadata, it'd have to go in an enclosing collection. |
| 16:46 | lpetit | chouser: allowing exact reconstruction would be great, and allow one to just rely on a unique reader ! :-) |
| 16:47 | johnmn3 | mm.. but because (comment ..) is not evaled, even macro time tools can't store the string? |
| 16:47 | _ato | you would need a different reader |
| 16:47 | _ato | (comment ...) is jsut a macro so you can find that |
| 16:47 | chouser | yes, but it could be a backward-compatible reader |
| 16:47 | _ato | but what you can't find is the whitespace and reader-macro symbols like #_ |
| 16:47 | stuartsierra | Even in Lisp, it's hard to draw a 1-to-1 correspondence between characters and code structures. |
| 16:48 | chouser | that is, this new reader would produce data that all existing tools (esp. the Compiler) could work with. |
| 16:48 | lpetit | #_ is a reader macro too ... |
| 16:48 | stuartsierra | It would be much more fun to have a real structural editor. |
| 16:48 | lpetit | _ato: sorry for the repetition |
| 16:48 | chouser | stuartsierra: this would enable that. |
| 16:48 | stuartsierra | IF it could be written. |
| 16:48 | chouser | allow a real structural editor to edit things like comments, #_foo, etc. |
| 16:48 | chouser | right. |
| 16:49 | chouser | it wouldn't be pretty. |
| 16:49 | stuartsierra | I think it would be much easier to write a structural editor from scratch than to try to recover structure from characters. |
| 16:49 | johnmn3 | yea, I've always wanted work with a structural editor, without having to learn emacs or vi (though I suppose those aren't real structural editors...) |
| 16:50 | lpetit | chouser: the classical problem of structural editors ... certainly too rigid for writing source code incrementally ... I guess adding paredit to ccw will suffice to users just as it seems to suffice to emacs users (at least it will for a while :-) ) |
| 16:50 | stuartsierra | Even paredit is just scanning for matching delimiters. |
| 16:51 | stuartsierra | I took a stab at a structural Lisp editor in Javascript, found it very hard to break away from the code-as-text habit. |
| 16:51 | chouser | stuartsierra: you still need a way to handle comments, don't you? |
| 16:51 | _ato | probably simplifying the model to would help implementation: don't allow custom indentation, don't allow arbitrary spaces between list element (just comma or no-comma), don't allow trailing whitespace. Then it becomes basically a question of where you put line breaks. But perhaps that's simplifying too far ? |
| 16:51 | hiredman | chouser: if only we had a reader written in clojure |
| 16:52 | stuartsierra | chouser: I never got that far. |
| 16:53 | johnmn3 | heh |
| 16:53 | chouser | maybe docstrings are sufficient |
| 16:53 | hiredman | my gui repl thing just counts the parens and does (zero? (mod x 2)) |
| 16:55 | johnmn3 | I wounder what the default would be? for any given function that takes three arguments, do you put the first argument on the same line and the next two on the following lines? and what if the first argument is a function which takes three arguments? Now you have it's first argument on the same first line... and so forth until you have 50 arguments and parens on one line? where do you draw the line? |
| 16:55 | lpetit | http://www.osenkov.com/diplom/contents/1/5/ |
| 16:55 | johnmn3 | hiredman: yea, just a bit cleaner than my 70 some line parens counter.. with 5 closed over atoms :) |
| 16:55 | lpetit | ~gui repl |
| 16:55 | clojurebot | the repl is holding onto the head of sequences when printing them. |
| 16:56 | lpetit | hiredman: where's your gui repl ? |
| 16:56 | _ato | it depends a lot on the function and the context. "if" you often want to split into 3 lines, but occasioanlly it reads better as 1-liner (if foo? 2 5) |
| 16:56 | _ato | a structural editor doesn't have to make that sort of decision for you though, let the programmer deicde |
| 16:56 | _ato | it'd annoy me to no end if it did ;-) |
| 16:56 | hiredman | johnmn3: :P |
| 16:57 | hiredman | http://www.thelastcitadel.com/images/Screenshot-Clojure.png http://gist.github.com/261648 |
| 16:57 | hiredman | _ato: you get all kinds of heuristics |
| 16:58 | lpetit | _ato: the indenter I intend to add to ccw will just correctly reindent the start of the lines. And it will do so in a totally predictable manner : 2 spaces for each argument that's not on the first line when parens, 1 space for every element of literal vectors, sets or maps (at least at first) |
| 16:58 | fliebel | defn: I'm done! http://github.com/pepijndevos/utterson/blob/master/test/template_test/template_test.clj calling template invokes the last function in the appropriate template file, supplying the used page, for body, title, etc. and the other pages for menus, blog pages, etc. |
| 16:58 | hiredman | based on the number and "size" of earch argument |
| 17:00 | lpetit | hiredman: thanks for the screenshot. Interesting stuff ! |
| 17:01 | johnmn3 | hiredman: I messed with it for a minuted.. couldn't get the background to go white! .setBackground on the JPanel and the JScrollPane was no help. |
| 17:01 | johnmn3 | *minute |
| 17:02 | chouser | swing is pure joy |
| 17:02 | hiredman | johnmn3: because of how stuff is rendered it can be difficult to figure out where to type, so I'm leaning towards accenting the different more instead of toning it down |
| 17:02 | hiredman | chouser: :P |
| 17:03 | fliebel | Are functions relying on the file system considered functional? I guess not, but calling them multiple times with the same input on the same file should give the same output, right? |
| 17:04 | johnmn3 | yea.. could try to set up mouse listeners for the whole window and have them redirect focus on the input box |
| 17:04 | hiredman | johnmn3: good idea |
| 17:04 | johnmn3 | you don't want the mouse anywhere else, anyway.. at least, I can't think of a good usage of having them anywhere else. |
| 17:05 | hiredman | johnmn3: might want to go clicky |
| 17:05 | johnmn3 | perhaps on a menubar, but every where else could redirect. |
| 17:05 | hiredman | click on a datastructure to get an exploded view |
| 17:05 | johnmn3 | hmm? |
| 17:05 | johnmn3 | ah |
| 17:05 | hiredman | file explorer in repl |
| 17:07 | johnmn3 | well, I'd imagine the most intuitive thing then.. would be that where a not obviously clickable object/region within the repl is, have it listening and redirecting to the input box. |
| 17:08 | lpetit | fliebel: you said it yourself, "pre-requisites" that are not part of the function arguments: the current status of the file, for one. And also, you can get an I/O exception, so no, definitely not purely functional they are |
| 17:08 | johnmn3 | like if a collapsed tree is presented, allowing the user to delve into the data structure.. but it is collapsed as one node, then only the small expand dot should be outside of the "redirect to input" listening region. |
| 17:09 | johnmn3 | intuitively then, one would just click in the whitespace to begin writing again. |
| 17:10 | hiredman | you can just create some kind of JCompenent at the repl and call $ on it, and it will render |
| 17:10 | hiredman | so that is pretty cool |
| 17:11 | johnmn3 | hiredman: does that many anything will render? like, even an embedded browser? |
| 17:12 | johnmn3 | typing (show menubar) and a menu bar pops up within the repl would be cool. |
| 17:12 | hiredman | johnmn3: if it's a JComponent, there might be some focus issues and such |
| 17:13 | patrkris | can anyone tell me why (binding [inc (fn [n] (+ n 2))] (inc 1)) doesn't return 3? |
| 17:13 | hiredman | ($ (JLabel. "Foo")) |
| 17:13 | johnmn3 | i've also been toying with the idea of a contextual repl.. has anyone ever worked with cisco switches or routers? |
| 17:13 | hiredman | inc might inline |
| 17:13 | hiredman | (meta #'inc) |
| 17:14 | hiredman | ,(meta #'inc) |
| 17:14 | clojurebot | {:ns #<Namespace clojure.core>, :name inc, :file "clojure/core.clj", :line 618, :arglists ([x]), :inline #<core$fn__4729 clojure.core$fn__4729@1724852>, :doc "Returns a number one greater than num."} |
| 17:14 | lpetit | ,(binding [clojure.core/inc (fn [n] (+ n 2))] (inc 1)) |
| 17:14 | clojurebot | 2 |
| 17:14 | hiredman | yeah, so the body of inc is inlined at compile time |
| 17:14 | patrkris | hiredman: aha... I guess there is nothing I can do then? |
| 17:14 | patrkris | I'm just using it as an illustration of binding |
| 17:15 | hiredman | ,(alter-meta! #'inc dissoc :inline) |
| 17:15 | clojurebot | {:ns #<Namespace clojure.core>, :name inc, :file "clojure/core.clj", :line 618, :arglists ([x]), :doc "Returns a number one greater than num."} |
| 17:15 | hiredman | ,(binding [clojure.core/inc (fn [n] (+ n 2))] (inc 1)) |
| 17:15 | clojurebot | 3 |
| 17:15 | lpetit | ,(binding [clojure.core/inc (fn [n] (+ n 2))] (inc 1)) |
| 17:15 | clojurebot | 3 |
| 17:16 | patrkris | hiredman: much too complex for my illustrative example... I'll redesign it. Thanks for the help. |
| 17:16 | hiredman | + is inline for the two arg case |
| 17:16 | hiredman | ,(binding [+ *] (+ 2 3)) |
| 17:16 | clojurebot | 5 |
| 17:16 | hiredman | ,(binding [+ *] (+ 2 3 1)) |
| 17:16 | clojurebot | 6 |
| 17:17 | hiredman | ,(binding [+ *] (+ 2 3 2)) |
| 17:17 | clojurebot | 12 |
| 17:17 | johnmn3 | in a cisco switch, you type "conf t" (short for "configure terminal") to get into the configuration mode. which changes the prompt to: hostname(config) |
| 17:17 | johnmn3 | then you type "int fa0/1" to get into Interface FastEthernet 0/1: hostname(if-config), etc |
| 17:18 | johnmn3 | I thought having a repl to configure a program (or your repl) using a contextual interface would be pretty neet. |
| 17:19 | johnmn3 | the great thing is that you can do a <tab> or an <?> in any given context to find out what available commands there are.. it's very easy to go into a switch you've never been in before and figure out your way around. |
| 17:20 | johnmn3 | So I was wondering, would that kind of thing be possible with a namespace at the repl? |
| 17:21 | johnmn3 | like, a repl.config namespace? where I could save configuration, load configuration, turn on and off properties |
| 17:22 | somnium | johnmn3: putting a user.clj on the classpath kind of works like that now |
| 17:23 | johnmn3 | true |
| 17:24 | johnmn3 | you could probably get by with a ,config {:background-color ..} |
| 17:25 | johnmn3 | just thought it'd be neet, you could drop down into a context with a whole DSL for a certain job. |
| 17:26 | johnmn3 | I guess DrScheme has something like that, with different levels of easiness (for noobs) |
| 17:26 | hiredman | I really need to namespace the code and do a proper repo, I got history working last night too |
| 17:26 | johnmn3 | *neat |
| 17:26 | johnmn3 | really? |
| 17:26 | johnmn3 | nice 1 |
| 17:27 | hiredman | yeah, there are some issues with enter |
| 17:27 | hiredman | I need to find a way to catch "enter" keypresses and selectively let them through |
| 17:27 | somnium | when you type (fn ...) at the repl does the runtime store a .class file in memory? |
| 17:28 | hiredman | yes |
| 17:28 | johnmn3 | rendering issues? those boxes.. I have a dark GTK theme in ubuntu and it looks a little funny with the white boxes on dark dark brown. |
| 17:28 | somnium | is there a way to get a handle on those files? |
| 17:29 | hiredman | somnium: they aren't files |
| 17:29 | hiredman | they are bytecode in ram |
| 17:29 | johnmn3 | serialization? |
| 17:29 | somnium | so if you serialized it, != .class file? |
| 17:31 | johnmn3 | hiredman: ah, you mean stop the enter key from actually making a \newline in the textarea? |
| 17:31 | hiredman | yeah |
| 17:31 | hiredman | somnium: actually you might be able to recover the byte arrays |
| 17:32 | johnmn3 | somnium: not in the java -cp my.class sense, I don't think. |
| 17:32 | somnium | would be nice to have (save-image!) or something like in smalltalk |
| 17:33 | johnmn3 | I don't see why that wouldn't be possible. |
| 17:34 | johnmn3 | in fact, I think a performance trick for faster start up is to pre-cache, or pre-.. pre-something which pretty much suspends the running code. |
| 17:35 | johnmn3 | hiredman: if you set the text area only one row in length, pressing enter doesn't do anything. |
| 17:35 | johnmn3 | you could then decide to add another row to the text area selectively, when you get an enter key press? |
| 17:36 | hiredman | I was thinking there was a method on ClassLoader that return the bytes for a class |
| 17:36 | johnmn3 | iirc |
| 17:36 | hiredman | but there isn't |
| 17:36 | somnium | hiredman: wall-hack into c.l.Compiler maybe? |
| 17:37 | hiredman | Classes are serializable, but I am not sure if the serialized form can just be written to a class file |
| 17:38 | johnmn3 | hiredman: how about setting the text area to only one row in length? |
| 17:38 | hiredman | "serializing java.lang.Class instance does not really write the content of the class file in to the stream. It only write a class descriptor. At the read end it will try to locate the class file locally and validate the class file with the information in the descriptor. |
| 17:39 | hiredman | johnmn3: I don't think that will effect the underlying issue |
| 17:39 | somnium | hmm, headius might have some input, doesn't appear to be around though |
| 17:39 | headius | input on what |
| 17:40 | somnium | headius: trying to serialize bytecode in the runtime to .class files |
| 17:40 | johnmn3 | hiredman: I'll have to check again, but I think pressing enter on a one row TA doesn't do anything, which would allow you to catch the enter without the new line. Then selectively add rows. |
| 17:42 | pdk | how's the current state of clojure-eclipse |
| 17:42 | headius | somnium: once you've classloaded it you can't get at the bytecode anymore as far as I know |
| 17:43 | headius | is this for serializing a function or something? |
| 17:44 | somnium | yeah, like at irb typing: a = lambda {|x| x * x}, save-image!, restart irb and a is there |
| 17:44 | somnium | headius: conceivable? |
| 17:45 | headius | closures are hard, and I think all functions in clojure qualify as closures, right? |
| 17:45 | headius | the problem is not getting the code across as much as getting the surrounding state across |
| 17:46 | headius | the context in which it runs |
| 17:46 | headius | your best bet in both cases would be to reverse it to code and re-evaluate/compile it on the other side in a new appropriate context |
| 17:46 | headius | that's theoretically possible in JRuby but there's no API for it |
| 17:46 | somnium | hmm, maybe once we get metadata on fns |
| 17:47 | technomancy | serializing a single closure might actually be more difficult than serializing the whole state of the VM |
| 17:47 | somnium | headius: the env of blocks is accessible in ruby, right? |
| 17:48 | headius | technomancy: yes |
| 17:48 | headius | somnium: indirectly, yes |
| 17:48 | hiredman | clojurebot: fn minus |
| 17:48 | clojurebot | ant clean and rebuild contrib |
| 17:48 | headius | you can evaluate code against that context (use it as a binding) but you can't really poke it directly |
| 17:49 | headius | interesting fact: this is also why define_method is slower than real methods, because it has to maintain a closure environment for every call |
| 17:49 | headius | in either ruby or clojure cases, though, the code is the least of your problems |
| 17:50 | hiredman | http://paste.lisp.org/display/91148 |
| 17:50 | technomancy | headius: is that the only reason define_method is slower? interesting. |
| 17:51 | hiredman | closed over locals are fields in the resulting fn class |
| 17:51 | headius | technomancy: that's the main reason |
| 17:51 | somnium | headius: does it make a new class for every new method? |
| 17:51 | hiredman | so if you don't use any closed over locals it's not a problem |
| 17:51 | headius | a secondary reason is because it uses block arguments, which are using masgn, which is slower in most rubies |
| 17:51 | johnmn3 | hiredman: I just tested it, setting (.setRows 1) on a JTextArea makes it not able to expand on <enter> |
| 17:51 | headius | somnium: impl detail |
| 17:51 | somnium | ok |
| 17:51 | headius | in JRuby everything interprets for a while, but once they jit there's a class per body of code in memory |
| 17:52 | headius | because that's the granularity on which we jit |
| 17:52 | hiredman | johnmn3: the expansion is not the problem |
| 17:52 | hiredman | I like the expansion |
| 17:52 | johnmn3 | what's the problem? |
| 17:53 | johnmn3 | the problem is that _sometimes_ you don't want it to expand, right? |
| 17:56 | hiredman | ,(let [x 1 y (fn [] x)] (wall-hack-field (class y) :x Object)) |
| 17:56 | clojurebot | java.security.AccessControlException: access denied (java.lang.reflect.ReflectPermission suppressAccessChecks) |
| 17:57 | lpetit | pdk: usable. But I'm biased, I'm for a great part the author :-) |
| 17:58 | somnium | ,(doc wall-hack-field) |
| 17:58 | clojurebot | "([class-name field-name obj]); Access to private or protected field." |
| 17:58 | hiredman | from java-utils |
| 18:02 | somnium | I get: Can not set java.lang.Object field user$eval__3708$y__3710.x to java.lang.Class |
| 18:07 | defn | what's an easy way to strip the first line of a block of text? |
| 18:07 | defn | 1234\nasdf\n => asdf\n |
| 18:08 | defn | this reminds me of _why's what_method? -- it'd be cool to build one of those in clojure |
| 18:08 | headius | back |
| 18:08 | defn | (what-makes "abc" "ABC") |
| 18:08 | defn | something like that |
| 18:08 | defn | hiya headius |
| 18:08 | defn | what's an easy way to strip the first line of a block of text? |
| 18:09 | arohner_ | defn: you can probably line-seq then rest |
| 18:09 | hiredman | ,(let [x (fn [] 1)] (-> x class .getFields first (.get x))) |
| 18:09 | clojurebot | 1 |
| 18:09 | hiredman | ,(let [y 1 x (fn [] y)] (-> x class .getFields first (.get x))) |
| 18:09 | clojurebot | nil |
| 18:10 | somnium | ,(apply str (drop-while #(not (= \newline %)) "foo bar\n baz")) |
| 18:10 | clojurebot | "\n baz" |
| 18:11 | defn | hm, specifically i have the output from (print-doc form) |
| 18:12 | defn | im using with-out-writer to print the output of print-doc form |
| 18:12 | somnium | ,(alias 's2 'clojure.contrib.str-utils2) |
| 18:12 | clojurebot | java.lang.NullPointerException: Expecting Symbol + Namespace |
| 18:15 | somnium | ,(require '(clojure.contrib [str-utils2 :as s2])) |
| 18:15 | clojurebot | nil |
| 18:17 | somnium | ,(s2/replace "foo bar baz\nbar konk\boom" #"^.*[\n]{1}" "") |
| 18:17 | clojurebot | "bar konk\boom" |
| 18:18 | somnium | ,(rest (s2/split "foo bar baz\nbar konk\nboom" #"\n")) |
| 18:18 | clojurebot | ("bar konk" "boom") |
| 18:19 | somnium | ^^ maybe less ugly? |
| 18:19 | johnmn3 | hiredman: so why were you wanting to intercept the enter key? |
| 18:22 | defn | how can i intercept (print-doc #'and) before it gets handled by with-out-writer? |
| 18:24 | somnium | ,(source print-doc) |
| 18:24 | clojurebot | java.lang.Exception: Unable to resolve symbol: source in this context |
| 18:24 | somnium | ,(use 'clojure.contrib.repl-utils) |
| 18:24 | clojurebot | java.lang.ExceptionInInitializerError |
| 18:25 | somnium | defn: well, if you check the source to print-doc it just gets the meta data off the var |
| 18:25 | _mst | emacs rainbow paren hideousness if anyone wants to try it: http://dishevelled.net/elisp/rainbow-parens.el. I don't actually want to use this--just wanted to see if it was possible :P |
| 18:25 | defn | somnium: yeah, that actually is fantastic |
| 18:26 | defn | thank you :) |
| 18:26 | defn | what is ^v? |
| 18:28 | mitchellh | defn: "^" is a reader macro for metadata, but its deprecated in 1.1.0 |
| 18:28 | mitchellh | defn: It does the same thing as the "meta" function |
| 18:28 | defn | mitchellh: what is it replaced by? |
| 18:29 | defn | ah |
| 18:29 | mitchellh | defn: It was always shorthand for "meta" |
| 18:29 | mitchellh | yep |
| 18:29 | defn | so now it will always be (meta v) |
| 18:29 | defn | instead of ^v? |
| 18:29 | mitchellh | Yep |
| 18:30 | mitchellh | I'm not sure why, I'm fairly new to clojure, perhaps readability? I'm unsure |
| 18:30 | mitchellh | I just read the messages the 1.1 RC1 is giving me :) |
| 18:30 | hiredman | rich wants to use ^ for type hinting |
| 18:30 | defn | :) |
| 18:30 | mitchellh | hiredman: thanks! |
| 18:32 | mitchellh | I have a question about "leiningen" if anyone is savvy: I'm trying to write a lib which uses HtmlUnit but HtmlUnit 2.6 isn't in maven central so "lein deps" doesn't work with it. What other options do I have to specify it as a dependency? |
| 18:32 | defn | ,(str "*" (ns-name (:ns (meta #'and)) "*") |
| 18:32 | clojurebot | EOF while reading |
| 18:32 | defn | ,(str "*" (ns-name (:ns (meta #'and))) "*") |
| 18:32 | clojurebot | "*clojure.core*" |
| 18:32 | neotyk | hiredman: I'm trying to run clojurebot and have some issues getting it to run, can you help? |
| 18:33 | neotyk | hiredman: or do you have some instructions on how to run it |
| 18:34 | hiredman | now is not a good time |
| 18:34 | hiredman | clojurebot () { rlwrap java -server -Djava.security.manager -cp $CLASSPATH:./clojurebot/ clojure.main -i clojurebot/hiredman/clojurebot.clj -r |
| 18:34 | hiredman | } |
| 18:35 | hiredman | that's how I start it |
| 18:37 | neotyk | hiredman: what version of clojureql bot depends on? one I got from http://www.gitorious.org/clojureql/ is using different name space |
| 18:40 | neotyk | hiredman: what is in $CLASSPATH ? |
| 18:45 | defn | ,(re-gsub #"\n" "" "hello world\n testing\n") |
| 18:45 | clojurebot | "hello world testing" |
| 18:47 | neotyk | hiredman: thanks anyway, will let you know if I manage to run it |
| 18:49 | defn | what is pr-on in (source pr)? |
| 18:49 | defn | ,(source pr) |
| 18:49 | clojurebot | java.lang.Exception: Unable to resolve symbol: source in this context |
| 18:52 | defn | the source for pr shows: (defn pr ([] nil) ([x] (pr-on x *out*))...) |
| 18:52 | defn | but i can't find pr-on anywhere |
| 18:53 | q1 | hi |
| 18:56 | q1 | any ideas on how to build a list of all defs defined in a particular library? (using clojure.contrib.repl-utils) |
| 18:56 | defn | q1: (vals (ns-publics 'clojure.core)) |
| 18:56 | defn | that gets you closer |
| 18:57 | q1 | yup looks like just a parsing problem now |
| 18:57 | defn | q1: whatcha building if i may ask? |
| 18:57 | q1 | slickedit module for clojure |
| 18:58 | q1 | i'd like to color code a list of common defs for example |
| 18:58 | defn | ah, neat |
| 18:59 | somnium | q1: I think you mean vars (not to be that guy, just because symbols/vars can lead to confusion) |
| 19:05 | q1 | somnium: yes guess im interested in public vars bound to functions in commonly used libs |
| 19:05 | q1 | this does the trick: (keys (ns-publics 'clojure.core)) |
| 19:07 | defn | q1: yeah, i used keys at first |
| 19:07 | defn | but then switched to vals |
| 19:07 | defn | since you'll probably be inspecting the #' versions |
| 19:08 | ubii | starting to dig into clojure and am looking for recommendations on what the best clojure development platform is for linux |
| 19:08 | the-kenny | ubii: Emacs + Slime |
| 19:08 | defn | ubii: it's painful at first, but you will learn to love it |
| 19:09 | defn | i learned emacs while i started learning clojure |
| 19:09 | defn | ubii: basically you need to get ELPA, then M-x package-install clojure-mode, swank-clojure, slime-repl, and slime |
| 19:09 | defn | and you're off to the races |
| 19:11 | ubii | that is what I am currently using, but being a vi guy for ever and a day, emacs takes a bit to get use to |
| 19:11 | the-kenny | It takes some time, but it's the best lisp editor out there. |
| 19:12 | defn | ubii: yeah, it takes time, you can get vimclojure setup and all, but i had nothing but trouble with it, you will learn some of the SLIME tricks and you'll be hacking like a pro in no time |
| 19:12 | the-kenny | (paredit is a must-have) |
| 19:12 | somnium | + emacs 23 even looks good by default now |
| 19:12 | defn | when i found M-. -- that was awesome |
| 19:12 | defn | yeah, with xft |
| 19:12 | somnium | I love the adjust opacity feature |
| 19:12 | defn | paredit-mode quick guide: M-s, M-r, C-) |
| 19:12 | ubii | agreed, v23 looks way better than v22 |
| 19:14 | kwertii | What's the most efficient and idiomatic way to make a per-thread spinner (i.e. a function that returns true or nil in strictly alternating sequence each call) in Clojure? a var? a closure? |
| 19:15 | ubii | I currently am running v23 with clojure-mode, slime, swank-clojure and have paredit installed |
| 19:15 | kylesmith | ,(take 4 (iterate not true)) |
| 19:15 | clojurebot | (true false true false) |
| 19:15 | ubii | just trying to get use to emacs and was wondering if there were any other comparable options that had less of a learning curve |
| 19:16 | kwertii | kylesmith: I don't know in advance how many times it will be called |
| 19:16 | ubii | but I agree emacs is the way to go, so I guess I just need man up and dig in |
| 19:16 | somnium | ubii: if you're not set in your emacs ways yet I would encourage trying ergoemacs too, the standard key-bindings are way saner than emacs defaults (pretty close to vi actually) |
| 19:16 | kylesmith | kwertii: so just omit the call to take. iterate returns an infinite seq |
| 19:19 | ubii | hmm, looking at http://ergoemacs.org, it appears that it is windows only |
| 19:19 | defn | ubii: one tip -- it's like quitting smoking, you need to change your $EDITOR, alias vim to emacs, etc. |
| 19:19 | somnium | ubii: no, its an elisp package |
| 19:19 | kwertii | kylesmith: interesting, so something like (let [spinner (iterate not true)] .... (foo data (fnext spinner))) ? |
| 19:19 | defn | what the heck is ergoemacs |
| 19:20 | somnium | ubii: theres a zip file under the windows download |
| 19:22 | somnium | http://code.google.com/p/ergoemacs/wiki/DeveloperIntro |
| 19:23 | ubii | defn: yeah, I thought about just trying to go cold turkey and only using emacs, but I use vi so much for work that I have simply not been able to make the switch yet |
| 19:24 | somnium | ubii: viper mode? |
| 19:24 | defn | can (def)'s have a docstring? |
| 19:24 | defn | (def abc "docstring") |
| 19:25 | somnium | ,(doc defvar) |
| 19:25 | clojurebot | "clojure.contrib.def/defvar;[[name] [name init] [name init doc]]; Defines a var with an optional intializer and doc string" |
| 19:25 | ubii | I use to do all of my development in vi, now I have wussed out as I sometimes use gedit or textmate when I am feeling lazy |
| 19:25 | defn | thanks somnium |
| 19:25 | ubii | emacs is way more powerful than vi, so I just need to start forcing myself to use it more |
| 19:26 | defn | ubii: yeah, like i said, just remove your other editors, make them map to emacs, it will be painful for about a week, and then you will start to enjoy yourself |
| 19:26 | defn | it's a hoot once you get over the first few bumps |
| 19:27 | ubii | as part of my original 12-step plan on migrating to emacs, I am now using emacs as my irc client instead of xchat :) |
| 19:28 | defn | hehe, use C-h a |
| 19:28 | ubii | defn: yeah, I just need to get my balls out of my momma's purse and start using emacs exclusively |
| 19:29 | ubii | that would be very helpful |
| 19:29 | ubii | I need Emacs for the impatient :) |
| 19:29 | somnium | http://xahlee.org/emacs/emacs.html << is pretty good |
| 19:29 | ubii | thx, I will check it out |
| 19:30 | defn | I don't have a lot of information, not a book, just like 20 things that i slowly learned that i wish i would have knew right away |
| 19:30 | defn | there's just so damn much... |
| 19:31 | the-kenny | C-h t ftw :) |
| 19:32 | ubii | wow, just caught myself doing "vi .emacs" to check a config setting |
| 19:32 | kwertii | why does this not work? (let [spinner (iterate not true)] (list (fnext spinner) (fnext spinner))) ;; (false false) |
| 19:32 | ubii | is that bad or what? :) |
| 19:33 | somnium | http://xahlee.org/emacs/emacs_kb_shortcuts_pain.html |
| 19:33 | the-kenny | ubii: put alias vi=emacs in your .bashrc or so |
| 19:33 | somnium | the-kenny: :-) |
| 19:33 | ubii | yep, that would resolve the problem, wouldn't it |
| 19:35 | kylesmith | kwertii: you're not re-binding spinner. |
| 19:36 | kylesmith | so you can't just bash it in place |
| 19:36 | kwertii | is there anything like pop that works on sequences? |
| 19:37 | pdk | what is the deal with this |
| 19:37 | pdk | after installing counterclockwise eclipse flips and gives a null pointer exception trying to load a clj file |
| 19:39 | somnium | ,(butlast (range 5)) |
| 19:39 | clojurebot | (0 1 2 3) |
| 19:39 | ubii | hmm, had forgotten about the emacs screencast out on peepcode |
| 19:40 | ubii | sweet, there is jQuery screencast as well, guess I know what I will be watching tonight :) |
| 19:41 | kylesmith | kwertii: (let [a (atom true)] (defn spinner [] (swap! a not))) |
| 19:41 | ubii | pizza is here, so I need bail, thx for everyones recommendations |
| 19:41 | defn | array element type mismatch... any ideas? |
| 19:41 | kwertii | kylesmith: interesting, thanks |
| 19:41 | kylesmith | kwertii: but you should really learn how to work with immutable data |
| 19:41 | kwertii | kylesmith: I'm working on that :) |
| 19:43 | kwertii | clojure.org/lazy says "A seq is like a logical cursor". doesn't that imply that you can iterate through an infinite sequence without using atoms? I'm not seeing anything in the API that does that. |
| 19:43 | defn | (defn apply-markdown [path] (doseq [f (file-seq (java.io.File. path))] (sh "/usr/local/bin/markdown" f "-f" (str f ".html") "-x codehilite"))) |
| 19:43 | defn | i get an array element type mismatch |
| 19:45 | ubii | sweet, the Emacs screencast is now part of my O'reilly Safari subscription, so I don't have to buy it |
| 19:45 | defn | nevermind, needed to coerce f to (str f) |
| 19:45 | ubii | so is the Functional Programming with Clojure screencast, which I already watched |
| 19:46 | ubii | finally, this damn scription is starting to pay off :) |
| 19:46 | ubii | later all |
| 19:53 | defn | oh my god that is slow |
| 19:54 | defn | running that above apply-markdown function on 1007 files :( |
| 19:55 | q1 | question. can anyone explain the NIL next of the lines that REPL is printing: (map #(println %) (keys (ns-publics 'clojure.core))) |
| 19:56 | arohner | q1: println returns nil |
| 19:56 | q1 | ah ok lol |
| 19:56 | q1 | thought i was going nuts |
| 19:57 | arohner | also, map creates a new seq of the return values of the function |
| 19:57 | arohner | if you want to use side effects, doseq is a better option |
| 19:57 | q1 | filter seems most applicable here |
| 19:57 | arohner | map is lazy, because it's assumed that 'f' is pure |
| 19:57 | q1 | just wanted a printout |
| 19:58 | q1 | you are right about doseq. thanks! |
| 20:03 | pdk | ok stupid q, how do you go about uninstalling eclipse plugins |
| 20:08 | kylesmith | kwertii: if you have a loop/recur algorithm (for example), just pass (next spinner) on each recur. |
| 20:09 | pdk | q1 everything in clojure returns something or another even if it's nil |
| 20:16 | q1 | pdk: yeah. just not used to the REPL output. thanks. |
| 20:28 | polypus | you guys have an opinion on jquery vs dojo? |
| 20:30 | polypus | i'm trying to pick a js lib to front a clojure app |
| 20:31 | pdk | guess i should just reinstall eclipse since counterclockwise left its mark |
| 20:43 | somnium | polypus: dojo is my preference for writing new javascript, but jquery usually wins for instant functionality. |
| 20:58 | johnmn3 | and now I embark on a week long mission home from afghanistan. |
| 20:59 | johnmn3 | hopefully, I'll be able to sign in to irc from Bagram, like did a year ago. later |
| 21:39 | pdk | so is counterclockwise for eclipse supposed to not work |
| 21:42 | polypus | somnium: ty, i'm going to go with jquery. knock on wood |
| 23:07 | technomancy | is the azul JVM free software? |
| 23:09 | danlarkin | ha! |
| 23:11 | technomancy | well they sell hardware, don't they? |
| 23:12 | danlarkin | and they want you to want their jvm |
| 23:14 | danlarkin | in this inspired by cliff click's latest post? pretty interesting read |
| 23:14 | technomancy | so they found some loophole in Sun's application of the JVM |
| 23:14 | technomancy | well I was about to be interested in it until I realized it was about stuff I'll never use. |
| 23:15 | technomancy | *loophole in Sun's application of the GPL, that is |
| 23:15 | pdk | what's the gist of it |
| 23:16 | danlarkin | there's this mention on wikipedia, don't know if it's relevant, http://en.wikipedia.org/wiki/Azul_Systems#Legal_issues |
| 23:16 | technomancy | danlarkin: nah; that's patent fluff |
| 23:17 | technomancy | they've been around since before the relicensing of the codebase though, so they must have some grandfather clause |
| 23:17 | danlarkin | it'd be fun to work on azul boxes instead of ec2, that's for sure :-D |
| 23:18 | technomancy | boxes? you need more than one? =) |
| 23:20 | pdk | he's going to construct skynet you see |
| 23:23 | technomancy | hah; a Lua implementation on the JVM called Kahlua: http://code.google.com/p/kahlua/ |
| 23:23 | technomancy | well played, Brazil. |
| 23:54 | defn | nevermind! M-x hs-minor-mode, C-c @ C-h |
| 23:55 | technomancy | lousy binding though |
| 23:55 | defn | yeah, terrible |
| 23:55 | defn | what do you bind to tech? |
| 23:55 | defn | or do you not use it? |
| 23:55 | technomancy | I just keep my files short |
| 23:56 | technomancy | unfortunately now that I switched to a widescreen I'm keeping them shorter than before |
| 23:56 | defn | yeah good call -- im really new to this whole structuring in nested directories and all that |
| 23:56 | technomancy | stupid aspect ratio |
| 23:56 | defn | so ive been building these massive source files |
| 23:56 | defn | and then splitting it up |
| 23:56 | technomancy | every time I open my old laptop I just get so jealous of the 4x3 display |
| 23:56 | defn | :) |
| 23:57 | technomancy | then I think to myself, "I should turn the brightness up--oh wait; it is all the way up. stupid non-LED display." =( |
| 23:57 | defn | yeah man, i know the feeling -- i have 4 displays at work with my emmaculate xmonad setup |
| 23:57 | defn | i get home and i have one big display, very different feeling |
| 23:57 | somnium | defn: do you run xmonad on top of gnome? |
| 23:57 | defn | yes |
| 23:58 | technomancy | I should just go get one of those portrait-oriented displays |
| 23:58 | technomancy | unfortunately they don't make laptops like that |
| 23:58 | defn | that's an interesting idea... |
| 23:59 | defn | portrait laptop display, the keyboard rotates once you open the laptop |
| 23:59 | technomancy | the Alto was portrait-oriented |
| 23:59 | technomancy | ahead of its time |
| 23:59 | defn | technomancy: could i have your opinion for a moment on some code ive been fiddling with? |