Re: Reducers newbie question

2013-04-26 Thread Alan Busby
Some additional pointers here (this is a little old though); http://www.thebusby.com/2012/07/tips-tricks-with-clojure-reducers.html On Fri, Apr 26, 2013 at 11:51 PM, László Török ltoro...@gmail.com wrote: Hi, Not sure what you are trying to do, but xxx is a lazy seq, thus it can only be

Re: style questions -- clojure newbie

2013-04-23 Thread Alan Malloy
Raynes recently released https://github.com/Raynes/least, a Clojure client for the last.fm API. Have you looked into just using his, rather than reinventing the API layer yourself? On Tuesday, April 23, 2013 2:12:37 PM UTC-7, Huey Petersen wrote: Howdy, I'm a clojure fan but quite new to

Re: [ANN] Javelin, spreadsheet-like FRP for ClojureScript

2013-04-22 Thread Alan Dipert
Np! Alan On Mon, Apr 22, 2013 at 7:41 AM, Hank h...@123mail.org wrote: Hi Alan, Only saw your answer now, somehow Google groups didn't notify me. Thanks for clarifying. -- hank -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post

Re: Arrays and indexes

2013-04-18 Thread Alan Malloy
(for [[y cols] (map-indexed vector rows) [x cell] (map-indexed vector cols)] (display cell y x)) ? On Thursday, April 18, 2013 3:14:19 AM UTC-7, edw...@kenworthy.info wrote: So, I want a 2 dimensional array. I think the best way to implement this is a vector of vectors. Now I want

Re: [ANN] Schejulure 0.1.3

2013-04-18 Thread Alan Thompson
Looks nice! Alan On Mon, Apr 15, 2013 at 12:40 PM, Anthony Grimes disciplera...@gmail.comwrote: You had me at the changelog entry regarding Sundays. I was actually tasked with writing pretty much this at work last Friday. My thanks for doing my work for me. Unfortunately I don't think you

Re: Type hinting generated functions

