2009-01-15
| 03:21 | Lau_of_DK | Good morning gents |
| 03:31 | joma | is there a clojure command for writing to file or i have to go to Java? |
| 03:33 | yangsx | joma: clojure.contrib.duck-streams/spit |
| 03:38 | joma | god |
| 03:38 | joma | spit slurp etc, please stop |
| 03:53 | joma | if i need to do : (if (action) then action else something_else |
| 03:53 | joma | how can I write that without a let |
| 03:54 | joma | and without doing the action 2 times? |
| 03:54 | joma | like in python |
| 03:54 | joma | no not like in python |
| 03:57 | rottcodd | (or (action) (something-else)) |
| 04:01 | sleven | I mean break a string and keep intendation |
| 04:04 | bergermeister | (first (filter apply [action something-else]) |
| 04:20 | AWizzArd | clojurebot: max people |
| 04:20 | clojurebot | max people is 127 |
| 04:21 | hiredman | /list #clojure |
| 04:21 | hiredman | er |
| 04:58 | blackdog | i just upgraded to HEAD and my clj script doesn't want to find my -cp classpath anymore anyone else with this? |
| 05:09 | Lau_of_DK | your clj script ? |
| 05:10 | blackdog | my bash starting script |
| 05:10 | blackdog | it hasn't changed, points to the same places |
| 05:10 | blackdog | i'll try going back in svn a bit see if it starts working again |
| 05:13 | hiredman | do you use clojure.main? |
| 05:13 | blackdog | yes |
| 05:13 | blackdog | started last week or so, but it's been fin |
| 05:13 | blackdog | e |
| 05:14 | karmazilla | my script works fine: http://gist.github.com/47350 |
| 05:14 | hiredman | have you checked the --help output recently? the options may have changed |
| 05:14 | blackdog | checking |
| 05:48 | mikem` | hi, is there a way to obtain the current version (ie: the SVN build) of clojure at the REPL? |
| 05:49 | dhaya | mikem`: No way currently. |
| 05:50 | mikem` | dhaya: thanks. not a problem :) just wanted to double-check it's running the latest SVN |
| 06:45 | mikem` | i'm having trouble with chapter 9 of Programming Clojure, in the function create-snippets on page 209, create-table is not found. do I somehow need to require/use hsqldb first? |
| 06:49 | dhaya | mikem`: create-table is in clojure.contrib.sql |
| 06:52 | Lau_of_DK | mikem`: Do your self a favor and get familiar with: http://github.com/Lau-of-DK/clojureql/tree/master |
| 06:52 | mikem` | dhaya: ok, that was easy. thanks :) |
| 06:53 | mikem` | Lau_of_DK: looks interesting. i'll bookmark that and take a look again when i'm doing some real work |
| 06:53 | mikem` | thanks |
| 06:54 | Lau_of_DK | np |
| 07:05 | sleven | is Programming Clojure available for free as pdf or soemthing? |
| 07:06 | Fib | sleven: There's a beta PDF but it's not free |
| 07:08 | Fib | http://www.pragprog.com/titles/shcloj/programming-clojure |
| 07:12 | mikem` | Lau_of_DK: just got to a mention of clojureql in the book :) |
| 07:44 | blackdog | interesting when i have clojure.jar in my -Djava.ext.dirs path, HEAD svn does not find my other classes on the -cp classpath, if I add clojure.jar to -cp too everything works fine |
| 07:45 | blackdog | it used to work with all the jars including clojure.jar in -Djava.ext.dirs |
| 07:46 | AWizzArd | And for me it's even more strange. In Slime I have to put everything that I already have on my classpath also into swank-clojure-extra-classpaths, because my classpath itself is completely ignored. |
| 07:47 | rhickey | blackdog: "does not find" mean import doesn't work? |
| 07:47 | blackdog | mmm, i mention this as it was a breaking change for me |
| 07:47 | blackdog | yes |
| 07:47 | rhickey | blackdog: what OS/JVM? |
| 07:47 | blackdog | import fails when clojure.jar is in -Djava.ext |
| 07:48 | blackdog | (build 1.6.0_11-b03) |
| 07:48 | blackdog | ubuntu |
| 07:48 | blackdog | i don't know what svn version i had that was working |
| 07:49 | blackdog | i probably updated about 2 weeks ago |
| 07:49 | blackdog | today it failed |
| 07:51 | blackdog | that's import on other .clj files fail, clojure itself loads fine |
| 10:01 | durka | what does clojure.xml/startparse-sax do? |
| 10:02 | durka | it has no documentation and looks like it could call any of four methods on SAXParser |
| 10:03 | durka | is the idea to proxy DefaultHandler and pass that? |
| 10:05 | drewolson | hey all, should the "Getting Started" page on clojure.org be updated to show launching the repl with clojure.main? |
| 10:18 | Chouser | durka: the idea is to you to provide some other sax-compatible parser |
| 10:18 | Chouser | durka: I use it for tagsoup |
| 10:22 | Chouser | as I understand it, it's currently impossible to create a class with genclass that calls its own (or its super-classes') methods when it is constructed. |
| 10:22 | durka | because genclass doesn't look for an implementation until runtime? |
| 10:22 | Chouser | no, because the init function is called without access the 'this' |
| 10:23 | durka | that seems unhelpful |
| 10:26 | joma | if i want to do something sideeffectful X times, what do I use? |
| 10:26 | rhickey | (doc repeatedly) |
| 10:26 | clojurebot | Takes a function of no args, presumably with side effects, and returns an infinite lazy sequence of calls to it; arglists ([f]) |
| 10:27 | rhickey | (doc dotimes) |
| 10:27 | clojurebot | bindings => name n Repeatedly executes body (presumably for side-effects) with name bound to integers from 0 through n-1.; arglists ([bindings & body]) |
| 10:28 | Chouser | I've claimed before that this is because 'init' is run before any 'this' object has been created. But upon further reflection, I don't think that's possible. |
| 10:29 | Chouser | So now I'd guess that providing 'this' would be a mis-feature in some way, or that it was simple overlooked. |
| 10:29 | Chouser | simply |
| 10:30 | walters | Chouser: in the JVM the constructor is restricted to only calling code without reference to "this" before invoking the superclass constructor |
| 10:30 | walters | Chouser: typically though what i do in Java at least is define a private static method which does all the computation, and just call that |
| 10:31 | Chouser | hm, that's interesting. |
| 10:31 | walters | Chouser: maybe genclass could be split into pre-init and post-init? |
| 10:32 | Chouser | that's what I was thinking originally. :init could be left as-is, but there could be a new :post-init function |
| 10:32 | rhickey | Chouser: init is called before ctor, and provides args for it |
| 10:32 | Chouser | called before the super's ctor, but from inside the gen'ed class's ctor, right? |
| 10:33 | Chouser | the problem is if there is stateful initialization required by the superclass for which it has only methods, not ctor args. |
| 10:33 | Chouser | poorly designed superclass if you ask me, but they exist. |
| 10:34 | dhaya | ,(if (Boolean. "false") "true" "false") |
| 10:34 | clojurebot | "true" |
| 10:34 | dhaya | That looks like a bug. |
| 10:34 | Chouser | Currently the only solution is to have a fn that you must always use to 'new' your gen'ed class, so that it can do some init after 'new'. Seems dangerous. |
| 10:36 | rhickey | Chouser: post-init is possible, but there's no safe-to-use this to pass to init, since the object is allocated but not yet constructed (init being one step in that construction) |
| 10:37 | Chouser | ok. I was about to post a :post-init feature request to the issues page. |
| 10:37 | rhickey | go for it |
| 10:37 | durka | ,(Boolean. "false") |
| 10:37 | clojurebot | false |
| 10:37 | durka | ,(Boolean. "true") |
| 10:37 | clojurebot | true |
| 10:41 | rhickey | dhaya: any object that is not nil or Boolean.FALSE is true. Sometimes there will be a conversion for you, but if you are dealing with boxed Booleans not coming from Clojure or known to come from Boolean.valueOf, then you'll need to call .booleanValue on them |
| 10:52 | dhaya | rhickey: Ok. I take it there is some reason that clojure itself cannot do that for me? |
| 10:58 | dhaya | It also seems to me to be inconsistent with (= (Boolean. "false") false) returning true. |
| 10:58 | rhickey | dhaya: yes, the rest of the planet doesn't want if (and everything built on if) slowed down for that special case |
| 10:59 | rhickey | dhaya: is this a real problem or a theoretical one? |
| 10:59 | dhaya | rhickey: I just stumbled on it while taking input from stdin and passing it directly to a if after boxing. |
| 11:00 | rhickey | how did you get a Boolean ? |
| 11:00 | Chouser | eval? |
| 11:00 | rhickey | you are boing yourself? |
| 11:00 | dhaya | yes. |
| 11:01 | dhaya | I was boxing myself. |
| 11:01 | rhickey | public Boolean(boolean value) |
| 11:01 | rhickey | Allocates a Boolean object representing the value argument. |
| 11:01 | rhickey | Note: It is rarely appropriate to use this constructor. Unless a new instance is required, the static factory valueOf(boolean) is generally a better choice. It is likely to yield significantly better space and time performance. |
| 11:01 | rhickey | public static Boolean valueOf(boolean b) |
| 11:01 | rhickey | Returns a Boolean instance representing the specified boolean value. If the specified boolean value is true, this method returns Boolean.TRUE; if it is false, this method returns Boolean.FALSE. If a new Boolean instance is not required, this method should generally be used in preference to the constructor Boolean(boolean), as this method is likely to yield significantly better space and time performance. |
| 11:01 | rhickey | from the JavaDocs, please use valueOf |
| 11:02 | rhickey | this will return Boolean.FALSE, which will test consitional false in if |
| 11:02 | rhickey | conditional |
| 11:02 | dhaya | Ah. I see the distinction now. Thanks. |
| 11:02 | rhickey | np |
| 11:03 | asbjxrn | How can I from an agent action run two calculations in parallell? |
| 11:03 | rhickey | asbjxrn: send to 2 other agents |
| 11:04 | asbjxrn | but I want to wait for them to finish before eg. adding them again, and I can't run await? |
| 11:05 | Chouser | got an assert, did you? :-) |
| 11:06 | Chouser | asbjxrn: 'send' called in an agent action is held until the action completes and the agent has gotten its new value. |
| 11:09 | asbjxrn | Right. So if what I want to do is ((task 1) (in parallel (task 2) (task 3)) (task 4)) How would I do that? Not sure I understand. |
| 11:11 | rhickey | asbjxrn: you could write an in-parallel fn using executors and futures, a la: http://clojure.org/concurrent_programming |
| 11:12 | Chouser | I guess you'd have to use something other than agents or await for one of thse steps. |
| 11:13 | Chouser | your main task could be a regular Thread instead of an agent, or task 4 could wait on some blocking object rather than using 'await' |
| 11:13 | asbjxrn | But they're so nice. :) |
| 11:16 | Chouser | would pmap be appropriate for tasks 2 and 3? |
| 11:16 | asbjxrn | That test-stm function from the concurrent_programming page looks promising. Is there a lot of overhead in setting up/tearing down such a pool? |
| 11:20 | Chouser | is clojurebot pointing at the wrong repo? or is that feature just not working at the moment? |
| 11:20 | Chouser | clojurebot: latest? |
| 11:20 | clojurebot | latest is 1207 |
| 11:21 | rhickey | http://code.google.com/p/clojure/source/list |
| 11:22 | Chouser | clojurebot: latest is 1215 |
| 11:22 | clojurebot | Alles klar |
| 11:22 | Chouser | heh. hm. |
| 11:22 | karmazilla | clojurebot: latest? |
| 11:22 | clojurebot | latest is 1215 |
| 11:36 | cgrand | Hello! format, name and namespace are not hinted {:tag String}. Do I open an issue for this? |
| 11:37 | rhickey | cgrand: sure |
| 11:38 | cgrand | ok |
| 11:53 | lisppaste8 | rhickey pasted "call-par" at http://paste.lisp.org/display/73650 |
| 11:54 | asbjxrn | :) |
| 11:57 | rhickey | better name needed |
| 11:57 | danlarkin | papply? you'd have to change it a little though |
| 11:59 | rhickey | danlarkin: requiring the last arg be a seq would also require it be realized (i.e. not parallel) |
| 12:00 | cgrand | hmm... should force be made to work on Futures? |
| 12:00 | Chousuke | so it evaluates the arguments in parallel and applies op to them... hmm. |
| 12:00 | rhickey | cgrand: I would worry about the possibly hidden blocking |
| 12:01 | Chouser | pinvoke |
| 12:02 | rhickey | http://en.wikipedia.org/wiki/Platform_Invocation_Services |
| 12:03 | Chouser | Mmm... DLLs |
| 12:03 | Chouser | so yummy |
| 12:04 | rhickey | I don't want MS to sue me |
| 12:05 | Chouser | seque only uses one worker thread. |
| 12:05 | rhickey | something indicating that the args are parallel would be good |
| 12:05 | Chousuke | parallel-eval-args is too long :( |
| 12:06 | Chouser | nm, I was thinking there was more similarity between call-par and seque than there is. |
| 12:07 | Chouser | it could return a vector, in which case 'peval' is pretty close. |
| 12:07 | danlarkin | but is that too close to peeval? |
| 12:30 | sp00oon | how about simply: parallelize |
| 12:32 | sp00oon | I'm new to lisp & concurrent mind spaces so not sure if that has other connotations... |
| 12:35 | Chousuke | sp00oon: that sounds like a higher order function that takes a function and returns a parallelised version of it. |
| 12:35 | shoover`` | is it a side-effects thing? doparallel |
| 12:37 | lisppaste8 | rhickey annotated #73650 with "pvals, pargs, using pool" at http://paste.lisp.org/display/73650#1 |
| 12:37 | rhickey | shoover``: no, not side effects, collecting results |
| 12:39 | danlarkin | it's sortof reduce-like behavior |
| 12:42 | cgrand | Slighty different: par-args (or par-list or par-seq or...) and (apply f (par-args (expr 1) (expr 2))? |
| 12:52 | shoover`` | cgrand's approach seems more general. it's an apply, and the args are eval'ed in parallel. (apply f (peval a b c)) |
| 13:04 | danlarkin | nooo not peeval |
| 13:06 | rhickey | cgrand: are you talking about: http://paste.lisp.org/display/73650#1 ? |
| 13:08 | rhickey | pvals fn, could do plist as macro, leaving applying out of it |
| 13:11 | jkantz | in clojure, what's the idiomatic equiv of common lisp case? |
| 13:12 | Chouser | I don't know CL, but you might look at cond or condp |
| 13:21 | jkantz | ok thanks, condp will work |
| 13:32 | cgrand1 | rhickey: I'm sorry I didn't see your annotation. pvals (fn) and plist (macro) are fine. My point was to leave apply out of teh macro. |
| 14:28 | hiredman | you guys see the "Problem using fn macro" thread? |
| 14:28 | hiredman | XD |
| 14:31 | hiredman | I think the reply "if this gets fixed" really makes the thread |
| 14:35 | bitbckt | hiredman: "you're doing it wrong" |
| 14:35 | hiredman | bitbckt: yeah |
| 14:38 | gnuvince | This Mark Volkmann is... weird. |
| 14:42 | gnuvince | Do you guys refer to x as in (let [x 0] x) as a variable or as a binding? |
| 14:43 | bitbckt | gnuvince: binding |
| 14:44 | bitbckt | as in, "x is locally bound to..." |
| 14:45 | gnuvince | Thanks |
| 14:46 | gnuvince | When I speak of Clojure (or Haskell for that matter) to people used to languages like C or Java, they always ask "why is it called a variable if it can't change?" |
| 14:46 | gnuvince | I just realized that binding is probably a better term that would also be less confusing |
| 14:46 | bitbckt | I think it's easier when discussing such things with them to use "variable." |
| 14:46 | bitbckt | that's the term their used to |
| 14:47 | bitbckt | but binding is more accurate, I think |
| 14:47 | gnuvince | But like I said, they buck at the "you can't modify it?" part |
| 14:47 | bitbckt | yeah... that's a pain ;-) |
| 14:47 | rhickey | gnuvince: I've been saying a "local" |
| 14:48 | bitbckt | rhickey: that's a solid alternative |
| 15:01 | drewr | How do you get to a static member in an inner class? |
| 15:01 | walters | $ |
| 15:01 | drewr | Foo$Bar/baz => No such namespace: Foo$Bar |
| 16:00 | danlarkin | drewr: you have to import Foo$Bar |
| 16:00 | danlarkin | sorry for being an hour late |
| 16:01 | drewr | danlarkin: Yeah. Strange that having the package doesn't work for me. E.g., clojure.lang.LispReader$RegexReader/stringrdr |
| 16:04 | Lau_of_DK | /query chouser |
| 16:16 | Lau_of_DK | Anybody know what the maximum filesize is, that I can upload view a HTML-form ? |
| 16:18 | danlarkin | depends on the server |
| 16:18 | danlarkin | I think |
| 16:18 | danlarkin | which probably means it doesn't depend on the server, since I seem to be wrong more than right |
| 16:19 | drewr | :-) |
| 16:21 | Lau_of_DK | Hmmm Dan :) |
| 16:21 | Lau_of_DK | So its a matter of setting some MAX_FILE_SIZE var somewhere, and then its up to the server after that? |
| 16:39 | grosours | hi |
| 16:39 | Lau_of_DK | yo |
| 16:40 | durka | Lau_of_DK: are you using apache? |
| 16:40 | Lau_of_DK | Yep |
| 16:41 | durka | as i remember there is max_file_size, but also max_upload_size and max_post_size |
| 16:41 | durka | since files are uploaded by POST requests |
| 16:42 | Lau_of_DK | There is - I just couldnt work out if the system gave an upper limit - which I think it does, just dont know what that is |
| 16:46 | stuhood | hey gang |
| 16:46 | Lau_of_DK | Hey Stu |
| 16:47 | stuhood | is it necessary to add type hints to the 'this' parameter for functions used in gen-class? |
| 16:47 | danlarkin | hints are never necessary :) |
| 16:48 | danlarkin | Although! going by the rule I've set out, they are indeed necessary |
| 16:48 | stuhood | haha |
| 16:49 | hiredman | Lau_of_DK: clojureql do postgres yet? |
| 16:49 | Lau_of_DK | hiredman: I suspect that it does, but I have not tested yet. |
| 16:54 | danlarkin | Lau_of_DK: how's the create-table stuff handled, since there's :mysql and :sqlite specific handlers |
| 16:54 | Lau_of_DK | sqllite doesnt have type for columns, it has types for cells |
| 16:55 | Lau_of_DK | Mysql, postresql, mssql all have one type per column |
| 16:55 | danlarkin | ah mmhmm |
| 17:00 | stuhood | the trouble i'm running into with hints is that if you hint the 'this' parameter, the compiler cannot find the class definition, since it hasn't been gen-class'd yet... chicken and egg? |
| 17:01 | Chouser | that's not right. The class fully exists before you get to the method function definitions. |
| 17:01 | stuhood | i'm declaring the functions before executing gen-class... is that wrong? |
| 17:01 | hiredman | postgresql's alter table has a slightly different syntax than what clojureql is generating |
| 17:01 | Chouser | doesn't mean the classname is imported yet though -- have you tried using the full package and class name. |
| 17:02 | stuhood | yes, full package and class name |
| 17:02 | Chouser | stuhood: oh, yep. that's backwards. (ns my.package.fooclass (:gen-class ...)) (defn -mymethod ...) |
| 17:02 | stuhood | gotcha. because gen-class is just creating stubs, right? |
| 17:02 | stuhood | cool beans... thanks. |
| 17:03 | Chouser | yep, the gen'd class doesn't go looking for method implementations until as demanded at runtime. |
| 19:00 | rhickey | anyone on 1215 yet? |
| 19:02 | hiredman | I have a jar built, but I haven't done anything with it |
| 19:03 | hiredman | I think I used the 1215 jar file when I was trying to talk to postgresql with clojureql |
| 19:17 | durka | what hiredman said |
| 19:41 | durka_ | is anyone using yourkit on a >1 cpu machine? |
| 19:41 | durka_ | i'm trying to figure out why activity monitor reports a 2x higher cpu usage than yourkit does, for the same clojure program at the same time |
| 19:44 | burkelibbey | Probably activity monitor goes up to 200% for what I presume is a Core 2 Duo. |
| 19:44 | burkelibbey | </guess> |
| 19:47 | durka_ | well, it only goes up to 102% or so, but i am wondering if that is more-or-less evenly split across the core 2 duo |
| 19:47 | durka_ | and if that was the case i would wonder why yourkit only looks at one cpu |
| 19:52 | pjb3 | rhickey: I'm interested in learning more about how Clojure works under the hood, any recommendations on things to read to learn about the JVM, JIT, Classloaders, etc.? |
| 19:53 | rhickey | pjb3: I don't know that there's a single place with all this stuff - Java Concurrency in Practice is a must read, though |
| 19:55 | pjb3 | rhickey: Yeah, I have JCIP, only read the first few chapters, I suppose I should get through that |
| 20:00 | Cark | how do i replace an item in a list based on some predicate ? |
| 20:00 | Cark | there must be some way |
| 20:00 | durka | map? |
| 20:01 | Cark | mhh yes that's what i'm doing right now |
| 20:01 | Cark | let's say i have a list of users like this {:name "cark" :foo "bar"} |
| 20:02 | Cark | and i only need to change the user "cark in that list" |
| 20:02 | Cark | or update its value :foo from "bar" to "baz" really |
| 20:03 | Cark | lisppaste8 : url |
| 20:03 | lisppaste8 | To use the lisppaste bot, visit http://paste.lisp.org/new/clojure and enter your paste. |
| 20:03 | Chouser | Cark: assoc ? |
| 20:03 | Chouser | (doc assoc) |
| 20:03 | clojurebot | assoc[iate]. When applied to a map, returns a new map of the same (hashed/sorted) type, that contains the mapping of key(s) to val(s). When applied to a vector, returns a new vector that contains val at index. Note - index must be <= (count vector).; arglists ([map key val] [map key val & kvs]) |
| 20:04 | Cark | let me prepare an example =P |
| 20:05 | Chouser | sure |
| 20:07 | lisppaste8 | cark pasted "untitled" at http://paste.lisp.org/display/73679 |
| 20:08 | Cark | see the map form, i wonder if there is some library function to do that |
| 20:09 | Chouser | do you always look things up by :name ? |
| 20:09 | Cark | well in this case yes |
| 20:10 | Chouser | or to head in a different direction, are your hashes unique and their order in the list unimportant? |
| 20:10 | Cark | but this cold be a more general function |
| 20:10 | Cark | the order in the list is important |
| 20:10 | Chouser | yeah, I think it's not all that "general" anymore, but we may be able to tighten up that example a bit... |
| 20:11 | durka | perhaps an "assoc-if"? |
| 20:11 | Cark | ah that sounds promising =P |
| 20:12 | durka | i wasn't saying that exists, i was suggesting that someone write one :p |
| 20:12 | Chouser | but that really assumes an ordered seq of hashes -- not something I've seen very often. |
| 20:12 | durka | well, isn't that what defstruct is designed for |
| 20:12 | durka | which would imply that it is expected |
| 20:13 | Cark | what i'm using it for : i have a list of column in a csv file, and the cv-import stuff needs to assign column numbers with field names |
| 20:13 | Cark | csv-import |
| 20:14 | Chouser | durka: structs are just maps, and maps are supported. There's a library of functions to work with unordered sets of maps, but not ordered seqs of them. |
| 20:14 | durka | i see |
| 20:14 | Cark | anyways if you guy can't tell me about this function, that means it doesn't exist, and it's trivial to write one ...thanks ! |
| 20:15 | Chouser | hm, and since the list itself changes, we can't use an array-map. |
| 20:17 | Chouser | (map second (vals (assoc-in (zipmap (map :name users) (indexed users)) ["rick" 1 :foo] "baz"))) |
| 20:17 | lisppaste8 | durka annotated #73679 with "untitled" at http://paste.lisp.org/display/73679#1 |
| 20:18 | durka | eek |
| 20:18 | Chouser | hm. durka's is better than mine. |
| 20:18 | durka | but pretty specific to this example |
| 20:19 | durka | yours looks like it adds a lot of complexity, but maybe because i don't know what a zipmap is |
| 20:19 | Chouser | yeah, just a failed approach. |
| 20:19 | Chouser | hm, not even correct. It needs a 'sort' in there somewhere. skip it. |
| 20:20 | Chouser | durka: your solution is better in every way |
| 20:20 | durka | i think the more general answer to this question is "sql" |
| 20:20 | Chouser | or would be if at least one of the argument names wasn't a builtin function. |
| 20:21 | durka | actually all of them are |
| 20:21 | durka | i think |
| 20:21 | Chouser | yeah, I know. don't do that. |
| 20:21 | Chouser | ,[test map key val] |
| 20:21 | Chouser | ,(prn [test map key val]) |
| 20:21 | clojurebot | [#<core$test__4053 clojure.core$test__4053@1fd9b49> #<core$map__3371 clojure.core$map__3371@fee225> #<core$key__3235 clojure.core$key__3235@c57f88> #<core$val__3238 clojure.core$val__3238@de6570>] |
| 20:22 | durka | of course, core/assoc names it params map/key/val too |
| 20:22 | Chouser | shame on it, too, then. :-) |
| 20:29 | lisppaste8 | cark annotated #73679 with "untitled" at http://paste.lisp.org/display/73679#2 |
| 20:29 | Cark | there you go ! |
| 20:30 | lisppaste8 | Chouser annotated #73679 with "map-if" at http://paste.lisp.org/display/73679#3 |
| 20:30 | Chouser | hey! |
| 20:31 | Chouser | I still screwed up the usage, though. sheesh. |
| 20:32 | Cark | ahyes, stay consistent put the coll param at the end |
| 20:38 | Chouser | well, if there's a simpler approach, I'm not seeing it. |
| 20:38 | Cark | yep that's good enough =P |
| 20:38 | Cark | thanks ! |
| 20:45 | Chouser | (assoc-in (vec users) [((apply hash-map (mapcat reverse (indexed (map :name users)))) "rick") :foo] "baz") |
| 20:47 | Cark | i'm not sure i would understand the meaning of that after a couple of days |
| 20:47 | Cark | or minutes even |
| 20:58 | durka | so we take the names out, number them in order and reverse those so there is a list of name/number pairs. then flatten that out with the mapcat so there is a list of name, #, name, #, etc. we make a hash-map out of that, which is keyed by names and valued with numbers, and then look up "rick" to get the index of rick's record in the original list. with that index in hand, we create a vector (which is like a hashmap from indices to s |
| 20:58 | durka | well, now i understand it |
| 20:59 | lisppaste8 | Chouser annotated #73679 with "indexed seq" at http://paste.lisp.org/display/73679#4 |
| 20:59 | durka | not sure my brain dump is coherent for anyone else |
| 20:59 | Chouser | :-) |
| 20:59 | Chouser | durka: you got it. |
| 20:59 | durka | does that end up turning the original list into a vector |
| 21:00 | durka | or does assoc-in return a list |
| 21:02 | Chouser | a vector |
| 21:03 | Chouser | so, not strictly the same as the rest. |
| 21:03 | Chouser | All these are making the original change-rick-to-baz look pretty good. :-) |
| 21:03 | durka | heh |
| 21:08 | Cark | now i'll feel responsible for any delay in textjure =( |
| 21:18 | Chouser | heh. no, I'm pretty sure I'm resposible for any dealys in textjure. |
| 21:48 | danlarkin | le sigh |
| 21:49 | danlarkin | Caused by: java.io.FileNotFoundException: Could not locate calliope/conf/urls__init.class or calliope/conf/urls.clj on classpath |
| 21:49 | danlarkin | but it _is_ on my classpath |
| 22:00 | danlarkin | Hm. very tricky, it was running with -Djava.ext.dirs |
| 22:00 | danlarkin | I guess changes how classpath look ups work? who knows |
| 22:01 | durka | that's strange... |
| 22:01 | durka | classpath magic is black magic indeed |
| 22:02 | KevinAlbrecht | I have a program which uses "require" to include another clojure file, but when I use (load-file) from the Repl, it won't load the required file... what's the solution? |
| 22:04 | danlarkin | KevinAlbrecht: what's the exception it throws? |
| 22:04 | danlarkin | likely the file isn't on your classpath |
| 22:04 | durka | sounds like the opposite problem |
| 22:04 | durka | if require works |
| 22:04 | KevinAlbrecht | It throws a not on classpath exception |
| 22:05 | danlarkin | oh, right.. wait so which one works, KevinAlbrecht, require or load-file? |
| 22:05 | KevinAlbrecht | Ah, I get it now... so you need to add the current directory to your classpath |
| 22:06 | KevinAlbrecht | require works when I'm running the program as a script, but when |
| 22:06 | KevinAlbrecht | I load the program on the Repl, the require fails |
| 22:09 | KevinAlbrecht | thanks, danlarkin |
| 22:10 | KevinAlbrecht | I really hate classpath nonsense |
| 22:11 | durka | it seems like a great idea -- you just import packages, and java translates the names into directories and magically finds the class files |
| 22:11 | durka | but... it doesn't seem to work in practice |
| 22:12 | durka | it's the portable equivalent of dll hell |
| 22:12 | banisterfiend | Yo dawg, I heard you like recursion so we put a Yo dog, I heard you like recursion so we put a Yo dog, I heard you like recursion so we put a Yo dog, I heard you like recursion so we put a Yo dog... |
| 22:13 | durka | StackOverflowError |
| 22:14 | durka | at: net.freenode.irc.clojure |
| 22:14 | durka | Caused by: banisterfiend |
| 22:15 | banisterfiend | hehe |
| 22:15 | durka | ... ? more |
| 22:16 | durka | but apparently it is option-5 |
| 22:16 | danlarkin | ? |
| 22:16 | danlarkin | oooo |
| 22:16 | danlarkin | fun |
| 22:16 | banisterfiend | do you know of any programming langauges that use unicode in their keywords etc? |
| 22:16 | banisterfiend | i heard some functional languages are thinking about using an actual lambda symbol |
| 22:16 | danlarkin | fortress |
| 22:16 | danlarkin | Guy Steele's new language |
| 22:17 | hiredman | banisterfiend: there is a hack where you can use '?' for 'lambda' in ruby |
| 22:18 | banisterfiend | hiredman: really? how do i find out about it? |
| 22:18 | hiredman | http://www.oreillynet.com/ruby/blog/2007/10/fun_with_unicode_1.html |
| 22:18 | hiredman | very simple |
| 22:18 | hiredman | (very silly) |
| 22:19 | durka | ,(let [? 3.14] (* 2 ?)) |
| 22:19 | clojurebot | 6.28 |
| 22:20 | hiredman | ? shoudl be a lazy seq of the digits of ? |
| 22:20 | arohner | There's a scheme hack for emacs that replaces (lambda with (<lambda symbol> |
| 22:21 | arohner | it's display only, but still cool |
| 22:21 | banisterfiend | hiredman: is that just ruby 1.9 or 1.8 too? |
| 22:21 | hiredman | banisterfiend: 1.8 |
| 22:22 | hiredman | dunno if it even works on 1.9 |
| 22:22 | banisterfiend | cool |
| 22:22 | banisterfiend | well proc in 1.9 is actually a Proc.new so should probably change the alias to a lambda |
| 22:24 | hiredman | ,(let [f (? [x] x)] :a) |
| 22:24 | clojurebot | :a |
| 22:26 | hiredman | oh |
| 22:26 | hiredman | duh |
| 22:26 | hiredman | the nyquil is kicking in |
| 22:26 | hiredman | ,(let [f (? [x] x)] (f :a)) |
| 22:26 | clojurebot | :a |
| 22:33 | hiredman | ,(((S K) K) :a) |
| 22:33 | clojurebot | :a |
| 22:35 | durka | oh no not that language :( |
| 22:40 | drewr | danlarkin: http://groups.google.com/group/clojure/msg/f65dd874f779b15c |
| 22:40 | drewr | Not sure how much that's related to your classpath issue. |
| 22:40 | danlarkin | ahh ha |
| 22:40 | danlarkin | interestingk |
| 22:42 | durka | (defn sgn [x] (if (>= 0 x) 1 -1)) |
| 22:42 | durka | (defn ? [n] (.doubleValue (apply + (take n (map #(/ 4 %) (iterate #(* (sgn %) (+ 2 (Math/abs %))) 1)))))) |
| 22:42 | durka | (? 359) |
| 22:42 | durka | 3.14437816350691 |
| 22:43 | durka | above that Doubles don't cut it |
| 22:44 | lisppaste8 | durka pasted "pi" at http://paste.lisp.org/display/73683 |
| 22:44 | durka | Ratios seem to be rather higher precision ^ |
| 22:45 | durka | hiredman: you may consider your ? lazy seq request beaten to death |
| 22:45 | Cark | hey ... (float your-very-long-number) returns NaN |
| 22:46 | hiredman | that's not a lazy-seq of digits |
| 22:46 | durka | Cark: yeah, float can't hold that many digits |
| 22:46 | durka | above (? 359) it does that |
| 22:47 | Cark | that's the problem with not having the full numeric tower |
| 22:47 | durka | hiredman: true. but it is a sum of a lazy seq of the terms of 4*arctan(1) :) |
| 22:49 | Cark | lispworks says your approximation is 3.1405926 |
| 22:49 | Cark | better but not quite it yet |
| 22:57 | durka | is it a bug that take seems to hang on exceptions? |
| 23:06 | yangsx | what is the perl equivalent for s/ab([0-9]+)cd/[\1]/ ? I mean how to refer to the captured group in re-gsub, for instance |
| 23:06 | yangsx | equivalent for the Perl* |
| 23:07 | danlarkin | you can use re-seq |
| 23:07 | danlarkin | or re-groups |
| 23:08 | yangsx | can re-seq or re-groups be used in re-gsub's replacement? |
| 23:10 | hiredman | yangsx: java has its own back reference syntax |
| 23:10 | hiredman | $1 |
| 23:12 | yangsx | hiredman: thanks, exactly what I'm looking for. I'm very unfamiliar with Java. |
| 23:12 | hiredman | ,(.replace "123nd" "(\\d+)nd" "$1ND") |
| 23:12 | clojurebot | "123nd" |
| 23:12 | hiredman | er |
| 23:13 | hiredman | ,(.replaceAll "123nd" "(\\d+)nd" "$1ND") |
| 23:13 | clojurebot | "123ND" |
| 23:21 | durka | hiredman: if lazy hexadecimal digits are satisfying enough, http://en.literateprograms.org/Pi_with_the_BBP_formula_(Python) should suffice. i don't understand it, but maybe i'll come back to it later if i'm bored again... |
| 23:56 | durka | Chouser: i just wrote a function with a parameter named "key", and tried to call clojure.core/key in the function, and it took me about 15 minutes to find the cause of the exception |
| 23:57 | durka | so there i am |
| 23:57 | durka | let this be a lesson to me |
| 23:59 | Chouser | :-) yes |