2009-05-10
| 00:04 | gcv | ah -- the swank-clojure-find-package looks suspicious |
| 00:28 | ataggart | how do I create a "block" for an if? e,g. (if predicate then-do-a-bunch-of-stuff) |
| 00:28 | ataggart | make it a separate function? |
| 00:30 | ataggart | aha, just below the documentation for if |
| 00:30 | ataggart | (do ...) |
| 01:39 | gcv | wow, figured it out... the answer is to start swank-clojure before opening up a .clj source file. |
| 01:40 | gcv | swank-clojure-slime-mode-hook in swank-clojure.el uses (set (make-local-variable ...)) to define the way to figure out the current package. If a buffer already has a .clj file open, then this hook does not run, and so slime tries to figure out the current namespace using a Common Lisp regexp. |
| 01:47 | gcv | actually correction. the hook does run, but if slime isn't running, slime-find-buffer-package-function is unbound, and so it never gets set for when slime loads. |
| 02:36 | cads | hi, in clojure.set, I'm trying to do (defn subset? ... ([s1 s2 & sets] (let [bubbled-sets (bubble-max-key count (conj sets s2 s1))] (apply and (map subset? bubbled-sets (rest bubbled-sets))))))) |
| 02:37 | cads | it compiles okay |
| 02:38 | hiredman | erm |
| 02:38 | cads | I've omitted the code for the other argument cases here |
| 02:38 | cads | but when I try to start clojure, I get an error |
| 02:38 | hiredman | ,^and |
| 02:38 | clojurebot | java.lang.Exception: Can't take value of a macro: #'clojure.core/and |
| 02:38 | hiredman | you cannot apply a macro |
| 02:38 | cads | Caused by: java.lang.Exception: Can't take value of a macro: #'clojure.core/and |
| 02:38 | cads | yea |
| 02:38 | hiredman | (reduce #(and % %2) ...) |
| 02:39 | replaca | unless you use stuart's "secret |
| 02:39 | replaca | " apply macro function |
| 02:39 | hiredman | replaca: ick |
| 02:39 | replaca | :-) |
| 02:39 | cmvkk | shouldn't there be a non-macro function that does the same thing as and? |
| 02:40 | replaca | that's why it's secret |
| 02:43 | cads | why's and a macro |
| 02:43 | cmvkk | so that it can short circuit. |
| 02:43 | cmvkk | so that if one argument returns false, the remaining arguments won't be evaluated at all. |
| 02:43 | cads | yeah but then you can't and a list of truth values? |
| 02:43 | hiredman | ,(and nil (println :foo)) |
| 02:43 | clojurebot | nil |
| 02:43 | hiredman | sure you can, just use reduce |
| 02:43 | cmvkk | so where's the 'every' function, that's what I want to know. |
| 02:43 | cmvkk | we have 'some' |
| 02:43 | cads | can I get short circuiting with something like reduce? |
| 02:43 | hiredman | ... |
| 02:43 | cads | am I going to have to use a maybe monad? :D |
| 02:43 | _mst | ,^every? |
| 02:43 | clojurebot | nil |
| 02:43 | replaca | cads: no, but it's not too hard to write a version that does something like that |
| 02:43 | hiredman | ,(doc every?) |
| 02:43 | clojurebot | "([pred coll]); Returns true if (pred x) is logical true for every x in coll, else false." |
| 02:43 | _mst | hurrah :) |
| 02:43 | cads | it's a special case of reduce that passes a logical value, anyways |
| 02:43 | cads | ah |
| 02:43 | hiredman | ^ is reader syntax for (meta ...) |
| 02:43 | cmvkk | hmm |
| 02:43 | _mst | ah, yes. I'd mistaken it for magic bot syntax :) |
| 02:43 | cmvkk | i guess (every? identity ...) is mostly the same as (apply and ...) when you don't care about short circuiting. |
| 02:43 | hiredman | ~def every? |
| 02:44 | hiredman | there is no reason every? couldn't short circuit, and it may well do so |
| 02:44 | _mst | there's also (not-any? pred col) which presumably short-circuits... |
| 02:45 | cmvkk | hmm that's true. |
| 02:45 | cmvkk | actually, if you passed it a lazy-seq I bet it would. |
| 02:45 | hiredman | uh |
| 02:45 | hiredman | I guess it does short circuit |
| 02:45 | cmvkk | well then. |
| 02:46 | hiredman | ~botsnack |
| 02:46 | clojurebot | thanks; that was delicious. (nom nom nom) |
| 02:46 | cads | how do I print out the source code of a public function? |
| 02:46 | hiredman | ~def source |
| 02:46 | hiredman | better check to if that worked, crontrib source lookup is new |
| 02:47 | cmvkk | seems to have worked. |
| 02:47 | cads | ,(source 'every?) |
| 02:47 | clojurebot | java.lang.Exception: Unable to resolve symbol: source in this context |
| 02:47 | durka42 | don't quote the function name |
| 02:47 | durka42 | it's in clojure.contrib.rep-utils |
| 02:47 | durka42 | and clojurebot won't do it because he won't do IO |
| 02:47 | cads | ,(do (use 'clojure.contrib.repl-utilities) (source every?)) |
| 02:47 | clojurebot | java.lang.Exception: Unable to resolve symbol: source in this context |
| 02:47 | cads | ok |
| 02:48 | hiredman | cads: clojurebot just sent a url leading to the source of every? |
| 02:48 | hiredman | just click on it |
| 02:50 | cads | ~def every? |
| 02:51 | cads | that short circuits even with the recur there, right? |
| 02:52 | hiredman | yes |
| 02:52 | hiredman | because and is like do, but it stops if something is false or nil |
| 03:09 | djkthx | is there a way to get read-line to work properly in the slime repl? |
| 03:09 | djkthx | when i use it in slime, it never stops accepting input |
| 03:11 | hiredman | ,(doc read-line) |
| 03:11 | clojurebot | "([]); Reads the next line from stream that is the current value of *in* ." |
| 05:33 | cads | I'd like to contribute some functions to clojure.set, are there existing tests and stuff I could add to? |
| 05:34 | kotarak | cads: tests (if there are any) are probably in contrib in test_clojure |
| 05:35 | hiredman | make sure you get a CA in |
| 05:43 | cads | what's CA? |
| 05:44 | cads | I'm thinking cellular automaton :) |
| 05:47 | hiredman | contributor agreement |
| 05:47 | hiredman | http://clojure.org/contributing |
| 09:09 | jal648 | greetings all, I'm hoping to demo a bit of clojure at my work tomorrow, and I was going to use the ants.clj demo. |
| 09:10 | jal648 | I have a quad core machine, and was hoping I could show all the cpu's being used. My question is, should I expect to see all four used when I'm running the ants demo? |
| 09:10 | Chouser | yes |
| 09:10 | jal648 | Hmm, it did not seem to... |
| 09:11 | jal648 | I launched the code through the REPL, that shouldn't matter though right? |
| 09:11 | Chouser | right |
| 09:12 | Chouser | I haven't actually tried on a 4-core. Now that I have one, I should try it... just a sec. |
| 09:14 | Chouser | hm, that's hardly using any CPU at all |
| 09:16 | jal648 | I was wondering if perhaps the demo is out of date. |
| 09:16 | Chouser | seems likely, but I would expect that to cause an error, not just a low CPU usage. |
| 09:17 | Chouser | I think there may just be insufficient work to keep all my cores busy. |
| 09:17 | jal648 | I haven't been paying as much attention to the community the last few months, do you know if there's a different example out there that shows off the concurrent stuff? |
| 09:19 | jal648 | maybe I'll just try increasing the number of ants... |
| 09:27 | Chouser | yeah, using 8 for nants-sqrt helps, as does changing ant-sleep-ms to 10 |
| 09:27 | Chouser | but it's still not pegging all 4 cpus |
| 09:28 | Chouser | each of the 4 are averaging 40% for me |
| 09:30 | jal648 | I did 20 nants-sqrt and made the dimensions 120, I'm showing around 220% cpu usage which is enough for the demo I think |
| 09:30 | Chouser | so they're all being used, just not fully |
| 09:31 | Chouser | ok |
| 09:31 | jal648 | yeah thanks for the help! |
| 11:44 | durka42 | whoops |
| 11:45 | durka42 | contrib.javalog doesn't compile |
| 11:45 | durka42 | [java] java.lang.NoSuchFieldException: GLOBAL_LOGGER_NAME (javalog.clj:49) |
| 11:46 | durka42 | oh, java 6 |
| 11:46 | durka42 | my bad |
| 11:46 | durka42 | there should be a warning about that somewhere more obvious than the top of javalog.clj |
| 11:48 | durka42 | and i am using java 6... |
| 11:56 | durka42 | sorry about the noise |
| 11:56 | durka42 | apparently ant ignores the settings in Java Preferences and reads $JAVA_HOME instead |
| 12:09 | eee | hi |
| 12:10 | eee | I'm trying to get intuition as to when to do things with java calls? My guess is that when you can't find it in the API, you can use contrib or the java way. |
| 12:10 | eee | for example |
| 12:11 | eee | seems like an obvious thing to want to test a set for "hasKey" (python) |
| 12:11 | eee | do you just use .contains ? |
| 12:11 | eee | i know someone wrote "includes?" in the contrib |
| 12:12 | eee | i just wanna check membership and I can't find the answer easily on the web |
| 12:15 | eee | i guess it's "(contains?) |
| 12:15 | eee | ,(contains? #{'3} '3) |
| 12:15 | clojurebot | true |
| 12:16 | eee | ,(.contains #{'3} '3) |
| 12:16 | clojurebot | true |
| 12:16 | eee | so there are two ways that work |
| 12:16 | eee | at least |
| 12:17 | eee | ,(contains? '(3) 3) |
| 12:17 | clojurebot | false |
| 12:17 | eee | ,(contains? '(3) '3) |
| 12:17 | clojurebot | false |
| 12:17 | eee | ,(contains? ('3) '3) |
| 12:17 | clojurebot | java.lang.ClassCastException: java.lang.Integer cannot be cast to clojure.lang.IFn |
| 12:17 | eee | ,(contains? '('3) '3) |
| 12:17 | clojurebot | false |
| 12:18 | eee | ,(contains? '("3") "3") |
| 12:18 | clojurebot | false |
| 12:18 | eee | ,(.contains '("3") "3") |
| 12:18 | clojurebot | true |
| 12:19 | eee | ??? so the clojure way doesn't always work? |
| 12:19 | liebke | ,(doc contains?) |
| 12:19 | clojurebot | "([coll key]); Returns true if key is present in the given collection, otherwise returns false. Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes. 'contains?' operates constant or logarithmic time; it will not perform a linear search for a value. See also 'some'." |
| 12:20 | eee | ,(doc some) |
| 12:20 | clojurebot | "([pred coll]); Returns the first logical true value of (pred x) for any x in coll, else nil. One common idiom is to use a set as pred, for example this will return true if :fred is in the sequence, otherwise nil: (some #{:fred} coll)" |
| 12:20 | liebke | eee: Note that for numerically indexed collections like vectors and Java arrays, this tests if the numeric key is within the range of indexes |
| 12:20 | liebke | that's the problem you were having |
| 12:21 | eee | so what's the most generic way to find membership |
| 12:21 | eee | in clojure |
| 12:21 | eee | for any collection |
| 12:23 | eee | that defn of contains seems out of whack with java's .contains |
| 12:23 | liebke | most generic way? I'm not sure, but you can use some: (some #(= 3 %) [4 5 3]) |
| 12:24 | eee | well, it seems like the java method works |
| 12:24 | eee | ,(.contains '("3") "3") |
| 12:24 | clojurebot | true |
| 12:24 | eee | ,(some '("3") "3") |
| 12:24 | clojurebot | java.lang.ClassCastException |
| 12:24 | eee | oh it needs a function |
| 12:24 | eee | i see |
| 12:25 | liebke | I think the most generic way to do it, is .contains. It's alright to use java in clojure after all :) |
| 12:25 | eee | to me, it's all right for esoteric stuff. for fundamental, primitive stuff, it seems wacky |
| 12:26 | eee | because you waste time looking |
| 12:26 | eee | like in lisp . . .i think there was "member?" |
| 12:26 | eee | or something |
| 12:26 | eee | (pmember |
| 12:26 | liebke | that's why clojure uses java types, so you can use java transparently |
| 12:27 | eee | i see |
| 12:27 | eee | so that'sa requirement on new collections if people were to write them |
| 12:27 | eee | must implement collection interface |
| 12:28 | eee | so I can count on this: http://java.sun.com/docs/books/tutorial/collections/interfaces/collection.html |
| 12:29 | eee | ,(doc do) |
| 12:29 | clojurebot | java.lang.Exception: Unable to resolve var: do in this context |
| 12:30 | eee | what happened to do? |
| 12:30 | eee | ,(doc doall) |
| 12:30 | clojurebot | "([coll] [n coll]); When lazy sequences are produced via functions that have side effects, any effects other than those needed to produce the first element in the seq do not occur until the seq is consumed. doall can be used to force any effects. Walks through the successive nexts of the seq, retains the head and returns it, thus causing the entire seq to reside in memory at one time." |
| 12:31 | eee | ,(doc do) |
| 12:31 | clojurebot | java.lang.Exception: Unable to resolve var: do in this context |
| 12:32 | chrizel | maybe because do is a special form? |
| 12:32 | chrizel | ,(doc let) |
| 12:32 | clojurebot | "([bindings & body]); Evaluates the exprs in a lexical context in which the symbols in the binding-forms are bound to their respective init-exprs or parts therein." |
| 12:32 | chrizel | ok O_o |
| 12:33 | eee | so (do) returns the last thing it doesn, right |
| 12:33 | eee | ?? |
| 12:33 | chrizel | ,(doc if) |
| 12:33 | clojurebot | "([tst & etc]); " |
| 12:33 | eee | that's what I was checking |
| 12:33 | chrizel | yes, do is for side effects |
| 12:33 | chrizel | like progn in common lisp or begin in scheme |
| 12:34 | eee | now that's cool. I wish you were the docs |
| 12:34 | eee | then I learn three languages at once! |
| 12:34 | chrizel | :-D |
| 12:50 | eee | do redefinitions take a long time? I know they are not idiomatic ... but like (def foo (conj foo blah)) |
| 13:00 | eee | (doseq i ,'(["a" "b"]) (print i)) |
| 13:00 | eee | ,(doseq i ,'(["a" "b"]) (print i)) |
| 13:00 | clojurebot | java.lang.IllegalArgumentException: doseq requires a vector for its binding |
| 13:00 | eee | ,(doseq i ,(vec '(["a" "b"]) (print i))) |
| 13:00 | clojurebot | java.lang.IllegalArgumentException: doseq requires a vector for its binding |
| 13:00 | eee | why that not work? |
| 13:00 | eee | i made it a vec |
| 13:02 | Chouser | ,(doseq [i ["a" "b"]] (print i)) |
| 13:02 | clojurebot | ab |
| 13:02 | eee | oh, it changed so that the i goes inside a vec |
| 13:02 | Chouser | yes |
| 13:03 | eee | ,(doseq [i ,'(["a" "b"])] (print i)) |
| 13:03 | clojurebot | [a b] |
| 13:03 | eee | someone's docs are old |
| 13:03 | eee | on the web |
| 13:04 | eee | does that mean you can have as many bindings and seqs as you want? |
| 13:04 | eee | well then you'd have to decide |
| 13:04 | eee | what to do when lengths were different |
| 13:06 | Chouser | yes, it acts like 'for' |
| 13:06 | Chouser | nested. |
| 13:06 | eee | ,(doc for) |
| 13:06 | clojurebot | "([seq-exprs body-expr]); List comprehension. Takes a vector of one or more binding-form/collection-expr pairs, each followed by zero or more modifiers, and yields a lazy sequence of evaluations of expr. Collections are iterated in a nested fashion, rightmost fastest, and nested coll-exprs can refer to bindings created in prior binding-forms. Supported modifiers are: :let [binding-form expr ...], :while test, :when test. |
| 13:06 | Chouser | (doseq [a [1 2 3] b [4 5 6]] (prn [a b])) |
| 13:06 | Chouser | ,(doseq [a [1 2 3] b [4 5 6]] (prn [a b])) |
| 13:06 | clojurebot | [1 4] [1 5] [1 6] [2 4] [2 5] [2 6] [3 4] [3 5] [3 6] |
| 13:07 | eee | oh ok |
| 13:07 | eee | woah |
| 13:07 | Chouser | it's got all the other 'for' features too. :while, :when, etc. |
| 13:07 | eee | ,(doc prn) |
| 13:07 | clojurebot | "([& more]); Same as pr followed by (newline). Observes *flush-on-newline*" |
| 13:07 | eee | ,(doc pr) |
| 13:07 | 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" |
| 13:08 | eee | i didn't know println was the long way |
| 13:08 | eee | either |
| 13:08 | Chouser | well, it does different things |
| 13:08 | Chouser | ,(println "hello") |
| 13:08 | clojurebot | hello |
| 13:08 | Chouser | ,(prn "hello") |
| 13:08 | clojurebot | "hello" |
| 13:09 | eee | i like the latter |
| 13:09 | eee | for what i'm doing |
| 13:09 | Chouser | ok |
| 13:09 | eee | would have avoided confusion for me |
| 13:09 | eee | (,prn ,'(["a"])) |
| 13:09 | eee | ,(prn ,'(["a"])) |
| 13:09 | clojurebot | (["a"]) |
| 13:09 | eee | ,(println ,'(["a"])) |
| 13:09 | clojurebot | ([a]) |
| 13:09 | eee | yup |
| 13:10 | eee | ,(println ,'(["1"])) |
| 13:10 | clojurebot | ([1]) |
| 13:10 | eee | at one point I forgot my numbers were strings |
| 13:11 | Chouser | ah sure |
| 13:12 | eee | so the 15-puzzle solver works now, but one ugly thing is that I have a global hash-set that I redefine everytime I insert something new into it. I know that's not idiomatic ... and at the very least it needs to be scoped to the file |
| 13:17 | lisppaste8 | eee pasted "i need a let binding, right?" at http://paste.lisp.org/display/79986 |
| 13:26 | eee | how do you make a closure that modifies what was originally (let)? |
| 13:26 | eee | so everytime it's called the let binding changes? |
| 13:28 | Chouser | let locals are immutable |
| 13:29 | eee | so here's what i've got now: http://paste.lisp.org/display/79986 . . . which I was gonna make with an outer (let), instead. |
| 13:29 | Chouser | if you're holding onto state and you want to be able to update it, you need a Clojure reference type: ver, ref, agen, or atom |
| 13:29 | Chouser | agent |
| 13:29 | eee | since nothing else uses "ALREADY-TRIED" |
| 13:29 | eee | i see |
| 13:30 | Chouser | the simplest, but not necessarily most correct, would be an atom |
| 13:30 | Chouser | (def already-tried (atom (hash-set))) |
| 13:30 | eee | or another hack (with-local-cars) |
| 13:30 | Chouser | then when you want to conj something onto it, (swap! already-tried conj new-state) |
| 13:31 | eee | cool |
| 13:31 | eee | i can do a clojure with an atom, I bet |
| 13:31 | eee | (let already-tried |
| 13:31 | eee | oops |
| 13:31 | Chouser | if you don't want it to be global, perhaps the atom should be passed into each fn |
| 13:31 | Chouser | or right, a closure |
| 13:32 | eee | (let [already-tried (atom (hash-set))] (defn sdsdfgsdfg ... |
| 13:33 | eee | so because it's an atom, do I want that in a synchronous section? |
| 13:33 | eee | dosync |
| 13:33 | eee | or something? |
| 13:33 | leafw | eee: atoms are AtomicObject, so no need. The are synchronized in themselves. |
| 13:33 | leafw | s/The/They |
| 13:34 | eee | nice |
| 13:34 | eee | hense the name |
| 13:35 | leafw | I think internally it uses this: http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/atomic/AtomicReference.html |
| 13:35 | eee | ,(doc swap!) |
| 13:35 | clojurebot | "([atom f] [atom f x] [atom f x y] [atom f x y & args]); Atomically swaps the value of atom to be: (apply f current-value-of-atom args). Note that f may be called multiple times, and thus should be free of side effects. Returns the value that was swapped in." |
| 13:37 | Chouser | eee: if the state of already-tried will ever need to be synchronized with any other state, then 'atom' is the wrong choice. |
| 13:37 | eee | then you gotta use @ or something to get the thing the atom holds |
| 13:37 | eee | right |
| 13:37 | eee | ok Chouser, thanks |
| 13:38 | eee | i'll start learning about the concurrency model a few projects later . . . that's the ultimate goal. to implement a few basic things to demonstrate the heap . . . branch and bound being the last, and then parallel branch about bound |
| 14:02 | Raynes | You wouldn't believe how many adolescents that I've got interested in functional programming so far. |
| 14:02 | durka42 | really |
| 14:03 | durka42 | that seems like a difficult task |
| 14:03 | eee | they are teaching scheme to kids at brown |
| 14:03 | eee | as a community project |
| 14:10 | __mac | Define community project |
| 14:11 | __mac | I'm from sweden, I'm stupid with regards to english and american culture sometimes... |
| 14:12 | __mac | Is that like something the student's take part in if they want to but the teachers are doing the teaching? |
| 14:16 | eee | well i was being vague so as not to misspeak |
| 14:17 | eee | but I believe it is for kids in cities that may not get the same chances as others |
| 14:17 | eee | so it wasn't for the students going to college at brown |
| 14:17 | eee | and what I meant was that it wasn't "for profit" |
| 14:18 | __mac | Ah I see |
| 14:18 | eee | at any rate, it turns out, the kids enjoyed it a lot and got to the point where they were inspired to learn more math |
| 14:18 | __mac | cool |
| 14:18 | eee | one thesis being that functional programming encourages learning more math |
| 14:19 | __mac | Yeah I can beleive that, pure functions and all that sure feels closer to math than imperative programming |
| 14:19 | __mac | So if you like functional programming, maybe you figure that math isn't that hard/bad after all |
| 14:22 | __mac | What about the students at Brown then? They study any lisp? I think we got maybe 2 universities in Sweden that teach any lisp at all. I just got a lot of C, C++ and later Java in uni and when I started learing lisp I felt I got a little cheated back in school |
| 14:22 | __mac | There is this whole world of programming we were never told about |
| 14:23 | eee | they are stating freshman with scheme now |
| 14:23 | eee | intro course to programming |
| 14:23 | eee | and the students will have their own android phone |
| 14:23 | eee | and learn to write apps in some DrScheme dialect |
| 14:23 | eee | written for android |
| 14:23 | eee | like MobyScheme or something |
| 14:24 | eee | i'm signin' off for now. nice shattin |
| 14:24 | eee | chattin |
| 14:24 | eee | i mean |
| 14:24 | eee | lol |
| 15:29 | cads_ | hey, I need some help with my clojure classpath, and getting cloggle to work |
| 15:29 | cads_ | cloggle's on my classpath, but when I try to load it it says that it can't find some java lib |
| 15:30 | durka42 | which java lib? |
| 15:30 | cads_ | it throws "ClassNotFoundException: javax.media.opengl.GLCanva" |
| 15:30 | durka42 | that looks like a typo |
| 15:32 | durka42 | Canva => Canvas |
| 15:32 | dnolen | cads_: are you using slime? and did you already install JOGL? |
| 15:32 | lisppaste8 | cads pasted "clojure error" at http://paste.lisp.org/display/79992 |
| 15:33 | cads_ | I've installed libjogl-java through apt |
| 15:33 | dnolen | but what environment are yo using, vimclojure, slime, netbeans? |
| 15:34 | cads_ | just the shell |
| 15:34 | cads_ | the first part is my classpath string |
| 15:34 | cads_ | which probably doesn't need to be so long |
| 15:34 | dnolen | you need to tell java where the OS specific dynamic library is, not just the jars. |
| 15:35 | dnolen | on Linux they are the .so files |
| 15:36 | dnolen | -Djava.library.path= your library path |
| 15:36 | cads_ | hmm |
| 15:36 | dnolen | needs to be passed to java when you start the REPL |
| 15:36 | dnolen | in addition to setting the classpath to the jars. |
| 15:37 | cads_ | let me find the so files |
| 15:37 | cads_ | that doesn't seem right, there are no .so files |
| 15:37 | dnolen | are you on Linux? |
| 15:38 | cads_ | yes |
| 15:38 | dnolen | then there are most definitely .so files. |
| 15:38 | dnolen | libjogl.so |
| 15:38 | dnolen | libjogl_*.so |
| 15:38 | dnolen | and |
| 15:38 | dnolen | libgluegen-rt.so |
| 15:39 | cads_ | the jogl package is essentially /usr/share/java/jogl.jar and libgluegen, and some documentation, but no so.. does it get generated somewhere outside the package? |
| 15:39 | cads_ | Im in ubunt :D |
| 15:40 | dnolen | look in |
| 15:40 | dnolen | do you have a |
| 15:40 | dnolen | directory? |
| 15:40 | dnolen | sorry |
| 15:40 | dnolen | /usr/lib/java |
| 15:40 | dnolen | ? |
| 15:40 | durka42 | http://packages.ubuntu.com/jaunty/all/libjogl-java/filelist |
| 15:41 | durka42 | he's right there are no .so's in that package |
| 15:41 | durka42 | ah but ti depends on libjogl-jni http://packages.ubuntu.com/jaunty/i386/libjogl-jni/filelist |
| 15:42 | durka42 | which puts them in /usr/lib/jni |
| 15:42 | dnolen | there you go. |
| 15:43 | dnolen | anyways, you need to pass that path to the REPL via the -Djava.library.path flag |
| 15:45 | cads_ | aah |
| 16:44 | cads | I'm trying to use this to run the cloggle example: java -Djava.library.path /usr/lib/jni/*.so -cp /usr/share/java/jogl.jar:$CLJ/clojure/clojure.jar:$CLJ/clojure-contrib/clojure-contrib.jar:$CLJ/ns clojure.lang.Script $CLJ/ns/cloggle/examples/gears.clj |
| 16:45 | hiredman | that will not work |
| 16:45 | hiredman | /usr/lib/jni/*.so will expand into a space delimited list of libraries |
| 16:46 | hiredman | which I doubt java is looking for |
| 16:46 | dnolen | -Djava.library.path /usr/lib/jni should be sufficient. |
| 16:51 | cads | I don't get it, it acts as if that flag is supposed to be giving it classes instead of .so files |
| 16:51 | hiredman | ... |
| 16:51 | hiredman | 13:45 hiredman : /usr/lib/jni/*.so will expand into a space delimited list of libraries |
| 16:51 | hiredman | 13:45 hiredman : which I doubt java is looking for |
| 16:52 | durka42 | i think the JVM recurses down java.library.path looking for stuff |
| 16:52 | durka42 | if you want to give it a list you will need to delimit with colons |
| 16:54 | cads | http://pastie.org/473915 |
| 16:54 | durka42 | -Djava.library.path=/usr/lib/jni |
| 16:55 | hiredman | cads: pay attention to what I am saying |
| 16:55 | hiredman | I just told you what is happening |
| 16:55 | hiredman | twice |
| 16:56 | durka42 | hiredman: no that wasn't the problem |
| 16:57 | hiredman | durka42: it obviously is |
| 16:57 | hiredman | oh |
| 16:57 | hiredman | actually you are missing a = |
| 16:57 | hiredman | :P |
| 16:57 | cads | d'oh |
| 16:58 | dnolen | sorry probably my fault :) |
| 17:02 | cads | awesome |
| 17:02 | cads | http://pastie.org/473927 |
| 17:02 | cads | now we're only missing something in the namespace :) |
| 17:02 | dnolen | i talked about this on the list |
| 17:02 | dnolen | his library is not structured properly |
| 17:02 | dnolen | you need to create the folders to match his ns |
| 17:02 | cads | oh no! |
| 17:02 | cads | oh, well.. |
| 17:02 | cads | that's not too bad |
| 17:13 | cads | I created the directory structure and it's no longer complaining about not finding the clj file, but now it throws Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/gluegen/runtime/DynamicLookupHelper (gears.clj:0) |
| 17:13 | cads | http://rafb.net/p/M25lKP42.html |
| 17:14 | dnolen | typo |
| 17:14 | dnolen | ]/usr/share/jave/gluegen-rt.jar |
| 17:14 | dnolen | java not javve |
| 17:14 | dnolen | jave :) |
| 18:02 | thearthur | is #enclojure the best place to ask about the netbeans clojure plugin? |
| 18:20 | unlink1 | What's the best way to transform a sequence into ((0 <first element>) (1 <second element>) (2 ...) ...) ? |
| 18:20 | unlink1 | i.e. am I missing some builtin for this? |
| 18:21 | dnolen | clojure.contrib.seq-utils has an indexed |
| 18:21 | dnolen | ,(indexed "test") |
| 18:21 | clojurebot | java.lang.Exception: Unable to resolve symbol: indexed in this context |
| 18:22 | AWizzArd | the clojurebot has not (use'ed ..) that |
| 18:22 | unlink1 | Ok, that's exactly what I wanted. Thanks. |
| 18:23 | unlink1 | Seemed silly to do that by hand. |
| 18:24 | unlink1 | I should really just grep on the clojure-contrib source more. |
| 19:06 | unlink1 | I have (ns ... (:gen-class)), (defn -main [] ...), and classes/my_ns$_main__23.class, but I'm still getting "Could not find the main class". |
| 19:09 | cmvkk | i think you have to recognize the fact that there's a main function in the :gen-class form somewhow |
| 19:09 | cmvkk | actually, on second glance maybe that's not the case. |
| 20:04 | bradford | any masters of the way of the monad on? |
| 20:05 | bradford | I want to make a monad around this: (defn mean-state |
| 20:05 | bradford | ([x val queue] [(/ (- (+ val x) (peek queue)) (count queue)) (conj (pop queue) x)]) |
| 20:05 | bradford | ([x] [x (conj clojure.lang.PersistentQueue/EMPTY x)])) |
| 20:06 | bradford | it is a stateful statistic, such as a rolling mean of the last 100 values |
| 20:19 | unlink | I'm running into a stateful parsing problem too. |
| 20:21 | unlink | How would you write a function parse-lines such that: http://dpaste.com/42824/ |
| 20:25 | durka42 | hmm is there even a lazy string split |
| 20:52 | durka42 | unlink: you hooked me :) almost got something |
| 20:54 | durka42 | Clojure=> (parse-lines "positive\n3\n2\n6\nnegative\n1\npositive\n8\n4\n5\nnegative\n12\n5\n9") |
| 20:54 | durka42 | (3 2 6 -1 8 4 5 -12 -5 -9) |
| 20:56 | unlink | hmm |
| 20:58 | durka42 | i started by writing lazy-split |
| 20:59 | durka42 | wrapped in lazy-seq, it looks for the delimiter, and returns (list s) if it's not there, and (cons string-up-to-delimiter (lazy-split rest-of-the-string delim)) if it is |
| 21:02 | unlink | What are you lazily splitting on? |
| 21:10 | durka42 | \newline |
| 21:10 | durka42 | sorry, i walked away |
| 21:10 | durka42 | (.indexOf s (int \newline)) |
| 21:11 | durka42 | <rant>why in the world does String.indexOf take an INTEGER?</rang> |
| 21:12 | unlink | durka42: I was trying to write a state-machine parser |
| 21:13 | unlink | durka42: Then I realized my states actually simply repeat in a clojure.core/cycle |
| 21:14 | durka42 | parsing the string or a list of lines? |
| 21:14 | unlink | list of lines |
| 21:23 | durka42 | so the states are positive and negative |
| 21:23 | durka42 | encountering the opposite word switches the state |
| 21:25 | durka42 | unlink: my version sort of has a state machine, i suppose - apply-signs just does a condp, and calls itself with the current sign |
| 21:27 | unlink | oh |
| 21:27 | unlink | can you paste it? |
| 21:28 | durka42 | yeah hold on |
| 21:30 | lisppaste8 | durka42 pasted "parse-lines" at http://paste.lisp.org/display/80001 |
| 22:41 | unlink | durka42: here was my solution to a related problem: http://dpaste.com/42845/ |
| 22:44 | unlink | I just learned how to use condp, you don't actually need the first "line" before the second let |
| 22:44 | unlink | So anyway I consider that horribly gross. |
| 22:45 | unlink | Indexing into the lines? recur 4 times? ugh... |
| 22:49 | eee | ~log |
| 22:49 | clojurebot | logs is http://clojure-log.n01se.net/ |
| 23:21 | unlink | durka42: I've produced a somewhat less horrific version of the same |
| 23:21 | durka42 | :) |
| 23:22 | unlink1 | http://dpaste.com/42853/ |
| 23:25 | unlink1 | I wonder if there's some way I could write that with reduce |
| 23:27 | Chouser | seems likely |
| 23:27 | durka42 | it seems like you'd need to reduce tuples |
| 23:27 | durka42 | of an accumulator and a state |
| 23:28 | unlink1 | right |
| 23:28 | durka42 | this is starting to sound like a monad :) |
| 23:28 | unlink1 | haha |
| 23:28 | unlink1 | yes |
| 23:29 | unlink1 | ooh, I like destructuring seqs with [x & xs] |
| 23:29 | durka42 | or you could use a closed-over atom or something |
| 23:32 | lisppaste8 | Chouser pasted "unlink1's fold-lines, with reduce" at http://paste.lisp.org/display/80007 |
| 23:33 | unlink1 | dammit, I shouldn't have clicked |
| 23:33 | Chouser | sorry, I almost warned you |
| 23:33 | Chouser | but I figured if you didn't want to see it, you wouldn't click. :-/ |
| 23:33 | unlink1 | or rather, once clicking, I shouldn't have studied your solution ;) |
| 23:34 | Chouser | It's like algebra. kind of relaxing. |
| 23:34 | Chouser | I don't even know what you're doing, or trying to do. |
| 23:35 | lisppaste8 | unlink1 annotated #80007 "final contribution before bedtime" at http://paste.lisp.org/display/80007#1 |
| 23:36 | unlink1 | Chouser: actually this is a reduced version of the larger problem |
| 23:36 | unlink1 | but the larger problem essentially composes into this one |
| 23:37 | Chouser | if you add a loop in there, then you wouldn't have to pass f around all the time. |
| 23:37 | Chouser | matter of taste, I suppose. |
| 23:37 | unlink1 | that's true |
| 23:38 | unlink1 | but in this case I find the loop to be a little noisy |
| 23:38 | Chouser | sure |
| 23:38 | unlink1 | in principle I agree |
| 23:40 | Chouser | fwiw, recur allows for the possibility of primitives, while reduce does not. Dunno if that's likely to matter in a case like this. |
| 23:55 | cads | chouser, I have a real bad bad desire to change the clojure convention to match the classical mathematical convention in the case of sets, where I really want to see {& elems} for a set rather than #{& elems}. Can I switch them out in my personal code? |
| 23:56 | cads | will I have to dive into the clojure implementation? |
| 23:56 | cmvkk | you want to change the set literal syntax from #{} to {}? |
| 23:57 | cads | yeah, but only in my personal files, it should still read normal clojure code |
| 23:57 | cmvkk | unfortunately reader syntax is inaccessable from clojure itself. |
| 23:57 | cmvkk | you'd have to change java code to make that happen. plus, what would you make map syntax be? |
| 23:58 | cmvkk | since {:a 1 :b 2} is currently a map. |
| 23:58 | clojurebot | map is *LAZY* |
| 23:58 | cads | should I awk it? |
| 23:58 | cmvkk | what do you mean? |
| 23:58 | cmvkk | to find where that code is? it's in Reader.java i'm pretty sure. |
| 23:59 | cmvkk | or to change your own source code? |