2013-04-15 Thread Alan Malloy
If all the functions you want to generate accept doubles, you can just modify str-sym to include a (with-meta (symbol ...) {:tag 'double}) and it should generate exactly the code in your hand-written version. As an aside, there's no reason for str-sym to be a macro: it should just be a function

Re: Difficulty working with complex protobuf objects [protobuf 0.6.2]

2013-04-11 Thread Alan Malloy
0.6.2 is six months old. I don't think anything about this has changed since then, but you should at least try [org.flatland/protobuf 0.7.2] and see if that does what you expect. On Thursday, April 11, 2013 8:39:12 AM UTC-7, David Pidcock wrote: I have some Java classes generated elsewhere

Re: Function recurring regardless of condition

2013-04-08 Thread Alan Malloy
You might be interested in https://github.com/amalloy/clusp/blob/master/src/snusp/core.clj, my Clojure interpreter for SNUSP (which is brainfuck with different control-flow mechanics). It's purely functional, and IMO does a good job of separating concerns; both of those are things it sounds

Re: Some docs on comparators, including mistakes to avoid, Clojure extended doc strings

2013-04-04 Thread Alan Shaw
Thumbs up on the comparators doc! On Apr 4, 2013 12:49 PM, Andy Fingerhut andy.finger...@gmail.com wrote: I am seriously considering the idea of working on some extended doc strings for Clojure functions. Having only scratched the surface so far, I have learned that it could take a *lot* of

Re: - operator and monads

2013-04-03 Thread Alan Malloy
Not even that: - is not a function composition operator at all, but a form-rewriting macro. You can perfectly well write (- [x xs] (for (inc x))) to get (for [x xs] (inc x)), and that is not composing any functions. The two things are entirely separate. On Wednesday, April 3, 2013 12:45:55 PM

Re: Attempt at rethrow macro

2013-04-01 Thread Alan Malloy
On Monday, April 1, 2013 10:26:43 AM UTC-7, Alf wrote: I am guessing the problem is that the rethrow macro is expanded and passed to the reader/compiler before the handle-ex macro is. And at that point the compiler sees catch as a standalone-symbol, not as part of the try special form.

Re: Problem with map (only when running on browser)

2013-04-01 Thread Alan Thompson
I second that, Nico! For some reason the lines are not wrapping at all in GMail and are coming in a couple of hundred char's wide! Alan On Sat, Mar 30, 2013 at 8:54 AM, Cedric Greevey cgree...@gmail.com wrote: On Sat, Mar 30, 2013 at 10:09 AM, Nico nbren...@gmail.com wrote: BTW, it seems

Re: Attempt at rethrow macro

2013-04-01 Thread Alan Malloy
This is how every macro and special form works. I know you like to complain, but the alternative is simply not possible: macros have complete control of expanding their bodies, and any macros therein are expanded later, not before. Try writing a macro system that goes the other way, and see

Re: WAT? BigInt instead of Long?

2013-04-01 Thread Alan Thompson
the overhead of the arbitrary-precision type. But, the extra precision is there if you need it later on in a calculation. Alan Thompson On Mon, Apr 1, 2013 at 2:43 PM, Gary Verhaegen gary.verhae...@gmail.comwrote: That's because ratios are intended to get you arbitrary precision. That would

Re: What is the status of Clojure on LLVM or C?

2013-03-29 Thread Alan Moore
would love to see an LLVM target for clojure. I have been looking into how clojurescript is implemented and how similar/different an LLVM target would be to implement... Alan -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group

Re: Floating point comparator issue?

2013-03-29 Thread Alan Malloy
Comparator.compare returns an int. (int 0.2) and (int -0.2) both return 0. Thus, your comparator is returning 0, saying I don't care what order these go in. On Mar 29, 6:44 pm, JvJ kfjwhee...@gmail.com wrote: Alright check this out: ;; Normal subtraction as comparator sorts in ascending order

Re: Working with a huge graph - how can I make Clojure performant?

2013-03-28 Thread Alan Malloy
Have you looked at https://github.com/jordanlewis/data.union-find ? Personally, I'd prefer it to Christophe's implementation, since his blog post seems to start with I dislike this algorithm; I also helped out a bit in writing this version. On Monday, March 11, 2013 10:37:39 AM UTC-7, Balint

Re: Quirk with printing regexps

2013-03-28 Thread Alan Malloy
On Thursday, March 28, 2013 5:36:45 PM UTC-7, Andy Fingerhut wrote: I don't understand why (re-pattern a\\\nb) would match the same thing. I would have guessed that it wouldn't, but it does indeed do so. For all I know that could be bug or weird dark corner case in the Java regex

Re: [ANN] Javelin, spreadsheet-like FRP for ClojureScript

2013-03-28 Thread Alan Dipert
of dataflow, and look forward to further developments in the Clojure space. Alan . Cheers -- hank On Wednesday, February 20, 2013 6:33:56 PM UTC+11, Alan Dipert wrote: Hi all, We recently released a ClojureScript library for FRP called Javelin. Links of interest: * Release announcement

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Alan Thompson
Apply works for any number of args: (apply + [1 2 3 4 5]) He just gave you an example inline function of 2 args since that was the original example. Alan Thompson On Tue, Mar 26, 2013 at 12:44 PM, Ryan arekand...@gmail.com wrote: Thanks Michael, but If i am not mistaken, your example only

Re: Apply elements in a vector as arguments to function

2013-03-26 Thread Alan Thompson
Essentially, apply just removes the parens (or brackets) from your list of args and creates the original function call: (apply + [1 2 3]) - (+ 1 2 3) Alan Thompson On Tue, Mar 26, 2013 at 12:49 PM, Alan Thompson thompson2...@gmail.comwrote: Apply works for any number of args: (apply

Re: Clojure/West 2013 videos?

2013-03-25 Thread Alan Thompson
Thank you for the conferences! I missed this one but really want to attend the next one. And a double thank you for having such high-quality videos from past conferences available on-line! Alan Thompson On Mon, Mar 25, 2013 at 10:35 AM, Mark Engelberg mark.engelb...@gmail.comwrote: I've been

Re: Clojure/West 2013 videos?

2013-03-24 Thread Alan Busby
On Mon, Mar 25, 2013 at 12:24 PM, Rich Morin r...@cfcl.com wrote: I can wait a bit for the editing; clean results are more important than saving a month or so. I wouldn't say anything if it was only a month, it's actually closer to 3-7 months after the conference though. Clojure West 2012

Re: Clojure/West 2013 videos?

2013-03-23 Thread Alan Busby
On Sat, Mar 23, 2013 at 2:48 PM, Alex Miller a...@puredanger.com wrote: The benefit to attendees and non-attendees is that the videos exist at all - without the InfoQ deal, the cost of recording, editing, and hosting videos is literally the difference between whether the conference is in the

Re: Map destructuring variations in Pedestal

2013-03-20 Thread Alan Malloy
Yes. Apparently you can put whatever garbage you want into the `:or` map: each local is looked up in that map to see if it has a default, but nobody ever checks to see if there are unused keys in the defaults map. So `:or {::type :jety}` has no impact at all on the generated code: there is no

Re: nested map destructuring

2013-03-20 Thread Alan Thompson
Nice explanation! --Alan On Tue, Mar 19, 2013 at 1:09 PM, Jim - FooBar(); jimpil1...@gmail.comwrote: nice one...when thinking like there is literally no confusion. thank you thank you thank you :) Jim On 19/03/13 20:05, Marko Topolnik wrote: Think of it in layers, like

Re: set!

2013-03-13 Thread Alan Malloy
On Wednesday, March 13, 2013 2:46:06 PM UTC-7, puzzler wrote: On Wed, Mar 13, 2013 at 2:06 PM, Marko Topolnik marko.t...@gmail.comjavascript: wrote: As far as I understand it, *set!* modifies the *thread-local* binding, just like the *binding* macro, but doesn't delimit a definite scope

Re: fold over a sequence

2013-03-12 Thread Alan Busby
On Tue, Mar 12, 2013 at 11:00 PM, Paul Butcher p...@paulbutcher.com wrote: On 12 Mar 2013, at 13:49, Adam Clements adam.cleme...@gmail.com wrote: How would feeding a line-seq into this compare to iota? And how would that compare to a version of iota tweaked to work in a slightly less eager

Re: ANN: Iota 1.0.2 release (Reducers for text files)

2013-03-10 Thread Alan Busby
to allow for (- (iota/vec filename.tsv) (r/filter identity) ... Hope this helps, Alan On Sat, Mar 9, 2013 at 9:41 AM, bernardH un.compte.pour.tes...@gmail.comwrote: Hi Alan, On Friday, March 8, 2013 4:02:18 PM UTC+1, Alan Busby wrote: Hi Bernard, I'd certainly like

Re: fold over a sequence

2013-03-10 Thread Alan Busby
I'm not aware of any mechanism to have fold *NOT* use every available resource. Hope this helps, Alan -- -- 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

Re: ANN: Iota 1.0.2 release (Reducers for text files)

2013-03-08 Thread Alan Busby
is full of records each 100B in size, and you ask for the 10th record; don't you already know that the length of the record is 100B? Hope I can help, Alan On Fri, Mar 8, 2013 at 1:44 AM, bernardH un.compte.pour.tes...@gmail.comwrote: Hi, On Wednesday, March 6, 2013 2:53:26 PM UTC+1

ANN: Iota 1.0.2 release (Reducers for text files)

2013-03-06 Thread Alan Busby
is available on Clojars here: https://clojars.org/iota Hope it helps, Alan Busby -- -- 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

Re: Improving visibility of clojure-doc.org

2013-02-28 Thread Alan Shaw
The ordinary visitor might be forgiven for expecting that both would be found under someplace like Clojure.org... just a thought. -A On Feb 28, 2013 2:04 AM, Michael Klishin michael.s.klis...@gmail.com wrote: 2013/2/28 xavriley i...@xavierriley.co.uk On another note, I wonder whether it's

Re: Support for pmap?

2013-02-26 Thread Alan Shaw
Could parallel.js and web workers help? On Feb 25, 2013 6:12 PM, David Nolen dnolen.li...@gmail.com wrote: Not sure how we could given JS is single threaded. On Monday, February 25, 2013, MC Andre wrote: Does ClojureScript support pmap? -- -- You received this message because you are

Re: Like if, but it composes functions

2013-02-20 Thread Alan Malloy
wrote: Hello, Why the names fix / to-fix ? 2013/2/20 Alan Malloy al...@malloys.org javascript:: Useful has functions that do this and more: fix or to-fix, according to taste. Your iffn is just the three-argument case of to-fix: (def magnify (to-fix pos? inc dec)). But fix and to-fix

Re: Like if, but it composes functions

2013-02-19 Thread Alan Malloy
Useful has functions that do this and more: fix or to-fix, according to taste. Your iffn is just the three-argument case of to-fix: (def magnify (to-fix pos? inc dec)). But fix and to-fix accept more or fewer arguments as well, so that (fix x pos? inc) is like (if (pos? x) (inc x) x), and

Re: Like if, but it composes functions

2013-02-19 Thread Alan Malloy
Sorry, forgot to link to useful: https://github.com/flatland/useful/blob/develop/src/flatland/useful/fn.clj#L30 On Tuesday, February 19, 2013 9:53:57 PM UTC-8, James MacAulay wrote: Sometimes I find myself writing code like this: (defn magnify [n] (if (pos? n) (inc n) (dec n))) ...and I

Re: clj/cljs best practice

2013-02-19 Thread Alan Dipert
-priority-map. I hope this clarifies things. Have fun with Javelin! Alan 1. https://github.com/tailrecursion/javelin/blob/master/project.clj#L9 2. https://github.com/tailrecursion/cljs-priority-map/blob/master/project.clj On Tuesday, February 19, 2013 3:13:13 PM UTC-5, Mimmo Cosenza wrote: Hi

[ANN] Javelin, spreadsheet-like FRP for ClojureScript

2013-02-19 Thread Alan Dipert
Hi all, We recently released a ClojureScript library for FRP called Javelin. Links of interest: * Release announcement: http://tailrecursion.com/blog/2013/02/15/introducing-javelin-an-frp-library-for-clojurescript/ * Demos (more on the way): http://tailrecursion.com/~alan/javelin-demos

Re: Why is this so difficult?

2013-02-15 Thread Alan Shaw
Leiningen works on Windows. On Feb 15, 2013 8:32 AM, Phil Hagelberg p...@hagelb.org wrote: So for the record, the reason Leiningen doesn't work on Windows is primarily that Windows users spend a lot more time talking about how it doesn't work on Windows, and very little time actually making

Re: What compiles into a method body?

2013-02-04 Thread Alan Malloy
Basically each lambda compiles into a method body, and the size of its lexical environment doesn't matter very much, only the amount of code inside the lambda's (fully macroexpanded) body. So in (fn a [x] (foo (letfn [(b [] (bar)) (c [] (baz))])), a only pays for foo, and b and c pay for bar

Re: How to solve Collatz Conjecture problem for huge numbers using clojure parallelism tricks?

2013-02-01 Thread Alan Malloy
(max-key :power mario luigi) On Thursday, January 31, 2013 6:08:21 PM UTC-8, Leandro Moreira wrote: Running through this problem I also faced the weird situation, so: Given two maps (def mario {:color red :power 45}) (def luigi {:color green :power 40}) I want the max between both but

Re: why did lein just download Clojure 1.5?

2013-01-29 Thread Alan Malloy
`lein deps :tree` will show you the tree of dependencies, and you can see which of your dependencies has a bad dependency specification overriding the one in your project.clj. Typically it turns out a dependency is saying something like I must have the very latest Clojure, whatever that is,

Re: special case in binding vector syntax for function definitions?

2013-01-25 Thread Alan Malloy
In (let [[x :as y] [1 2]]), there is already an object to make y point to: the vector [1 2]. in ((fn [x :as y]) 1 2), there is no such object. On Friday, January 25, 2013 2:18:39 PM UTC-8, Ben wrote: Both of these work: user (let [[x y] [1 2]] [x y]) [1 (2)] user (let [[x :as y] [1 2]]

Re: Is keyword-params middleware safe?

2013-01-16 Thread Alan Malloy
Keywords are garbage-collected if no references to them exist. I think this is as of Clojure 1.3, but I'm not sure exactly; perhaps it's always been true. You can see it easily enough at https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/Keyword.java#L32 - there's a map from

Re: CLJS: protocol interfaces don't seem to support variable args in the arglist, like [ opts]

2013-01-16 Thread Alan Malloy
On Wednesday, January 16, 2013 11:17:41 AM UTC-8, Aaron Cohen wrote: On Wed, Jan 16, 2013 at 12:53 PM, Frank Siebenlist frank.si...@gmail.comjavascript: wrote: Thanks for the confirmation. I know that destructuring is supported in protocols as I'm using with much pleasure - kind of

Re: replacing specific symbols in arbitrary expressions

2013-01-14 Thread Alan Malloy
(clojure.tools.macro/symbol-macrolet [P +, M -, T *] ...) The tools.macro code-walker is much smarter and more careful than any that you or I will ever write. On Monday, January 14, 2013 3:31:40 AM UTC-8, Jim foo.bar wrote: Hi everyone, I hope you're all well! I recently faced a problem

Re: reduce, reduce-kv, map, mapv, reducers/map and nil

2013-01-07 Thread Alan Busby
On Tue, Jan 8, 2013 at 12:18 AM, Wolodja Wentland babi...@gmail.com wrote: On Thu, Nov 01, 2012 at 22:34 +0900, Alan Busby wrote: On Thu, Nov 1, 2012 at 8:27 PM, Wolodja Wentland babi...@gmail.com wrote: Oh, fold-into-map and fold-into-map-with would be wonderful and I tried

Re: clojurescript gensym does not generate a unique symbol?!

2013-01-04 Thread Alan Malloy
Certainly it does work the same way in JVM-Clojure: user= (gensym) G__1278 user= (gensym) G__1281 user= (gensym) G__1284 user= (= 'G__1287 (gensym)) true Whether that's a bug or a case of If it breaks when you do that, then don't do it isn't for me to say, but I would be pretty surprised to

ANN: Clevolution, evolutionary art in Clojure

2013-01-02 Thread Alan Shaw
Hi folks, My Clevolution project has been reimplemented using clisk, Mike Anderson's Clojure Image Synthesis Kit, greatly improving its speed and range of image-processing operations: http://nodename.github.com/clevolution/ -A -- You received this message because you are subscribed to the

Re: ANN: Clevolution, evolutionary art in Clojure

2013-01-02 Thread Alan Shaw
There is one thing that puzzles me: user= (clisk-eval (vround (vround x))) Error: java.lang.IllegalArgumentException: No matching method found: round Could be I'm just holding it wrong. -A On Wed, Jan 2, 2013 at 7:15 PM, Mikera mike.r.anderson...@gmail.com wrote: Cool project! I was

Re: reduce-kv incompatible with subvec

2012-12-28 Thread Alan Busby
than having to be written as special cases. Andy On Dec 27, 2012, at 8:54 PM, Alan Busby wrote: I'm confused why we'd need to give up O(1) just to support something like reduce-kv on subvectors. Isn't the implementation of subvector just a wrapper around the original vector along

Re: reduce-kv incompatible with subvec

2012-12-27 Thread Alan Busby
I'm confused why we'd need to give up O(1) just to support something like reduce-kv on subvectors. Isn't the implementation of subvector just a wrapper around the original vector along with a start and end value? Current source here;

Re: inserting code into reify methods

2012-12-24 Thread Alan Malloy
You don't need any of the typehints in your reify body. The compiler infers argument and return types from the interface definition. On Monday, December 24, 2012 5:35:35 AM UTC-8, nkonovalov wrote: Hi. I have a java interface. Something like this this. public interface ITest { void

Re: zip-reduce

2012-12-24 Thread Alan Malloy
Probably better to write it more generally, by creating a seq from a zipper and then just using the ordinary reduce function on that zip: (defn zip-seq [f acc z] (map node (tree-seq branch? children z))) (reduce f acc (zip-seq some-zipper)) On Monday, December 24, 2012 6:27:00 PM UTC-8, JvJ

Re: zip-reduce

2012-12-24 Thread Alan Malloy
Except of course zip-seq doesn't need the f, acc arguments. Sorry about that. On Monday, December 24, 2012 7:18:17 PM UTC-8, Alan Malloy wrote: Probably better to write it more generally, by creating a seq from a zipper and then just using the ordinary reduce function on that zip: (defn

Re: Little namespace question

2012-12-19 Thread Alan Shaw
:06 PM, Alan Shaw node...@gmail.com wrote: Thanks very much Juan, that's some good study material for me. -A On Dec 18, 2012 10:45 PM, juan.facorro juan.f...@gmail.com wrote: The macro sees it arguments as *symbols* and does not resolve to the corresponding *var* until evaluation, so

Re: Little namespace question

2012-12-19 Thread Alan Shaw
Oh! yes it does! -A On Wed, Dec 19, 2012 at 6:39 PM, Dave Ray dave...@gmail.com wrote: It does, right? On Wednesday, December 19, 2012, Alan Shaw wrote: But returning the evaluation was a requirement... On Wed, Dec 19, 2012 at 2:58 PM, Alan Shaw noden...@gmail.com wrote

Re: Little namespace question

2012-12-18 Thread Alan Shaw
) On Mon, Dec 17, 2012 at 11:53 PM, Alan Shaw noden...@gmail.com wrote: Oh yes, the something.something is fixed so I can just prepend it, thanks. (Hadn't noticed your macro takes the ns as a string!) -A On Mon, Dec 17, 2012 at 11:47 PM, Baishampayan Ghose b.gh...@gmail.comwrote: Alan

Re: Little namespace question

2012-12-18 Thread Alan Shaw
On Tue, Dec 18, 2012 at 1:38 PM, Alan Shaw noden...@gmail.com wrote: BG, The macro doesn't seem to do the trick. The function X is interned in the target namespace, but: user= (def image (eval-in (X 400 400) clevolution.version.version0-1-1)) CompilerException java.lang.RuntimeException

Re: Little namespace question

2012-12-18 Thread Alan Shaw
) user= (def image (eval-in (X 400 400) clevolution.version.version0-1-1)) #'user/image So it's OK to pass the explicit string but not the symbol. What am I not getting here? -A On Tue, Dec 18, 2012 at 12:48 AM, Alan Shaw noden...@gmail.com wrote: Now I do, and the macro worked! I believe I have

Re: Little namespace question

2012-12-18 Thread Alan Shaw
, 2012 at 12:48 AM, Alan Shaw node...@gmail.com wrote: Now I do, and the macro worked! I believe I have a problem using the macro from a function, but leaving that for tomorrow. Thanks BG! -A On Tue, Dec 18, 2012 at 12:19 AM, Baishampayan Ghose b.g...@gmail.comwrote: Do you have

Re: Little namespace question

2012-12-18 Thread Alan Shaw
As an aside, I'm curious about whether this could have been implemented without a macro. -A On Dec 18, 2012 11:06 PM, Alan Shaw noden...@gmail.com wrote: Thanks very much Juan, that's some good study material for me. -A On Dec 18, 2012 10:45 PM, juan.facorro juan.faco...@gmail.com wrote

Little namespace question

2012-12-17 Thread Alan Shaw
that string should be (read and) eval'ed so that the names will resolve to the appropriate functions. Advice on managing this would be appreciated. -Alan Shaw -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure

Re: Little namespace question

2012-12-17 Thread Alan Shaw
Ah no, that puts me in a new user-ns namespace! Not what I wanted! On Mon, Dec 17, 2012 at 10:51 PM, László Török ltoro...@gmail.com wrote: Try (in-ns 'user-ns) Las On Dec 18, 2012 7:50 AM, Alan Shaw noden...@gmail.com wrote: user= *ns* #Namespace user user= (def user-ns *ns*) #'user

Re: Little namespace question

2012-12-17 Thread Alan Shaw
part of your question I maybe able to help. Las Alan Shaw 2012. december 18., kedd napon a következőt írta: Ah no, that puts me in a new user-ns namespace! Not what I wanted! On Mon, Dec 17, 2012 at 10:51 PM, László Török ltoro...@gmail.comwrote: Try (in-ns 'user-ns) Las On Dec 18

Re: Little namespace question

2012-12-17 Thread Alan Shaw
Thanks BG, I'm trying that. But I don't think it addresses how to get from the string version-0-1-1 to the namespace something.something.version-0-1-1. How can I do that? -A On Mon, Dec 17, 2012 at 11:26 PM, Baishampayan Ghose b.gh...@gmail.comwrote: Alan, Something like this might work

Re: Little namespace question

2012-12-17 Thread Alan Shaw
Oh yes, the something.something is fixed so I can just prepend it, thanks. (Hadn't noticed your macro takes the ns as a string!) -A On Mon, Dec 17, 2012 at 11:47 PM, Baishampayan Ghose b.gh...@gmail.comwrote: Alan, What you're asking for is to derive the ns clojure.core given only core

Re: Confused about comp

2012-12-15 Thread Alan Malloy
Nonsense. Why would that be any faster? (join coll) is defined as (apply str coll). On Saturday, December 15, 2012 12:21:45 PM UTC-8, Marek Šrank wrote: ...which should be also a lot faster :) On Saturday, December 15, 2012 5:44:01 PM UTC+1, Armando Blancas wrote: (comp (partial apply str)

Re: Strange behaviour: nested def in proxy method body

2012-12-13 Thread Alan Malloy
On Thursday, December 13, 2012 4:14:23 AM UTC-8, Marshall Bockrath-Vandegrift wrote: kristianlm kris...@adellica.com javascript: writes: I'm enjoying testing Java code with Clojure and it's been a lot of fun so far. Coming from Scheme, the transit is comfortable. However, I

Re: Specific reduce function version

2012-12-09 Thread Alan Malloy
You seem to have written (reduce (fn [acc [a b]] ...) (partition 2 1 coll)). On Sunday, December 9, 2012 7:39:21 AM UTC-8, Alexander Semenov wrote: Hi, folks. I'm wondering if Clojure library has 'reduce' function version which is like (reduce f coll) - i.e. it applies function to coll

Re: Sorted Sets With Duplicate Elements

2012-11-20 Thread Alan Malloy
On Tuesday, November 20, 2012 10:29:18 AM UTC-8, Andy Fingerhut wrote: On Nov 20, 2012, at 10:12 AM, Mark Engelberg wrote: Clojure's sorted collections must be provided with a sorting function where items tie if and only if they are equal. (sorted-set-by #(compare [(second %) %]

Re: Difference between JVM and CLR when destructuring a lazy sequence

2012-11-15 Thread Alan Malloy
Binding to [ rst] must realize an element of the sequence, to determine if there are any left, and it promises to never bind (), only nil. On Thursday, November 15, 2012 7:23:05 AM UTC-8, ffailla wrote: I believe I have discovered differing behavior between the JVM and CLR implementations

Re: Proposed change to let- syntax

2012-11-15 Thread Alan Malloy
The primary point of let- is that you can insert it into an existing - pipeline. (- foo (stuff) (blah) (let- foo-with-stuff (for [x foo-with-stuff] (inc x))) Your proposal breaks this. On Thursday, November 15, 2012 10:35:59 AM UTC-8, Alex Nixon wrote: Hi all, I

Re: How to get the namespace for an unqualified symbol?

2012-11-12 Thread Alan Malloy
Yikes! Try ((juxt (comp ns-name :ns) :name) (meta (resolve 'inc))) - name information is stored on the var's meta in a clojure-friendly way - no need to use undocumented behavior on the java internals. On Monday, November 12, 2012 11:05:15 AM UTC-8, Ambrose Bonnaire-Sergeant wrote: Evil, but

Re: Proposal/request: Give clojure.core/conj a unary implementation

2012-11-03 Thread Alan Malloy
There is never a reason to write (apply conj ...). Instead, use `into`, which does the same thing but faster and with fewer characters. On Saturday, November 3, 2012 3:27:24 PM UTC-7, CGAT wrote: It would be nice if clojure.core/conj had a unary implementation ([coll] coll) The

Re: reduce, reduce-kv, map, mapv, reducers/map and nil

2012-11-01 Thread Alan Busby
On Mon, Oct 29, 2012 at 10:00 PM, Wolodja Wentland babi...@gmail.com wrote: I find this behaviour quite unfortunate because I now have to explicitly test for nil? and ensure consistent behaviour. This inconsistency violates the principle of least-surprise and I am not sure if the current

Re: reduce, reduce-kv, map, mapv, reducers/map and nil

2012-11-01 Thread Alan Busby
On Thu, Nov 1, 2012 at 8:27 PM, Wolodja Wentland babi...@gmail.com wrote: It seems to me as if we are currently figuring out which (boilerplate?) functions are missing in reducers.clj and that we will have a nice and well-integrated library at the end. To be fair, it's in beta and it's open

Re: downcast

2012-10-24 Thread Alan Malloy
Clojure doesn't care about casting, so you can ignore this issue entirely. But also, it's not an issue: the same code would fail in Java, because Clojure's integer literals are Long, not Integer. (cast Long (cast Number 1)) would work fine. On Oct 24, 2:12 pm, Steffen Panning

Re: Replacing nested let statements with assignments

2012-10-18 Thread Alan Malloy
It's rare to get tired of this, because nobody does it: it's not common because your interleaved statements are side-effecting only, which is not encouraged in Clojure, and rarely needed. Certainly sometimes it's the best way to do something, but not so often that I'd become frustrated; if

Re: Replacing nested let statements with assignments

2012-10-18 Thread Alan Malloy
On Oct 18, 12:02 pm, David Nolen dnolen.li...@gmail.com wrote: On Thu, Oct 18, 2012 at 2:55 PM, Alan Malloy a...@malloys.org wrote: It's rare to get tired of this, because nobody does it: it's not common because your interleaved statements are side-effecting only, which is not encouraged

Re: Redubicle NIO

2012-10-18 Thread Alan Malloy
As a general-macro aside, you are multiply-evaluating the `f` argument, by expanding it in-place inside the recursive clause. This is almost certainly not what you want, and you could avoid it by starting with (let [f# ~f] ...). Better still, ask why this is a macro at all. This should really just

Re: trampoline not compatible with reducers?

2012-10-16 Thread Alan Malloy
Reducers don't enter into the picture at all: this code is just as broken with clojure.core/reduce and clojure.core/map. The immediate problem that Kevin is trying to draw your attention to is that you are calling (reduce max (map my-fn coll)), where my-fn sometimes returns a number, and sometimes

Re: parallel alpha-beta pruning possible?

2012-10-16 Thread Alan Malloy
You will get better results from a game-programming forum, or indeed from a google search for parallel alpha beta than from a bunch of clojure guys with no particular experience in your problem domain. On Oct 16, 1:27 pm, Jim - FooBar(); jimpil1...@gmail.com wrote: After watching this

Re: Evaluating an anonymous function with closure

2012-10-15 Thread Alan Malloy
Evaluating function literals is not intended to work; that it works for non-closure functions should be treated as a coincidence. On Oct 15, 2:19 am, Gergely Szabó gergel...@gmail.com wrote: Hello, could someone please explain the behavior that is shown in the gist below?

Re: Evaluating an anonymous function with closure

2012-10-15 Thread Alan Malloy
Evaluating function literals is not intended to work; that it works for non-closure functions should be treated as a coincidence. On Oct 15, 2:19 am, Gergely Szabó gergel...@gmail.com wrote: Hello, could someone please explain the behavior that is shown in the gist below?

Re: Evaluating an anonymous function with closure

2012-10-15 Thread Alan Malloy
On Oct 15, 1:07 pm, Jim - FooBar(); jimpil1...@gmail.com wrote: On 15/10/12 19:42, Ben Smith-Mannschott wrote: If the distinction I'm trying to make is not clear to you, I'd suggest having a look athttp://www.infoq.com/presentations/Clojure-Macros (It does a good job exploring these kinds

Re: Intern a var from outside namespace

2012-10-11 Thread Alan Malloy
On Thursday, October 11, 2012 9:03:38 PM UTC-7, David Jacobs wrote: I would like to create function names programmatically. So far, I have code that works: ... Where am I going wrong? David Sentence one. Don't do it that way: namespaces are not very good hashmaps, but hashmaps are

Re: apply: increase performance by 60% for fixed length

2012-10-07 Thread Alan Malloy
This is nonsense. If s is fixed-size at compile-time, you would never use apply to begin with. Why bother with (applyn 10 + [1 2 3 4 5 6 7 8 9 10]) when you could just write (+ 1 2 3 4 5 6 7 8 9 10)? On Sunday, October 7, 2012 2:15:28 PM UTC-7, Marc Dzaebel wrote: *apply *is slow. However you

Re: comp inside macro

2012-09-26 Thread Alan Malloy
(a) There's no reason for this to be a macro at all: you don't need to prevent evaluation of anything, and you don't need to transform any syntax. Just write a function: (defn asdf [ {:keys [a]}] (println (comp (partial + 1) a))) (b) To make this a macro, just be more careful about what you

Re: Nested functions on #() reader

2012-09-17 Thread Alan Malloy
Indeed, there's no need for anything to be a reader macro, except concision. You can write this as an ordinary macro, eg, (crazy-fn %a %%b %%%c). If you try that and find it's awesome, share it with others. If it's universally loved, perhaps someday it could be a reader macro. On Monday,

Re: Sort and Java 1.7

2012-09-12 Thread Alan Malloy
Vote to close as not a real question. The signature of java.util.Collections/sort hasn't changed since 1.5, when generics were introduced, and it should still be basically compatible with what it was when it was introduced in 1.2. On Wednesday, September 12, 2012 5:54:22 AM UTC-7,

Can't start Rhino repl for ClojureScript

2012-09-08 Thread Alan Shaw
Hi, Any help wd be appreciated; this is what happened (environment is Cygwin on win7): $ lein2 trampoline cljsbuild repl-rhino Running Rhino-based ClojureScript REPL. (do (require (quote cljsbuild.repl.rhino)) (do (clojure.core/ns leiningen.core.injected) (defn- compose-hooks [f1 f2] (fn [ args]

Re: using take-while with pred function that has state

2012-09-03 Thread Alan Malloy
(map #(do %2 %1) c1 c2) is a neat trick I hadn't seen in this context; thanks for showing me! On Sunday, September 2, 2012 10:26:07 PM UTC-7, Stephen Compall wrote: On Fri, 2012-08-31 at 05:08 -0700, shaobohou wrote: I have written the following function using take-while and a pred

Re: reporting function inputs as part of exceptions

2012-09-03 Thread Alan Malloy
Slingshot's throw+ generates an exception object that includes, among other things, all the locals in the context of your throw. On Monday, September 3, 2012 9:03:42 PM UTC-7, Timothy Pratley wrote: I'm working on a project where it would be quite convenient to have the input values to the

Re: [emacs over ssh limitations]

2012-08-29 Thread Alan Busby
On Tue, Aug 28, 2012 at 10:29 PM, Stuart Sierra the.stuart.sie...@gmail.com wrote: SSH in iTerm 2 from an OS X machine to a Linux server. $TERM is xterm-256color at both ends. We use this for pair-programming, so X and tramp are not helpful. To support what Tim said, after killing an afternoon

Re: [emacs over ssh limitations]

2012-08-29 Thread Alan Busby
On Thu, Aug 30, 2012 at 1:13 AM, Phil Hagelberg p...@hagelb.org wrote: Alan Busby thebu...@thebusby.com writes: To support what Tim said, after killing an afternoon I got iTerm2 from OSX to play nice with an Emacs in gnu screen on a remote Linux host. All keys and combos were working

Re: Howto not reindent in (emacs) clojure-mode

2012-08-26 Thread Alan Malloy
I just use C-j instead of RET in the rare cases that I want to leave the previous line alone. On Sunday, August 26, 2012 4:15:54 PM UTC-7, frye wrote: Hey all, There'll probably be a quick solution to this. But I have emacs with clojure-mode installed. And it has this very annoying

Re: clojure.logic project.clj file

2012-08-15 Thread Alan Malloy
Blech. I've found having the project.clj helpful myself for the same reason David has: it's easy to start up lein (swank or repl) and hack around. I'm opposed to removing it unless there's someone it's actually hurting. On Wednesday, August 15, 2012 3:00:27 PM UTC-7, Sean Corfield wrote: On

Re: Pattern of Succinctness

2012-08-12 Thread Alan Malloy
This doesn't work. On Sunday, August 12, 2012 12:44:11 PM UTC-7, Pierre-Henry Perret wrote: I prefer (filter (partial not nil?) coll) as a HOF Le dimanche 12 août 2012 20:46:59 UTC+2, rmarianski a écrit : On Sun, Aug 12, 2012 at 11:22:55AM -0700, Takahiro Hozumi wrote: (filter

<    1   2   3   4   5   6   7   8   9   10   >