Why not "sorted-set-by"?
Hi, all. I'm experimenting clojure. Some code, I needed something like "sorted-set-by", but no such thing. So i used "sorted-map-by" ignoring value part. Is it deliberate for some reason? Or just not there? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Why not sorted-set-by?
Hi all. I'm experimenting cljoure. some code, i needed something like "sorted-set-by". but, no such thing, so I emulated that using "sorted-map-by". Is it deliberate for some reason? or just not there? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Why not "sorted-set-by"?
Hi, all. I'm experimenting clojure. Some code, I needed something like "sorted-set-by", but no such thing. So i used "sorted-map-by" ignoring value part. Is it deliberate for some reason? Or just not there? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
I'm experimenting clojure - "sorted-set-by"?
Hi, all. I don't know why my previous posts ignored. spam filtering? so i changed title. I'm experimenting clojure. Some code, I needed something like "sorted-set-by", but no such thing. So i used "sorted-map-by" ignoring value part. Is it deliberate for some reason? Or just not there? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: Why not "sorted-set-by"?
Thank you, hoeck. Thank you Chouser, your code taught me about "proxy". When I saw the patch 1st time, I missed java parts. before I saw your code, I thought if I need that again then I could use the code without affecting core. (What a wrong conclusion ^^; ) ps. I was embarrassed when my 4 posts with 3 threads appeared. I didn't know about 1st posting moderation. (I think google group ui must notify about moderation, anyway that's another story.) So I was reluctant to post just thank you reply. Thank you Frantisek Sodomka, for reply on another thread. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Yet another trace library.
While searching usable trace libray in clojure, I found 3 pieces of codes. - Stuart Sierra's clojure.contrib.trace - Rich Hickey's posting http://groups.google.com/group/clojure/browse_thread/thread/fd315d9dfdb8c32c/7479682cdf3a1b97?lnk=gst&q=trace#7479682cdf3a1b97 - Craig McDaniel's trace2.clj http://groups.google.com/group/clojure/browse_thread/thread/3ea8777880231e18/6fd1b352ac1a6744?lnk=gst&q=trace#6fd1b352ac1a6744 1st can be used to trace any expression. but it's not for general function tracing. 2nd version works well. 3rd version provide trace-ns, untrace-ns. but no indentation on trace output. So I combined indented output part of the 2nd codes to the 3rd codes. And provided some control vars on output contents. http://groups.google.com/group/clojure/web/trace_fn.clj Any comment? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Are there ways to propagate bindings to child threads?
Hi, all. Story: I couldn't understand my "binding" form behavior. (binding [*print-level* 2 *print-length* 2] (some-function)) but, some outputs didn't confirm the bound value. After some investigation on my code and output, I found the reason. - I used pmap Well, I can use "set!", but I think that's not a solution. I could "set!" *print-level* and *print-length. But I couldn't "set!" other defs defined in other ns. (I guess that's not intended use of "set!". right?) And think about something like *out*. I don't know that's intended behavior of "binding" or not. Anyway I think something like thread-propagate-binding is needed. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
"(binding ...)" form and "pmap" (was: Are there ways to propagate bindings to child threads?)
I wrote a question, but I think my point was not clear. I wanted some trace output of my codes, but my code uses heavily liked structure. After I found out there are vars that controls output, I tried that. Let's consider below codes. (I made runnable example.) (The main differenece from real code and example is that - printing of args/returns done by "trace" library, not by the 'pmaped' function itself) - Not much relation to lazy things. - Not much relation to closure. ;; BEGIN --- ;; this is *EXAMPLE* codes. ;; So don't ask things like why pass a range instead of a number. (defn pmaped [r] (println "pmaped - called with - " r) ;; think as trace output (Thread/sleep (rand 200)) (let [ret (reduce + r)] (println "pmaped returns - " ret) ret)) (defn some-fn ([] (some-fn 100)) ([n] (let [square (fn [x] (* x x)) rs (map range (range n))] (reduce + (pmap pmaped rs) ;; END - ; Consider this (binding [*print-length* 2] (some-fn 10)) ; Some time needed to figure out why above code does not work as I expected. ; That's because I used pmap. ; Environment of threads created(or picked in pool) by pmap do not keep that of caller. ; But am I wrong to expect pmap to behave similar to map? ; Yes I expect order of side effects differs, but not the effects itself. ;; My (non-)solution - (binding [*print-length* 2 pmap map] ;; ^^ (some-fn 10)) ;; But how about this? (borrowed from another group thread.) (use 'clojure.contrib.duck-streams) (defmacro with-out-as [f & body] `(with-open [w# (writer ~f)] (binding [*out* w#] ~...@body))) (with-out-as "/tmp/trace.out" (some-fn 10)) ; That means if I can use macros like above, ; I have to be sure all called functions do not use multi-threading facilities, ; which is not practical. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: bug in clojure.contrib.math/exact-integer-sqrt
Thank you! And sorry, I made serious typo in last question. I had to write "private" instead of "public". (I want to pull my hairs.) I'm not sure, I think there might be cases the error part not needed. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Re: bug in clojure.contrib.math/exact-integer-sqrt
I know I can ignore leftover part, but my concern is that exact- integer-sqrt will calculate leftover if needed or not. Why not 2 public functions? like mzscheme's "integer-sqrt" and "integer-sqrt/remainder" On Mar 30, 9:16 am, Mark Engelberg wrote: > If you don't care about the "leftover" portion that exact-integer-sqrt > returns, you can do something like: > (let [[floor-sqrt _] (exact-integer-sqrt n)] ...) > or (first (exact-integer-sqrt n)) > > so I didn't want to expose another function which returns only half of > the information that this one does. > > On Sun, Mar 29, 2009 at 4:34 PM, hjlee wrote: > > I'm not sure, I think there might be cases the error part not needed. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---
Suggestion - change doc string of "rand-int"
Hi. (doc rand-int) says "([n]) Returns a random integer between 0 (inclusive) and n (exclusive)." I think the word "integer" may cause some confusion, because it can be interpreted as clojure integer - including int, long and BigInteger. But the reality is with long or BigInteger n, rand-int does not work properly. How about changing doc string to clarify effective range of n? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en -~--~~~~--~~--~--~---