2008-12-20
| 09:14 | poiuyt | is there no way to abort a functon without killing the jvm? its incredibly annoying |
| 09:15 | Chouser | you may be able to use Thread/interrupt to stop the thread that's running the function. |
| 09:15 | Chouser | of course if that's the Repl thread it's not a terribly useful technique |
| 09:16 | Chouser | if the function is busy printing, you can limit it with *print-length* |
| 09:18 | Chouser | s/can limit/could have limited/ |
| 09:25 | poiuyt | how do I just kill the function without closing the window? |
| 09:25 | poiuyt | if i do C-x k the windows holding the thread is destroyed, not just aborting the jvm |
| 09:25 | Chouser | sorry, I don't use emacs or slime. |
| 09:26 | Chouser | many others do, but perhaps they're not here this morning. |
| 09:26 | poiuyt | VIM!!!??? |
| 09:27 | Chouser | yes |
| 09:27 | poiuyt | ill find out where you live |
| 09:29 | leafw | er, don't you mess around with vim'ers. |
| 09:48 | poiuyt | clojure-load-file: Symbol's value as variable is void: f |
| 09:48 | poiuyt | emacs ^^ |
| 09:48 | poiuyt | why? |
| 10:03 | poiuyt | got it |
| 10:28 | poiuyt | is there a group or group-by like function in clojure already? |
| 10:28 | poiuyt | (group-by ["h" "j" "h"] 0) -> [["h" "h"] ["j"]] |
| 10:28 | kotarak | (doc partition) |
| 10:28 | clojurebot | Returns a lazy sequence of lists of n items each, at offsets step apart. If step is not supplied, defaults to n, i.e. the partitions do not overlap.; arglists ([n coll] [n step coll]) |
| 10:29 | kotarak | However it does cut off parts. |
| 10:29 | poiuyt | not what i asked for |
| 10:29 | kotarak | (partition 2 [1 2 3 4 5]) => ((1 2) (3 4)) |
| 10:30 | kotarak | What is your function supposed to do? I'm not sure I understand the 0) |
| 10:31 | poiuyt | it groups stuff |
| 10:32 | poiuyt | user=> (group-by [[1 2 3] [1 2 3] [4 2 6] [1 2 3]] 0) |
| 10:32 | poiuyt | [[[1 2 3] [1 2 3] [1 2 3]] [[4 2 6]]] |
| 10:32 | poiuyt | user=> (group-by [[1 2 3] [1 2 3] [4 2 6] [1 2 3]] 1) |
| 10:32 | poiuyt | [[[1 2 3] [1 2 3] [4 2 6] [1 2 3]]] |
| 10:33 | poiuyt | user/group-by |
| 10:33 | poiuyt | ([coll on-elem]) |
| 10:33 | kotarak | Hmmm... Not that I am aware of. |
| 10:34 | poiuyt | Group a collection of items comparing on the on-elem element |
| 10:34 | Chouser | clojure.contrib.group-by |
| 10:34 | Chouser | clojure.contrib.seq-utils/group-by |
| 10:35 | Chouser | that takes a predicate and returns a map, but should get you close |
| 11:08 | dcnstrct | hey is clojurebot written in clojure ? |
| 11:08 | dcnstrct | clojurebot, give me source |
| 11:15 | Chouser | he is |
| 11:15 | Chouser | clojurebot: where are you? |
| 11:15 | clojurebot | http://gist.github.com/27733 |
| 11:16 | durka | kotarak: would you be interested in a trace of gorilla freezing? |
| 11:16 | kotarak | Sure. did you find something? |
| 11:16 | durka | unclear |
| 11:16 | kotarak | (I had a look, yesterday, but was too sleepy) |
| 11:18 | lisppaste8 | durka pasted "gorilla freeze" at http://paste.lisp.org/display/72449 |
| 11:18 | durka | ---ALL CAPS denote what I did in Vim |
| 11:20 | kotarak | How do I get such a nice trace? (Have no clue about java and its tools so far.) |
| 11:21 | Chouser | that's got to be a clojure-aware trace |
| 11:23 | kotarak | Yes. There is no prompt sent. As I suspected. |
| 11:23 | kotarak | I'll have a look, why this is the case. |
| 11:23 | durka | i didn't know if the proposed clojure.contrib.trace2 ever got into contrib |
| 11:23 | durka | but i just took the code from here |
| 11:24 | durka | http://groups.google.com/group/clojure/browse_thread/thread/b70cf422ab268cbd |
| 11:24 | durka | and I did a (trace-ns) in gorilla.clj and gorilla/repl-ln.clj |
| 11:24 | kotarak | This will definitively go to my toolbox. That's really nice. |
| 11:25 | kotarak | Concerning debugging I'm still on stone-age here. |
| 11:28 | kotarak | I'm really a bit puzzled. There is no code which checks for a ( or ). |
| 11:28 | kotarak | I don't know, why eg. *out* is treated differently. |
| 11:30 | leafw | a profiler would be nice too: count the time spent on each function, and keep track of the parent chain of function calls. |
| 11:34 | kotarak | Hmmm... It seems, that the repl doesn't read the trailing null byte. |
| 11:34 | kotarak | But I don't know, why. |
| 11:34 | durka | seems like the bug is triggered when the input doesn't end with a ) |
| 11:34 | durka | () is fine |
| 11:34 | kotarak | Yes. |
| 11:34 | durka | "() nonsense" hangs |
| 11:34 | durka | "nonsense ()" does not hang |
| 11:37 | kotarak | ) is not treated specially... |
| 11:55 | kotarak | Now it gets funny. |
| 11:55 | kotarak | I extract the command and add a 0x0. |
| 11:55 | kotarak | (+ 1 1) |
| 11:55 | clojurebot | 2 |
| 11:55 | kotarak | works |
| 11:55 | kotarak | *out* does not work. |
| 11:56 | kotarak | doing cmd + " " + 0x0.chr instead of simply cmd + 0x0.chr. |
| 11:56 | kotarak | fixes the problem. |
| 11:56 | kotarak | I don't get it. |
| 11:57 | kotarak | durka: thanks for the trace. Will push a fix to the bitbucket repo. |
| 12:26 | poiuyt | how do I nest loop-recurs? |
| 12:27 | kotarak | poiuyt: recur always goes to the inner-most loop |
| 12:27 | kotarak | or function |
| 12:30 | poiuyt | so how do I jump back? |
| 12:33 | kotarak | Just don't call recur: (loop [x 0] (cond condition1 (recur 1) condition2 (recur (loop [y 0] (if inner-condition (recur 1) 2 (<-leaves inner loop)))) condition3 3 (<- leaves outer-loop))) |
| 12:34 | kotarak | poiuyt: maybe you can translate the loops in map, reduce and friends. |
| 12:48 | poiuyt | well this was something very simple getting ridic hard lol |
| 12:49 | poiuyt | I have a list of lists. for each elem in the inner list i want to do something with a sideeffect and then conj that to a function-global vector and then return the vector once everyhting is done |
| 12:49 | durka | kotarak: fix confirmed, thanks |
| 12:49 | kotarak | durka: np, though I still don't understand, why this is a fix... |
| 12:50 | durka | yeah, i know no ruby at all so i can't really speculate there |
| 12:50 | kotarak | durka: I'm not sure, that the problem lies in Ruby... But as long as it works for now... |
| 12:51 | kotarak | poiuyt: Can you paste an example? I don't under stand the side effect thing, I don't understand what you want to conj to the vector. The original thing? |
| 12:52 | durka | kotarak: gorilla still doesn't setup its maps unless I put a "ruby Gorilla.setup_maps()" at the bottom of gorilla.vim |
| 12:52 | poiuyt | http://hpaste.org/13212 |
| 12:52 | poiuyt | that should return a vector of 2 matrices |
| 12:52 | kotarak | durka: Have you put in place the after/... file? |
| 12:53 | poiuyt | it is a simplified version of what im doing but illustrates the problem |
| 12:53 | durka | the ftplugin? |
| 12:56 | kotarak | durka: yes |
| 12:58 | lisppaste8 | kotarak pasted "maybe with map?" at http://paste.lisp.org/display/72450 |
| 12:59 | kotarak | durka: and of course you must be in a clojure buffer. |
| 12:59 | kotarak | poiuyt: maybe like this? |
| 12:59 | durka | oh that would be it |
| 13:00 | kotarak | durka: in other buffers, it doesn't make sense to capture the keymaps. |
| 13:02 | durka | even when i open a .clj file it doesn't seem to work |
| 13:02 | durka | gorilla.vim is in ~/.vim/ftplugin/clojure/gorilla.vim |
| 13:03 | kotarak | durka: ehm. which? the one from after/ftplugin...? |
| 13:03 | durka | yes |
| 13:03 | kotarak | hmmm |
| 13:03 | durka | is macvim weird about these things? |
| 13:04 | kotarak | no. works for me. |
| 13:04 | kotarak | You have activated ftplugins? |
| 13:04 | durka | well the syntax highlighting works |
| 13:04 | durka | sorry, i'm really a vim newbie |
| 13:05 | kotarak | try ":filetype plugin indent on" |
| 13:05 | kotarak | Put this in your .vimrc. |
| 13:12 | kotarak | hi wizz |
| 13:35 | poiuyt | kotarak: i did (reduce (reduce...)) dont know what i was thinking before |
| 13:39 | poiuyt | if im nesting to #()-closures/functions/whatever ina reducea nd i need to refer to the outer %2 in the inner then i cant use #( in both? i solvced wioth using (fn [acc elem]... and #( %1 %2 so no prob, just wondering |
| 13:39 | kotarak | poiuyt: I sometimes stare to hours at a loop and then *poo*f* it vanishes into a reduce with take-while and is 2/3 shorter. |
| 13:40 | kotarak | #() cannot nest. You have to use fn, then |
| 13:40 | kotarak | #() is only short-cut for very simple fns |
| 13:40 | kotarak | Not a replacement for fn |
| 13:56 | poiuyt | ok ty |
| 14:04 | fffej | quick question - is there a Clojure defined function for absolute or is (Math/abs x) the way to go? |
| 14:06 | danlarkin | fffej: Math/abs |
| 14:09 | fffej | thanks, is the guidance basically that if it's available in core Java as a simple static func, there probably isn't a Clojure equivalent? |
| 14:10 | danlarkin | fffej: you can always consult http://clojure.org/api |
| 14:11 | poiuyt | how do I contribute to contrib? |
| 14:11 | poiuyt | and how do I do if I want to suggest functions for clojure-core? |
| 14:15 | danlarkin | poiuyt: http://clojure.org/contributing |
| 14:16 | poiuyt | clojurebot contributing |
| 14:17 | danlarkin | clojurebot: contributing? |
| 14:17 | clojurebot | No entiendo |
| 14:17 | danlarkin | clojurebot: contributing is <reply> http://clojure.org/contributing |
| 14:17 | clojurebot | Roger. |
| 14:20 | poiuyt | ok i think if i do something ill just host it on github then and people can pull from there |
| 14:20 | fffej | i'm just trying to understand recur by implementing my own version of "range", but it's overflowing the stack. |
| 14:20 | poiuyt | ffej: post |
| 14:20 | poiuyt | clojurebot: paste? |
| 14:20 | clojurebot | Pardon? |
| 14:20 | poiuyt | clojurebot: paste |
| 14:20 | clojurebot | excusez-moi |
| 14:20 | fffej | post: |
| 14:20 | fffej | (defn my-range [start end] |
| 14:20 | fffej | ((fn [x y accum] |
| 14:20 | fffej | (if (= x y) |
| 14:20 | fffej | (concat accum (list x)) |
| 14:20 | kotarak | poiuyt: you should probably discuss your contribution on the google groups list |
| 14:20 | fffej | (recur (inc x) y (concat accum (list x))))) start end nil)) |
| 14:21 | poiuyt | ffej: you can use recur without loop but often oyu use loop. ill copy it and try it |
| 14:21 | kotarak | fffej: http://paste.lisp.org/new/clojure |
| 14:21 | fffej | thanks kotarak, will use that from now on |
| 14:22 | fffej | (range 1 50000) works whereas my one gives a stack overflow |
| 14:23 | lisppaste8 | py pasted "range" at http://paste.lisp.org/display/72451 |
| 14:24 | poiuyt | you are doing some unneccessasry stuff |
| 14:24 | poiuyt | i posted another version ^^ |
| 14:25 | fffej | poiuyt: thanks, conj was the bit I was missing |
| 14:26 | fffej | I'm a bit confused why change from (concat accum (list x)) to (conj accum x) fixes the stack overflow though? What am I missing? |
| 14:26 | lisppaste8 | kotarak annotated #72451 with "my-range with lazy-cons" at http://paste.lisp.org/display/72451#1 |
| 14:28 | fffej | thanks kotarak |
| 14:28 | fffej | so far when I've been playing around I've avoided explicit recursion because of the lack of TCO. I'm guessing that when lazy-cons is used this doesn't apply and the tail call is only evaluated when it's needed? |
| 14:29 | kotarak | yes |
| 14:30 | fffej | thanks all, that's helped me understand a few things! |
| 14:33 | danlarkin | kotarak: lazy-cons is the best... it's faster _and_ more memory efficient |
| 14:34 | fffej | but more difficult to reason about complexity wise |
| 14:34 | cljnewb | hello. I have an object that implements java.util.Collection, Iterator, List, etc. how do I simply iterate over it and print its members? |
| 14:34 | kotarak | fffej: one must take care for side effects. |
| 14:34 | kotarak | eg. open files and such |
| 14:35 | kotarak | cljnewb: (doseq [x your-coll] (prn x)), not tested |
| 14:36 | danlarkin | or if you just wanna see it use (seq your-coll) |
| 14:38 | cljnewb | kotark & danlrkin: thanks. |
| 14:41 | poiuyt | and there is no problem with lazy-cons as far as blowing stack somehow? like in Haskell when not using foldr foldl' etc correctly it all works fine until you hit some cornercase and blow the stack and have to change it to use strictness instead |
| 14:41 | poiuyt | are lazy expressions building up large thunks that can blow the stack? |
| 14:42 | poiuyt | and when doing count on a lazy sequence does that take the same time as on a normal one? |
| 14:44 | kotarak | poiuyt: In general count on seq is O(n), since you don't know the length in advance (eg. line-seq). For collections (vectors, maps, sets, lists, ...) it's O(1). I'm not sure about a seq based on such a collection. |
| 14:46 | fffej | there's a good book about this "Purely Functional Data Structures". It talks about how to understand the performance of an algorithm when it's evaluated lazily |
| 14:49 | aperotte | I know this is relatively new, but does anyone know if there are plans for JVM support of the new OpenCL standard? |
| 14:50 | Kerris7 | fffej: I hope to "port" that book to Scala one day :V |
| 14:52 | poiuyt | count on lists are O(n) right? it seems so when timingat least |
| 14:52 | kotarak | poiuyt: O(1) |
| 14:52 | kotarak | hmmm |
| 14:52 | poiuyt | (time (count (range 1000000))) |
| 14:52 | poiuyt | "Elapsed time: 45.857505 msecs" |
| 14:52 | poiuyt | (time (count (range 1))) |
| 14:52 | poiuyt | "Elapsed time: 0.047772 msecs" |
| 14:52 | fffej | doesn't that tell you more about range? |
| 14:53 | poiuyt | lol |
| 14:53 | kotarak | poiuyt: yes. range is a lazy-seq. |
| 14:53 | kotarak | poiuyt: (list ....) are lists. |
| 14:54 | poiuyt | but still the same |
| 14:54 | poiuyt | user=> (time (count b)) |
| 14:54 | poiuyt | "Elapsed time: 0.196114 msecs" |
| 14:54 | poiuyt | 1 |
| 14:54 | poiuyt | user=> (time (count a)) |
| 14:54 | poiuyt | "Elapsed time: 45.200996 msecs" |
| 14:54 | poiuyt | ai i see |
| 14:54 | fffej | but range is lazily evaluated, so you need to force it first I guess |
| 14:54 | kotarak | http://clojure.org/data_structures#toc43 says "count is O(1)" |
| 14:55 | poiuyt | es when doing (apply list (range 10000)) |
| 14:55 | poiuyt | thne timing it is the same |
| 14:55 | poiuyt | also lazy-seq allows loooong lists where normal ones blows the heao |
| 14:55 | poiuyt | p |
| 14:57 | kotarak | Gorilla=> (def y (apply list (range 100000))) |
| 14:57 | kotarak | #'user/y |
| 14:57 | kotarak | Gorilla=> (time (count y)) |
| 14:57 | kotarak | "Elapsed time: 0.029 msecs" |
| 14:57 | kotarak | 100000 |
| 14:57 | kotarak | Gorilla=> (time (count (range 100000))) |
| 14:57 | kotarak | "Elapsed time: 9.055 msecs" |
| 14:57 | kotarak | 100000 |
| 14:58 | kotarak | Gorilla=> |
| 15:00 | poiuyt | yes as i noticed |
| 15:00 | poiuyt | anyway where can isee the implementation of # as the function-shorthand? |
| 15:01 | kotarak | poiuyt: don't know of hand the doc, but #(foo %) is shorthand for (fn [x] (foo x)) |
| 15:02 | kotarak | poiuyt: http://clojure.org/reader#toc2 |
| 15:11 | poiuyt | hmm does a macro always need parenthesis to be called? I always got the impression that macros was this "divine" thing that you could do superawesome stuff with but what I really like about clojure is that sit is so close to purely functional and immutable datstructures. macros i still have never needed one. |
| 15:11 | poiuyt | i cant do: (+ 2 q 3 add 5) -> 10? where q is a macro: (defmacro q [a b c] |
| 15:11 | poiuyt | `(~b ~a ~c)) |
| 15:11 | kotarak | macros are the "divine" thing you can do superawesome stuff with. ;) |
| 15:12 | kotarak | But they are also this super 100Mt atomic bomb, which blows your code of the water. |
| 15:12 | durka | is there a function that will "reset" clojure |
| 15:12 | arohner | poiuyt: macros are fns that are called at compile time |
| 15:12 | durka | like, if i managed to start some agents at the repl with infinite loops or memory leaks or something |
| 15:12 | arohner | that just happen to return lists |
| 15:12 | durka | and i want to terminate them all instead of cleaning up my mess |
| 15:13 | kotarak | poiuyt: (apply + 2 (q 3 add 5)) |
| 15:14 | kotarak | Arg. |
| 15:14 | poiuyt | arohner: yes they are functions but i thought od them more like: when some character or word is occured, replace that word with this. but having to use parenthesises greatly reduces the dsl-ishness of them |
| 15:14 | kotarak | Forget the apply |
| 15:16 | kotarak | poiuyt: what a lisp can do, is a DSL in lisp style. For more, you need an external DSL. |
| 15:28 | dreish | I check http://www.google.com/trends?q=clojure%2Cocaml&ctab=0&geo=all&date=ytd&sort=0 every day. When Clojure passes OCaml, confetti will appear out of nowhere at my house. |
| 15:30 | walters | not a fan of staring at type inference clashes? |
| 15:31 | dreish | No, nothing against OCaml specifically. It's just an easy-to-google language at a low enough popularity level to make it a reasonable one to measure Clojure against. |
| 15:32 | walters | ah |
| 15:34 | danlarkin | O'caml big in france eh |
| 15:34 | walters | it originated from INRIA |
| 15:37 | triddell | When I println a data structure I get from a java call is looks like: |
| 15:37 | triddell | (#=(java.util.ArrayList. [#=(java.util.HashMap. {id MachineStandards, title Standards, column 1, app-context machine, row 1, skin nil}) #=(java.util.HashMap. {id MachineInventory, title Inventory, column 2, app-context machine, row 1, skin nil})]) |
| 15:37 | triddell | nil nil) |
| 15:37 | triddell | (#=(java.util.ArrayList. [#=(java.util.HashMap. {id MachineStandards, title Standards, column 1, app-context machine, row 1, skin nil}) #=(java.util.HashMap. {id MachineInventory, title Inventory, column 2, app-context machine, row 1, skin nil})]) nil nil) |
| 15:38 | triddell | Is this a list with a vector containing two Hashmaps and two nils? |
| 15:39 | triddell | I'm try to get a sequence of Maps from this and can't seem to get it. |
| 15:39 | danlarkin | triddell: well those are java containers |
| 15:39 | triddell | right, just trying to read it properly |
| 15:39 | triddell | and then just get the maps as a sequence |
| 15:40 | dreish | (first (seq above-thing)) doesn't work? |
| 15:40 | dreish | Oops, I mean (seq (first ...)) |
| 15:40 | poiuyt | what is the preferred way to package clojure programs? should I always have each file in a separate namespace? |
| 15:42 | triddell | dreish (seq (first ... gets me: ((#<Entry id=MachineStandards> #<Entry title=Standards> #<Entry column=1> #<Entry app-context=machine> #<Entry row=1> #<Entry skin=null>) |
| 15:43 | triddell | which I don't think is a map any more |
| 15:43 | arohner | poiuyt: it's a good rule of thumb to use the (ns ... ) macro, |
| 15:43 | arohner | that pushes you in the direction of of file per ns |
| 15:43 | dreish | Oh, weird, first got you the first thing in the ArrayList (the HashMap) instead of the ArrayList itself. I wonder where the outer parens came from. |
| 15:43 | kotarak | poiuyt: ns do not correlate to files. you can use several files for one namespace. |
| 15:44 | dreish | It looks like you ought to be able to just do (seq above-thing). |
| 15:44 | danlarkin | triddell: so try (apply hash-map (seq (first above-thing))) |
| 15:54 | triddell | That seems to do it... now I have this: |
| 15:54 | triddell | ({#=(java.util.HashMap. {id MachineStandards, title Standards, column 1, app-context machine, row 1, skin nil}) #=(java.util.HashMap. {id MachineInventory, title Inventory, column 2, app-context machine, row 1, skin nil})} |
| 15:54 | triddell | nil nil) |
| 15:55 | triddell | combined... not sure why it's a list with two nils on the end but I'll see if I can use the first map, thanks |
| 16:07 | AWizzArd | clojurebot: max people |
| 16:07 | clojurebot | max people is 116 |
| 16:16 | poiuyt | i dont quite get how to use namespaces |
| 16:16 | poiuyt | (ns linear-algebra) |
| 16:16 | poiuyt | how should i then import it from another file? |
| 16:16 | poiuyt | and how do i refer to names from that namespace? |
| 16:17 | kotarak | (ns other.namespace (:require linear-algebra)) (linear-algebra/foo) |
| 16:18 | poiuyt | and do i do load-file first or how does it find the namespace? |
| 16:19 | kotarak | put (ns linear-algebra) ... in a file /linear_algebra.clj in your classpath. |
| 16:19 | kotarak | The rest does require. |
| 16:22 | hiredman | I think good form requires at least two segments in the ns |
| 16:22 | hiredman | poiuyt.linear-algebra |
| 16:44 | hiredman | clojurebot: ,(println "pong") |
| 16:44 | clojurebot | I don't understand. |
| 16:44 | hiredman | ,(println "pong") |
| 16:44 | clojurebot | pong |
| 16:45 | poiuyt | is there no way to prepend a macro? |
| 16:45 | poiuyt | like clojure doe salready |
| 16:45 | poiuyt | #(+ % 3) |
| 16:46 | hiredman | poiuyt: sounds like you are talking about read macros |
| 16:46 | poiuyt | so i can do |(2 + 3) instead of (+ 2 3) |
| 16:46 | kotarak | poiuyt: no. this is not possible. |
| 16:46 | hiredman | rhickey doesn't seem to want people to that |
| 16:46 | kotarak | the problem is, you can't resolve such reader macros. |
| 16:47 | kotarak | what happens, why I have to a |... macro? |
| 16:47 | kotarak | which to use? |
| 16:47 | hiredman | http://markmail.org/message/zp4minh63ewqsdtj |
| 16:53 | poiuyt | yeah well if theyare what they seem to be those are what i really need. normal macros i really never ever nee |
| 16:53 | poiuyt | d |
| 16:54 | kotarak | poiuyt: Funny. I never needed reader macros up to now. (Maybe with exception of #()) |
| 16:56 | hiredman | poiuyt: why not just use a normal macro? |
| 16:57 | hiredman | (| 3 + 2) |
| 16:57 | zakwilson | CLSQL does very useful things with reader macros. |
| 17:06 | poiuyt | yes exactly what i was thinking |
| 17:06 | poiuyt | i hate sql-statements ugly long. want to make a simple dsl for taking away allt he boilerplate from sql |
| 17:06 | poiuyt | it is jsut cleanrer having the macro-symbol outside the expr |
| 17:16 | Lau_of_DK | Good evening gents |
| 17:16 | kotarak | hi lau |
| 18:24 | mmcgrana | I know of assoc, assoc-in, and update-in, but there is no "update". e.g. (update {:wins 2 :losses 3} :losses inc) => {:wins 2 :losses 4} Is there a function for this with a different name? |
| 18:25 | kotarak | mmcgrana: you can use (update-in {...} [:losses] inc), but I also noted that this missed. |
| 18:25 | kotarak | Also get-in has no default value. |
| 18:25 | kotarak | Maybe we need some polish here? |
| 18:28 | mmcgrana | yeah i think so |
| 18:31 | drewr | I wonder if this is worthy of core: |
| 18:31 | drewr | (defn toggle [_atom] |
| 18:31 | drewr | (swap! _atom #(not %))) |
| 18:35 | lisppaste8 | mmcgrana pasted "update" at http://paste.lisp.org/display/72456 |
| 18:36 | mmcgrana | note that this is just the base case for update-in, thus we could replace that case in update-in with a call to update |
| 18:43 | kbarros | Hi folks, I have a question about the slime command M-. (i.e., slime-edit-definition). How is it supposed to work? |
| 18:44 | kbarros | If I change a file, should M-. use the updated information? |
| 18:50 | mmcgrana | i might work up a proper patch for the update thing, but gtg now |
| 19:22 | Lau_of_DK | Anyone up ? |
| 19:23 | Lau_of_DK | Ive got a simple job, convert (> one two) to "one > two". Is there anything built into Clojure which allows me to do this elegantly ? |
| 19:29 | Chouser | (defn f [[a b c]] (list b a c)) |
| 19:30 | RSchulz | Ha! That's exactly what I was going to ask... How general is the transformation you require? |
| 19:30 | RSchulz | Arbitrary infix -> prefix parsing? |
| 19:32 | hiredman | I seem to recall this in some cs class |
| 19:32 | RSchulz | That's good. Having taken CS classes is a good thing... |
| 19:33 | danlarkin | use interleave? |
| 19:33 | hiredman | at the time I did not have internet hat home so I wa busy goofing off on the laptop so I don't remember |
| 19:34 | danlarkin | sorry, I mean interpose |
| 19:34 | danlarkin | (doc interpose) |
| 19:34 | clojurebot | Returns a lazy seq of the elements of coll separated by sep; arglists ([sep coll]) |
| 19:34 | danlarkin | throw a wrapper around that IMO |
| 19:37 | RSchulz | Face it! Infix -> Prefix requires a parser. Trying to finesse it with things like (interpose ...) just don't cut it. |
| 19:37 | RSchulz | They're two different realms, and never the twain shall meet! |
| 19:44 | danlarkin | but this is prefix -> infix |
| 19:44 | danlarkin | much easier! |
| 19:47 | RSchulz | Yes. Magic is always easier... |
| 19:47 | RSchulz | Oh. Prefix TO Infix. Trivial.. |
| 19:48 | RSchulz | A slight complication ensues if you want minimal parenthesization of the resulting infix. |
| 19:50 | gnuvince_ | What's with all the infix talk lately? Do people really want to write 2 + 3 instead of (+ 2 3)? |
| 19:51 | danlarkin | 2nd place to infix |
| 19:51 | danlarkin | distant last place to posfix *shudder* |
| 19:52 | RSchulz | gnuvince_: Yes, people _do_ want to write that. |
| 19:52 | RSchulz | What can you do? |
| 19:52 | gnuvince_ | RSchulz: flame them until they don't want to? |
| 19:52 | RSchulz | Well... It's worth a try! |
| 19:52 | gnuvince_ | ;) |
| 19:53 | RSchulz | You want to write WHAT?!?! 2 + 3 * 4 = What? 14? 20? Say what you mean, dammit!! |
| 19:54 | gnuvince_ | I feel that not having infix maths in Lisp languages is less of a problem than these people think. The most common operations are increasing and decreasing values by one |
| 19:54 | gnuvince_ | I don't think a lot of people spend their days writing quadratic equations in their programs |
| 19:54 | RSchulz | "Syntactic sugar leads to cancer of the semicolon." -- Alan Perlis. |
| 19:55 | RSchulz | ...RIP... |
| 20:00 | gnuvince_ | This guy had some good quotes |
| 20:45 | hiredman | I have a seq of vectors, I would like to eliminate all the vectors with duplicate data in a certain slot |
| 20:52 | Chouser | hiredman: "certain slot" as known by its index? |
| 20:52 | hiredman | yeah |
| 20:52 | hiredman | woa |
| 20:52 | hiredman | http://clojure.org/sequences <-- changed |
| 20:53 | Chouser | indeed. what do you think? |
| 20:53 | hiredman | uh |
| 20:53 | hiredman | cuts down on duplication I guess |
| 20:53 | Chouser | biab |
| 20:54 | hiredman | the seq is registration data, but some people registered twice, with slightly different data |
| 20:59 | Chouser | oh, I see. |
| 21:03 | Chouser | (vals (reduce #(assoc % (nth %2 1) %2) {} theseq) |
| 21:07 | hiredman | thanks |
| 21:08 | hiredman | let me try and figure that out |
| 21:08 | hiredman | ok |
| 21:13 | hiredman | wonderful |
| 21:13 | Chouser | or (vals (into {} (for [v theseq] [(nth v 1) v]))) |
| 21:14 | Chouser | eh. nevermind. use 'reduce' |
| 21:16 | hiredman | works great |
| 21:17 | hiredman | you are a gentlemen and a scholar, and there are only four of us left |
| 21:28 | karmazilla | is there an API page for contrib? |
| 21:29 | Chouser | karmazilla: nope. |
| 21:30 | Chouser | karmazilla: but 'doc' and 'find-doc' work |
| 21:32 | karmazilla | yeah, but quite a substitute if overview is what you want. |
| 21:33 | Chouser | I agree -- contrib is under-documented. |
| 21:34 | karmazilla | what about test-is tutorials? |
| 21:38 | Chouser | test-clojure uses test-is a bunch |
| 21:40 | karmazilla | yeah, just remembered that as well |
| 21:55 | karmazilla | I think the test-that macro in clojure.contrib.test-clojure.evaluation looks like something that would be nice to have in test-is itself |
| 22:00 | dpthfltr | clojure + htmlunit FTW |
| 22:01 | dpthfltr | I was doing this kind of testing with Ruby before.. the clojure version looks much more concice even though htmlunit is more verbose than Ruby's WWW::Mechanize |
| 22:02 | dpthfltr | and the clojure version is somehow faster even though a whole extra browser engine is being loaded... weird |
| 22:03 | dpthfltr | Rick Hickey I kiss you |
| 22:03 | dpthfltr | ok that is all |
| 22:03 | dpthfltr | goodnitez |
| 23:20 | hiredman | clojurebot: ping? |
| 23:52 | lisppaste8 | jawolfe pasted "lazy concat?" at http://paste.lisp.org/display/72461 |
| 23:52 | jawolfe | Hi, what's the proper idiom for *truly* lazy concatenation ? |
| 23:53 | jawolfe | (in situations where lazy-cat is not applicable since the number of arguments is not known at compile-time) |
| 23:53 | jawolfe | As you can see in the above post, while it claims to be lazy, concat seems to get ahead of itself. |