Re: Joy of Clojure example not working

2021-08-14 Thread Chouser
In this case, I think the git repo has correct code where the book does not; "clang" instead of "gcc": (defmethod compile-cmd [::osx "gcc"] [m] (str "/usr/bin/" (get m

Re: PSA: A slight tweak to "concat"

2019-07-08 Thread Chouser
I see I introduced the bug while adding support for chunked seqs to concat. I'm grateful someone has found and fixed my mistake. Thanks, Alex! —Chouser On Sat, Jul 6, 2019 at 7:57 AM Matching Socks wrote: > > There's activity on a ticket in Jira to fix a quirk of "concat&q

Re: order of returned values from keys and vals

2014-02-01 Thread Chouser
y robust in relation to each other for other sizes of smallish maps. --Chouser On Sat, Feb 1, 2014 at 10:35 PM, Justin Smith wrote: > Realistically, how many situations are there where running keys and vals > independently is preferable to running seq once and using the two element > vec

Re: infinite loop print out of cyclic structure at repl

2013-10-01 Thread Chouser
Bah, mutable state! To be cursed in all its forms! Here is the same content as was at that paste.lisp.org link. I haven't tested it with recent versions of Clojure or anything: https://gist.github.com/Chouser/6783292 --Chouser On Tue, Oct 1, 2013 at 12:44 PM, Patrik Sundberg wrote: &

Re: Natively Compiled Clojure

2013-01-21 Thread Chouser
Google > > Groups "Clojure" group. > > To post to this group, send email to clojure@googlegroups.com > > Note that posts from new members are moderated - please be patient with > your > > first post. > > To unsubscribe from this group, send email to &g

Call for Presentations: Commercial Users of Functional Programming 2012

2012-02-24 Thread Chouser
The 2012 CUFP call for presentations is out: http://cufp.org/cufp-2012-call-presentations The program committee is hoping for better representation from the Clojure community this year, so if you've got something interesting to say about Clojure, please submit a proposal! --Chouser --

Re: Empty list type

2011-11-01 Thread Chouser
something for which seq?, list?, coll?, and sequential? will return true, and that () and (list) will return something for which empty? will return true. --Chouser -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send ema

Re: Idiomatic record construction in 1.3

2011-10-26 Thread Chouser
literal vectors and maps, eval would have to know how to handle each record type, find the forms contained in the values, evaluate them, and build a new record with the results. Off the top of my head I don't see why this would be impossible, but it may not be desirable. --Chouser -- You

Re: Tail Recursion In Erjang

2011-10-21 Thread Chouser
call that could be either of two things (a loop/recur or a trampoline site) simple or complected? --Chouser -- 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 Note that posts from new

Re: Clojure 1.3 "wonky" behavior

2011-10-20 Thread Chouser
anded the Var existed but had minimal metadata. This was after the declare was compiled but before any part of the 'vector' form was run. There is no :dynamic flag, and anything that depends on that flag at compile time to work correctly (such as a function that refers the for Var) will

Re: "ClojureScript Mobile" BOF at the Clojure/conj?

2011-10-18 Thread Chouser
ing someone from creating > a google docs spreadsheet, defining some time slots, and dropping > talks / BOFs / topical hack sessions in, quasi-unconference style. I love this idea -- google spreadsheet of extra events. /me waits for someone to post a link. --Chouser -- You received this messa

Re: Recursively convert Java Map to Clojure Map

2011-10-16 Thread Chouser
those aren't (yet!) protocols, I supposed you'd have to either use a non-standard conj and assoc, or create a wrapper around the Java Maps. Of course there are complications with all three of these solutions, so you'll have to choose carefully based on your needs. --Chouser -- You rece

Re: Partitioning problem

2011-09-23 Thread Chouser
as to compare the sum to log(n) other buckets each time instead of doing an n*log(n) sort-by. --Chouser -- 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 Note that posts from new me

Re: How does clojure class reloading work?

2011-09-22 Thread Chouser
On Thu, Sep 22, 2011 at 8:52 PM, Phil Hagelberg wrote: > On Thu, Sep 22, 2011 at 2:19 PM, Chouser wrote: >> It looks like each top-level form currently gets its own fresh >> DynamicClassLoader. >> >> [...] >> >> (do (def a #()) (def b #())) > >

Re: How does clojure class reloading work?

2011-09-22 Thread Chouser
se: (do (def a #()) (def b #())) (.getClassLoader (class a)) ;=> # (.getClassLoader (class b)) ;=> # --Chouser -- 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 Note that posts

Re: clojurescript closure problem?

2011-09-22 Thread Chouser
On Thu, Sep 22, 2011 at 8:46 AM, David Nolen wrote: > It's a known issue: > http://dev.clojure.org/jira/browse/CLJS-39 I somehow missed that one and had filed this one as well: http://dev.clojure.org/jira/browse/CLJS-59 --Chouser -- You received this message because you are subscr

Re: [newbie] filter confusion

2011-09-20 Thread Chouser
result for each. I can't reproduce your results: user=> (filter #(not-seen-already? path %) next-steps) () What does your REPL say if you: (= (first next-steps) (first path)) What version of Clojure are you using? --Chouser -- You received this message because you are subscribed to the Go

Re: How to convert general recursion to loop .. recur syntax

2011-09-15 Thread Chouser
arvel for a moment at the beauty of lazy seqs, that they can sometimes avoid both premature computation and stack overflows, even in cases where no amount of tail-call-optimization would help! And all this while delivering code so similar to the problem statement and therefore concise, compared to

Re: Neighbors function from The Joy of Clojure

2011-09-14 Thread Chouser
an to put words in your mouth, Fogus. > It was used again only briefly in section 11.2 to define the legal > moves that a king can make in chess, which of course includes > diagonals.  :-) Ah, indeed. Sorry to mislead. --Chouser -- You received this message because you are subscribed t

Re: How to convert general recursion to loop .. recur syntax

2011-09-14 Thread Chouser
) todo) [dst] Jonathan Claggett helped write that. I'm not sure there was ever a moment where we both understood it simultaneously. It essentially does what zippers do, but holds the data in a loop/recur frame rather than a data structure. Any further explanation is left as an exercise to

Re: Neighbors function from The Joy of Clojure

2011-09-14 Thread Chouser
lly equivalent? And if so, why is the first > syntax supported or better yet, when is it best to use it? The main difference is that the first version allows you to pass in your own deltas. This could be useful if you wanted to include diagonals as neighbors. We don't think we take advan

Re: Programmer Day

2011-09-13 Thread Chouser
nt)) s) '[ibqqz qsphsbnnfs ebz])) --Chouser -- 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 Note that posts from new members are moderated - please be patient with your first

Re: heaps in clojure

2011-09-13 Thread Chouser
s in clojure? .. Is there > some other way to achieve this? some sort of lazy sort would be perfect. I > know I need the full collection to start with .. but that is fine. A seq on a sorted set should be pretty efficient. (take 3 (sorted-set 8 2 1 4 6 9 7 3)) ;=> (1 2 3) --Chouser -- You

Re: Misleading Exception due to function name containing ->

2011-09-12 Thread Chouser
Exception: Wrong number of args (1) passed to: >> user$bar (NO_SOURCE_FILE:0) > > It is reporting the correct function but not reporting the name > correctly (I just tried a similar example before I saw Stefan's post). https://github.com/clojure/clojure/blob/master/src/jvm/cloju

Re: Misleading Exception due to function name containing ->

2011-09-12 Thread Chouser
ontaining ->. > Is this a bug? I was unable to reproduce the problem: user=> (defn foo->fn [] (throw (Exception. "bad thing"))) #'user/foo->fn user=> (defn other-fn [] (foo->fn)) #'user/other-fn user=> (other-fn) Exception bad thing user/foo->fn (NO_S

Re: What's wrong with my *print-dup* persistence?

2011-09-09 Thread Chouser
the outer +, which fails because it's expecting a number not a list. So one alternative would be: #=(+ 1 #=(+ 2 4)) ;=> 7 But please consider another alternative: (+ 1 (+ 2 4)) ;=> 7 That is, if you're going to be evaluating a large amount of code while reading you

Re: java interop not possible in #=(..) reader syntax?

2011-09-09 Thread Chouser
generally best not to use the older form (. foo bar) as it can be ambiguous. But just so you know what's going on... If Clojure finds that foo is a class name, it assumes that bar is a static method or field of class bar. When if can't find a foo in bar, it gives you the error above. By

Re: On Lisp with Clojure

2011-09-09 Thread Chouser
is turring complete. If scheme can do it compiling down > to machine code, clojure could do it compiling down to JVM bytecode. Yes, but it would have to use a technique such as trampolines which would not follow Java calling conventions, with implications for both interop and HotSpot performanc

Re: ANN: ClojureSphere - browse the Clojure ecosystem

2011-09-06 Thread Chouser
or creating this. --Chouser -- 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 Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from

Re: not= counterintuitive?

2011-09-03 Thread Chouser
On Sat, Sep 3, 2011 at 10:59 AM, Alex Baranosky wrote: > Sounds like you want a function such as: > > none= ...which could be written as #(not-any? #{1} [1 2 3]) --Chouser -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post

Re: ClojureScript can't call JavaScript functions relying on `this`

2011-08-29 Thread Chouser
o = function(){  return this.one() + 1; }; >    x.__proto__ = p_injection; >    x.two(); // 2 >    x.two.call(null); // error, object has no method "one()" Have you tried calling the method using the interop form? (. x (two)) --Chouser -- You received this message because you ar

Re: Errors in Clojure

2011-08-19 Thread Chouser
7;t with credentials that should never be used because I never > specified them anywhere, so, I kinda need the stack trace to track down the > problem. Some versions of Clojure provide a function pst at the repl: (pst) This tries to print the stack trace in a prettier way. --Chouser --

Re: clojurescript support of ns-* functions

2011-08-19 Thread Chouser
it's pretty much meaningless by runtime. Does that help? --Chouser -- 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 Note that posts from new members are moderated - please be

Re: Creating a map algorithmically

2011-08-09 Thread Chouser
less memory, and probably others. Depending on your goals, a vector may or may not be preferable to a hash-map. --Chouser -- 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 Note th

Re: Toward in-browser ClojureScript debugging ?

2011-08-09 Thread Chouser
w far it got or if anybody is actively working on it at the moment. It would certainly be nice to have! --Chouser -- 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 Note that posts fr

Re: Referencing Clojure code from the ClojureScript namespace

2011-08-08 Thread Chouser
but that all happens while the ClojureScript is being compiled. The macros must produce valid ClojureScript code so that it can be compiled to JavaScript, at which point it has lost all access to Clojure and must make do with ClojureScript and JavaScript functions. --Chouser -- You receive

Re: ClojureScript binding problem

2011-08-01 Thread Chouser
is an empty list to them thinking that (method) is a normal function call. Actually, I'm still hoping we'll be able to come up with something less ugly that is nevertheless consistent with normal Clojure syntax. I have no idea what that would be. --Chouser -- You received this mess

Re: Alright, fess up, who's unhappy with clojurescript?

2011-07-25 Thread Chouser
a couple of the G. Closure library files that ClojureScript itself uses, but nothing compared to streaming HD video. So, you could use ClojureScript and jQuery to write a snappy little demo and prove to everyone the value of that approach. I'm sure I'm not the only one that would be inter

ClojureScript announcement video

2011-07-21 Thread Chouser
Video is now available of Rich Hickey's talk at ClojureNYC yesterday announcing ClojureScript. http://blip.tv/clojure/rich-hickey-unveils-clojurescript-5399498 Thanks to the Clojure/core team for getting this online so rapidly! --Chouser -- You received this message because you are subsc

Re: Most concise way to determine that a sequence is consecutive integers starting with one?

2011-07-01 Thread Chouser
umbers >> >> Can someone suggest something better? > > (defn f [xs] (every? #(apply = %) (map vector xs (iterate inc 1 (defn f [xs] (every? true? (map = xs (iterate inc 1 --Chouser -- You received this message because you are subscribed to the Google Groups "C

Re: New to Clojure

2011-06-09 Thread Chouser
new functional directions. Then once you've got Clojure under belt, go get a real editor. ;-) --Chouser http://joyofclojure.com/ -- 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

Re: Re: first element after an element in the sorted-set?

2011-05-24 Thread Chouser
e you can also walk the other direction using rsubseq: (first (rsubseq (sorted-set 1 2 3 4 5 6) < 3)) ;=> 2 --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@go

Re: Applying collection of functions

2011-04-07 Thread Chouser
On Thu, Apr 7, 2011 at 9:11 AM, Baishampayan Ghose wrote: > On Thu, Apr 7, 2011 at 6:34 PM, Chouser wrote: >>>> Given a collection of functions >>>> >>>> (def fs [#(* % 10) #(+ % 1)]) >>>> >>>> and some numbers >>>> >&

Re: Applying collection of functions

2011-04-07 Thread Chouser
(map #(reduce (fn [x f] (f x)) % fs) c) Hm, BG's solution compiles no new classes, while mine generates two. More classes is better, right? :-P --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To pos

Re: Your favorite utility function or macro.

2011-03-25 Thread Chouser
would guess people wrote it for other lisps even previous to that. --Chouser http://joyofclojure.com/ -- 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 Note that posts from new membe

Re: Comparing clojure speed to java speed

2011-03-11 Thread Chouser
aren't useful. In which case I'd recommend leaving them out. --Chouser -- 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 Note that posts from new members are moderated

Re: Clojure on JS VMs

2011-03-03 Thread Chouser
I'm sorry it's too out of date to be of much real use now, but it does show it's possible and hopefully has some tidbits that will be useful in later implementations. --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups &q

Re: Problems with lazy-xml

2011-02-12 Thread Chouser
t want it. The drop-last is used because the last node of each interior sequence holds the non-descendant events and so must be dropped from the content seq. I'm currently trying to come up with a different way of passing around the non-descendant events so that drop-last isn't neces

Re: Problems with lazy-xml

2011-02-11 Thread Chouser
On Fri, Feb 11, 2011 at 2:35 PM, Chris Perkins wrote: > On Feb 11, 5:07 am, Marko Topolnik wrote: >> http://db.tt/iqTo1Q4 >> >> This is a sample XML file with 1000 records -- enough to notice a >> significant delay when evaluating the code from the original post. >&

Re: Efficient queue types for Clojure.

2011-01-22 Thread Chouser
noting that > it's not truly O(1). Clojure's sorted collections are binary trees thus log2, not log32 like the hashed collections. --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to th

Re: Testing if a sequence is lazy

2011-01-19 Thread Chouser
uld change at any time, probably fails in various spectacular ways. Use at your own risk. :-) http://gist.github.com/589694 --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

Re: a loop gives boxing warning when it shouldn't

2011-01-03 Thread Chouser
On Sat, Jan 1, 2011 at 5:47 PM, Albert Cardona wrote: > Hi all, > > I'd apreciate help on figuring out why a loop gets number boxing > warnings, when it shouldn't: > > http://clojure.pastebin.com/9uLZqGhy I just filed this as: http://dev.clojure.org/jira/br

Re: Error Handling for Callback API to Blocking API example in Joy of Clojure

2010-12-21 Thread Chouser
On Sun, Dec 19, 2010 at 3:36 AM, HiHeelHottie wrote: > > In Joy of Clojure, there is a callback API to blocking API example in > the section on promises.  Chouser outlines it a briefly in a > discussion on Promise/Deliver use cases here - > http://groups.google.com/group/clojur

Re: clojure -> javascript

2010-12-21 Thread Chouser
On Tue, Dec 21, 2010 at 6:51 AM, Shane Daniel wrote: > Hi everybody, > Just for kicks I took Chouser's good start on the PersistentVector port and > threw it in a Github gist, and demonstrated using it in jsFiddle. I love the > cloud these days ;) > Anyway, I hope you don&#x

Re: Let usage question

2010-10-28 Thread Chouser
onger be safely cleared." This is dramatically better than the "invisible" head-holding that sometimes happened in earlier versions of Clojure (and was noted in earlier versions of JoC), but is still good to be aware of. --Chouser http://joyofclojure.com/ -- You received this mess

Re: finding value nearest x

2010-09-25 Thread Chouser
(min-key #(Math/abs (- % 136)) (first asc) (first desc))) That's O(log n) instead the simpler (apply min-key ...) which is O(n). --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: partition-starting-every : yet another partition function

2010-09-16 Thread Chouser
have the lazy-seq outside the empty test to make your fn as lazy as possible. And I'd use split-with: (defn partition-starting-every "Partition the sequence starting each partition when the f is true." [f coll] (lazy-seq (when-let [[x & xs] (seq coll)] (let

Re: possible bug

2010-09-13 Thread Chouser
wrong?  I have also moved the > binding of x inside the "try" and it has the same behavior. For me, x and y are unbound after running either function on a recent master branch of Clojure. What version of Clojure are you using? user=> (clojure-version) "1.3.0-master-SNAPSHOT"

Re: clojurescript and 1.2.0

2010-09-12 Thread Chouser
k with Clojure 1.0 (with the patch applied) ... or perhaps even an earlier version than that. I've given up working on it until more of Clojure-in-Clojure is complete, which will make bringing ClojureScript up to date and keeping it there dramatically easier. --Chouser http://joyofclojure.co

Re: Line numbers for forms embedded in macros

2010-09-12 Thread Chouser
failing line. > > Better ideas for fallbacks? In your macro, try printing out your input forms with *print-meta* on. (defmacro print-meta [& args] (binding [*print-meta* true] (prn args))) I think you'll find some useful data in there. There won't

Re: lisp error system in clojure

2010-09-09 Thread Chouser
or hierarchy, please let me know. These features seem very complex for how often they're used so I'd be pleased to find a simpler subset that is at least as useful. --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure&qu

Re: Does 'require' with the :reload option have a tendency to build up memory?

2010-09-03 Thread Chouser
; namespace, but all of them together. That's why I was thinking that it > may have possibly been some implicit weirdness with reload. Which classes show the most increase in instance count? Or perhaps you could attach or post the full list of before and after instance counts somewhere.

Re: Thinking in Clojure

2010-09-03 Thread Chouser
uot; Perhaps you heard it in Yegge's enjoyable essay: http://steve-yegge.blogspot.com/2006/03/execution-in-kingdom-of-nouns.html --Chouser -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@g

Re: Does 'require' with the :reload option have a tendency to build up memory?

2010-09-02 Thread Chouser
eps I can take to keep memory from building up > like this? I'd recommend using a memory profiling tool that lists the object counts by class. I think jvisualvm that comes with Sun's JDK will do it, and I know yourkit will. Check your counts before a :reload and again after -- might

Re: Why do is used in this function?

2010-08-31 Thread Chouser
[s] >  (when (seq s) >   (println "Item:" (first s)) >   (recur (rest s Good tips! Another option: (defn printall [s] (doseq [i s] (println "Item:" i))) --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to

Re: Basic colour in the standard REPL

2010-08-27 Thread Chouser
You can either just run (my-repl) at the REPL, or start Clojure with -e '(my-repl)' If you then run a little test, you can see each of the different colors: (do (println "hi") 5) --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to

Re: inserting into vector

2010-08-26 Thread Chouser
On Thu, Aug 26, 2010 at 12:43 PM, David Nolen wrote: > On Thu, Aug 26, 2010 at 11:53 AM, Chouser wrote: >> >> On Thu, Aug 26, 2010 at 9:44 AM, Jon Seltzer >> wrote: >> > I know what assoc does: >> > >> > user=> (assoc [\a \b \c] 0 \d)  ;

Re: inserting into vector

2010-08-26 Thread Chouser
On Thu, Aug 26, 2010 at 11:53 AM, Chouser wrote: > On Thu, Aug 26, 2010 at 9:44 AM, Jon Seltzer wrote: >> I know what assoc does: >> >> user=> (assoc [\a \b \c] 0 \d)  ;please extend to much larger vector >> with index somewhere in the middle >> [\d \b \c]

Re: inserting into vector

2010-08-26 Thread Chouser
)) ;=> [a b c X d e f] That's about as good as you're going to get with vectors, O(n) where n is (- (count v) i). --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send e

Re: Simple Regex Question

2010-08-21 Thread Chouser
, I have to be able to tell which of the strings of b's was > preceded with an "a", and which was preceded by a space. (->> "aaa bbb abb ab bb" (re-seq #"(?<=(.))?(\w)\2*") (map (fn [[s pre]] {:s s, :pre pre}))) returns a lazy seq: ({:s "a

Re: Today's clojure trick question

2010-08-18 Thread Chouser
thod instead of its constructor. This is the right way: (if (Boolean/valueOf "false") :truthy :falsey) ;=> :falsey --Chouser http://joyofclojure.com/ 1: http://download-llnw.oracle.com/javase/1.5.0/docs/api/java/lang/Boolean.html#Boolean%28boolean%29 -- You received this

Re: Nil Coalesce

2010-08-17 Thread Chouser
ctions (fn [[_ b] a] (if (nil? a) [(first b) (rest b)] [a b])) [0 b]) rest (map first))) This is much like Jeff Valks solution, but lazy. --Chouser http://joyofclojure.com/ -- You received this m

Re: Nil Coalesce

2010-08-17 Thread Chouser
gt;  (defn nil-coalesce [a b] >>    (map #(if (nil? %1) %2 %1) a (concat b (repeat nil >> > > > I am not sure to get it. > Won't map advance in  parrallel in the sequences, jumping over the > values in b where there is something in a? Oh, indeed. I misunderst

Re: Nil Coalesce

2010-08-17 Thread Chouser
sce (nil 1 2 3 nil nil) (4 5)) > (4 1 2 3 5 nil) Clojure golf is the most fun golf! (defn nil-coalesce [a b] (map #(or %1 %2) a (concat b (repeat nil Or if you really want to treat nil and false differently: (defn nil-coalesce [a b] (map #(if (nil? %1) %2 %1) a (concat b

Re: Identifying error-kit Throwables

2010-08-16 Thread Chouser
provide private Var in error-kit until it does what > you want... > > (instance? @#'clojure.contrib.error-kit/ctrl-exception-class your- > throwable) > > Be advised, that this uses a clever trick which is maybe too clever? All of error-kit is in danger of being too clever. But it does seem like

Re: order of returned values from keys and vals

2010-08-11 Thread Chouser
this is promised, though I agree having it in the docstring of keys and vals would be nice. --Chouser http://joyofclojure.com/ -- 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 Note

Re: lazy-seq realization/retention within futures

2010-08-11 Thread Chouser
On Wed, Aug 11, 2010 at 3:06 PM, Stuart Halloway wrote: > Chouser, > > There is now a ticket and roadmap for fixing this: See > https://www.assembla.com/spaces/clojure/tickets/423-make-sure-future-clears-closed-overs. Did you see that my examples didn't use future at all

Re: lazy-seq realization/retention within futures

2010-08-11 Thread Chouser
er of my examples, though of course retaining the head of a lazy seq retains the entire seq, and creating a future does create a closure. --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: Question on defrecord

2010-08-11 Thread Chouser
factory function for each record type, you can create an anonymous fn on the fly instead: (defrecord X []) (def hey #(X.)) (hey) ;=> #:user.X{} Note in either case when you define the factory fn (named or not), you need to specify all the args the real record constructor

Re: jna Java Native Acess and clojure ....

2010-08-11 Thread Chouser
Java interop code, so quite well and naturally. --Chouser http://joyofclojure.com/ -- 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 Note that posts from new members are moderated - pl

Re: Bug in try/finally?

2010-08-11 Thread Chouser
On Wed, Aug 11, 2010 at 8:01 AM, Stuart Halloway wrote: > Ticket and patch welcome! Done and done: https://www.assembla.com/spaces/clojure/tickets/422 --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" grou

Re: Bug in try/finally?

2010-08-11 Thread Chouser
ould be included in clojure-test, but I don't see your name on the contributor's list: http://clojure.org/contributing Have you sent in your CA? --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" grou

Re: Bug in try/finally?

2010-08-10 Thread Chouser
On Tue, Aug 10, 2010 at 2:51 PM, Chouser wrote: > > That patch seems to essentially reverse this one: > > http://github.com/clojure/clojure/commit/5e9f2b293b307aa7953cd390360d24549e542b92 > > ...which suggests to me there must be a better solution, though I > don't see

Re: Bug in try/finally?

2010-08-10 Thread Chouser
erse this one: http://github.com/clojure/clojure/commit/5e9f2b293b307aa7953cd390360d24549e542b92 ...which suggests to me there must be a better solution, though I don't see yet what it would be. --Chouser -- You received this message because you are subscribed to the Google Groups "Clojure

Re: jna Java Native Acess and clojure ....

2010-08-09 Thread Chouser
ood > to use .. Or do you have any other suggestions.. I wrote clojure-jna, but although I haven't had a chance to use clj-native yet I understand it's significantly more advanced and efficient than clojure-jna. So I'd recommend at least starting with clj-native to see if it wi

Re: alter atom while iterating

2010-07-13 Thread Chouser
[0 0] [0 1] [0 2] [1 0] [1 1] [1 2]) So just before seq is needed, the expression that produces that seq is re-evaluated. This is necessary because inner seq expressions to the right can refer to locals defined further to the left, thus their result could be different for each iter

Re: explode string

2010-07-01 Thread Chouser
(next (.split #"(?=)" string)) But why do you one-char strings instead of just a seq of chars? --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@g

Re: Can't send from agent error handler?

2010-06-29 Thread Chouser
action, as if it was itself an agent action, but you may not use 'await' inside an agent action. Using await there throws an exception, but since you're already in an error handler, that exception is silently thrown away and you still won't see the "CODE DOESN'T REACH

Re: Can't send from agent error handler?

2010-06-29 Thread Chouser
me stuff about it in the wiki [1], > but it's hard to tell what was decided explicitly. Thanks for the report. Ticket is here: http://www.assembla.com/spaces/clojure/tickets/390 Please try out the patch there and see if it works and/or causes other problems. Thanks. --Chouser http:

Re: Question: pmap + number of threads + number of cpus

2010-06-28 Thread Chouser
t, I guess pmap isn't expecting. So pmap creates one 'future' per element, but instead of only doing this for procs+2 elements at a time, it does so for every element of the first chunk. If you use range of more than 32 elements, you'll see your example doesn't go beyo

Re: Protocols

2010-06-28 Thread Chouser
But after looking into it a bit more, it appears that docstring is not (yet?) accurate. --Chouser http://joyofclojure.com/ -- 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 Note th

Re: lazy-xml defect (?)

2010-06-23 Thread Chouser
inserts newlines when it shouldn't and fails to escape text and attribute values. I'd be happy to see it use lazy-xml's implementation instead, unless people have issues with how lazy-xml does it. --Chouser http://joyofclojure.com/ -- You received this message because you are su

Re: Non-tail recursion (Clojure way to hierarchies)

2010-06-15 Thread Chouser
;=> 123456789012345678...67890123456789 Note that since these trees are infinitely deep, a depth-first walk like tree-seq does is probably not very useful: (take 8 (map :item (tree-seq :kids :kids (node 1 ;=> (1 10 100 1000 1 10 100 1000) Hope that

Re: Unexpected conj behavior

2010-06-15 Thread Chouser
t; # cannot be cast to java.util.Map$Entry (NO_SOURCE_FILE:...)> Stuart S. already covered the reasons for this behavior. Given those reasons, a solution that works for your last example there is: (apply array-map [:a 1 :b 2 :c 3 :d 4]) ;=> {:a 1, :b 2, :c 3, :d 4} --Chouser http://joyofc

Re: update-in oddness

2010-06-04 Thread Chouser
argument, but not your implementation: (update-in* {nil 2} [nil] (constantly 3)) ;=> 3 Perhaps: (defn update-in* [m ks f & args] (if-let [[k & mk] ks] (if mk (assoc m k (apply update-in* (get m k) mk f args)) (assoc m k (apply f (get m k) args

Re: Question on destructure source

2010-06-03 Thread Chouser
binding map. Which means the above example does exactly the same things as: (let [{a :a b :b} {:a 1 :b 2}] [a b]) ;=> [1 2] ...which is what you'd do if there was no support for :keys --Chouser http://joyofclojure.com/ -- You received this message because you are su

Re: Insert into an indexed seq

2010-04-27 Thread Chouser
for example finger trees: http://functionaljava.googlecode.com/svn/artifacts/2.21/javadoc/fj/data/Seq.html --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to

Re: let's all link to the "getting started" pages!

2010-04-06 Thread Chouser
top hit for "clojure getting started" is http://clojure.org/getting_started -- should that page be replaced or at least simplified and include a prominent link to the assembla page? --Chouser http://joyofclojure.com/ -- You received this message because you are subscribed to the Googl

Re: Set as function

2010-04-05 Thread Chouser
returns true and false, so that's not a particularly good example. "Which of the items in this set comes first in this vector?" (some #{:b :c} [:a :c :d]) ;=> :c --Chouser -- You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: Confused about "=", native java arrays and seqs...

2010-03-24 Thread Chouser
anges the underlying array values? Pray. (let [a (into-array (range 5)), s (seq a)] (prn s) (aset a 1 42) (prn s)) ; (0 1 2 3 4) ; (0 42 2 3 4) I'd recommend keeping the exposure of arrays to very small and isolated pieces of code, if they must be used at all. --Chouse

  1   2   3   4   5   6   7   8   >