Re: clojure.data.csv/write-csv isn't thread safe (should it be?)

2019-05-02 Thread Michael Gardner
Note that clojure.core/println is also not "thread-safe" in that sense: two threads doing `(println "foo" "bar")` may produce interleaved output. > On May 2, 2019, at 05:59, matt.t.gr...@gmail.com wrote: > > The write-csv function in clojure.data.csv isn't thread safe because even > though it

Re: Keyword namespacing best practices

2018-10-01 Thread Michael Gardner
> On Sep 30, 2018, at 23:41, Alan Thompson wrote: > > It is easy to overdo it when trying to predict future needs. I always (now) > do the minimal solution, with the expectation that it *may* evolve in the > future. Normally I'd agree: YAGNI is great for functionality that can be added

Re: Keyword namespacing best practices

2018-09-30 Thread Michael Gardner
> On Sep 30, 2018, at 18:54, Eric Lavigne wrote: > > I would not use keyword namespaces in this situation. Users of the "fetch" > function will likely type :timeout, :status, and :body when using this > function. Keyword namespaces would just force users to type longer names for > these.

Keyword namespacing best practices

2018-09-30 Thread Michael Gardner
I'm looking for some feedback on keyword namespacing. Say you're writing an API to be used by external clients that works something like this: (fetch url :timeout 10) => {:status 200, :body "..."} Would you namespace the :status and :body keywords in the response? What about the :timeout kwarg

Re: case bug

2018-07-24 Thread Michael Gardner
As its docstring states, the `case` macro doesn't evaluate its test-constants. It only works on compile-time constants (e.g. literal strings/numbers), to allow O(1) matching. You want `condp` instead. -- You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: [ANN and RFC] Bifurcan: impure functional data strucures

2017-03-27 Thread Michael Gardner
> On Mar 27, 2017, at 09:51, Zach Tellman wrote: > > They also provide high-performance mutable variants of the data structure > which share an API with their immutable cousins. How does their performance compare to Clojure's transients? Transients are slower than Java's

Re: Clojure.spec, maps, restrict valid keywords, easier way?

2017-02-02 Thread Michael Gardner
What would be the Right Way to deal with typos like (fetch-important-data {:encypt true}), where the :encrypt key is optional? Timothy mentions auto-complete, which is better than nothing but doesn't feel like a real solution (especially to those who don't use auto-complete). > On Feb 2, 2017,

Re: Help me understand what part of this code is slow, and how to make it faster?

2016-11-16 Thread Michael Gardner
Below is the fastest version I tested, using ideas from the various responses in this thread. It runs in ~4s on my machine, compared with ~27s for the original version. The biggest win by far was from James Reeves' suggestion of switching to Java's mutable HashSet. I'm not sure why; I'd

Re: Thoughts on clojure.spec

2016-07-10 Thread Michael Gardner
It might be possible to leverage something like American Fuzzy Lop[1] for better random input generation. I've never used AFL myself, but I know SQLite (one of the best-tested libraries I know of) has had good success with it[2], and it does work on Java. [1] http://lcamtuf.coredump.cx/afl/

Rationale for `keys` not supporting vectors?

2016-07-08 Thread Michael Gardner
I've looked around, but couldn't find any discussion on the topic. Is it purely an implementation thing, or a design choice? (Yes, I realize you can just do (range (count v)).) -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group,

Re: apply madness

2016-05-12 Thread Michael Gardner
There's no need to avoid `apply` altogether, IMO. You could do something like this: (let [raw (list :a 1 :b 2 :c 3)] (into {:raw raw} (filter (comp even? second) (apply hash-map raw BTW, `list` is pretty uncommon. Usually you'd just use a vector literal. And this is

Re: Are strings vectors? Should 'get' docstring be changed?

2016-04-21 Thread Michael Gardner
On Apr 21, 2016, at 10:04, James Reeves wrote: > > Clojure seems to avoid having functions that have variable performance > depending on the data structure they're applied to. But not always! (e.g. count) -- You received this message because you are subscribed to the

Re: Reducing the pain of a clojars outage

2016-01-02 Thread Michael Gardner
> On Jan 2, 2016, at 10:27, Toby Crawley <t...@tcrawley.org> wrote: > > On Sat, Jan 2, 2016 at 12:47 AM, Michael Gardner <gardne...@gmail.com> wrote: >> >> I would caution against this approach. An attacker could easily target >> specific organizati

Re: Reducing the pain of a clojars outage

2016-01-01 Thread Michael Gardner
> On Jan 1, 2016, at 21:31, Toby Crawley wrote: > > But if we had a regular >process that crawled all of the mirrors and the canonical repo to >verify that the checksums every artifact are identical, this could >actually improve security, since we could detect if

Re: Style, Efficiency, and updating nested structure

2015-11-11 Thread Michael Gardner
- Worrying about the performance of a small, pure function like this is almost certainly premature optimization. - Avoid concurrency constructs like atoms if you don't need them. - Have you considered using group-by? > On Nov 11, 2015, at 13:25, Dave Tenny wrote: > > A

Re: Clojure/Pedestal vs Go

2015-09-15 Thread Michael Gardner
On Sep 15, 2015, at 20:45, Mikera wrote: > > 7. The open source library ecosystem on the JVM is awesome. There's nothing > like it for any other language. I like your other points, but in my experience this one is (arguably) no longer true. I've often found the

Single-atom update ordering guarantees

2015-06-09 Thread Michael Gardner
This might be blindingly obvious to some, but I can't find any discussion about it. Let's say I have code like the following: (def a (atom 1)) ... (swap! a inc) (swap! a dec) Is there any possibility of another thread seeing a=0? If not, what provides this guarantee? -- You received this

Re: Single-atom update ordering guarantees

2015-06-09 Thread Michael Gardner
from 1 to 2, then from 2 back to 1. Andy On Tue, Jun 9, 2015 at 9:38 AM, Atamert Ölçgen mu...@muhuk.com wrote: On Tue, Jun 9, 2015 at 7:30 PM, Michael Gardner gardne...@gmail.com wrote: This might be blindingly obvious to some, but I can't find any discussion about it. Let's say I

Re: Single-atom update ordering guarantees

2015-06-09 Thread Michael Gardner
declared volatile. I don't have a good authoritative link handy for Java documentation on volatile, but the basic idea is that they should not be cached locally by individual threads, but be visible to all. Andy On Tue, Jun 9, 2015 at 11:33 AM, Michael Gardner gardne...@gmail.com wrote

Identifying dependency that's pulling in SLF4J

2015-06-08 Thread Michael Gardner
I've started to see unwanted SLF4J console messages from one of my projects. I'm not (directly) using SLF4J, and would like to find out which of my dependencies is. But the dependency tree is a bit large to search by hand. Is there a better way? -- You received this message because you are

Re: Identifying dependency that's pulling in SLF4J

2015-06-08 Thread Michael Gardner
On Jun 8, 2015, at 10:30 AM, Stephen Gilardi scgila...@gmail.com wrote: Does “lein deps :tree” help? Yes, that's very helpful. 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

Re: contains? on String

2015-05-12 Thread Michael Gardner
On May 12, 2015, at 1:54 PM, Shantanu Kumar kumar.shant...@gmail.com wrote: I agree about the counter-intuitiveness. I'm only wondering whether the error message is a bit misleading contains? not supported on type: java.lang.String because of course (contains? hello 2) works fine. It seems

Re: contains? on String

2015-05-12 Thread Michael Gardner
On May 12, 2015, at 3:28 PM, Fluid Dynamics a2093...@trbvm.com wrote: Strings and arrays support constant-time access by index. Yes, but why should that mean that contains? should work on Strings? Because it can doesn't seem compelling to me. In discussions about contains?, one often hears

Re: How to coerce to bigint ?

2015-04-04 Thread Michael Gardner
On Sat, Apr 4, 2015 at 11:36 AM, Paul Roush pro...@gmail.com wrote: (range 5N) = (0 1 2 3 4) ; i.e. the bigint-ness is lost So in this particular case I needed to inject bigint into the process later in some way. You could try (range (* 0 n) n). A little silly, but does avoid the

Re: Set equality bug?

2015-01-23 Thread Michael Gardner
On Jan 23, 2015, at 8:23 AM, Andy Fingerhut andy.finger...@gmail.com wrote: You can try creating a JIRA ticket suggesting that Clojure's = should return false when comparing floats and doubles to each other. CLJ-1649, for anyone interested. -- You received this message because you are

Re: Set equality bug?

2015-01-23 Thread Michael Gardner
On Jan 23, 2015, at 11:51 AM, Andy Fingerhut andy.finger...@gmail.com wrote: Hash consistency is certainly nice, but if Clojure were changed such that (= float-val double-val) were always false, and no other changes were made, it would lead to this situation: user= (= (float 1.5) (double

Re: Set equality bug?

2015-01-23 Thread Michael Gardner
I'm sure we are all aware of the various issues with floating point math (particularly equality comparisons); however none of that is relevant to this discussion. The only issue here is an inconsistency between hashing and equality testing in Clojure. My claim is that the property any two

Re: Set equality bug?

2015-01-23 Thread Michael Gardner
On Jan 23, 2015, at 1:33 AM, Immo Heikkinen immo.heikki...@gmail.com wrote: I actually ran into this while comparing nested data structures from two different sources and spent a good part of my day figuring out what's happening. While it is a good advice to avoid mixing floats and doubles,

Re: Set equality bug?

2015-01-23 Thread Michael Gardner
If there's a technical reason why Clojure can't return false for all = comparisons between floats and doubles, I'd like to hear it. Otherwise, I don't see how your response is relevant. On Jan 23, 2015, at 3:10 AM, Luc Prefontaine lprefonta...@softaddicts.ca wrote: Agree, it's broken...

Re: [ANN] Clojure 1.7.0-alpha2

2014-09-06 Thread Michael Gardner
Great stuff, and thanks for all the hard work. But if I may, I'd like to suggest that completing isn't a great name for that transducer helper function-- at least not in the core namespace. It's too generic: there's no way to guess what it does from the name, and IMO a function with such a

Re: what's the elegant way to write this code in clojure?

2014-04-18 Thread Michael Gardner
On Apr 18, 2014, at 09:05 , sd song sd.s...@gmail.com wrote: another question is: i think code like: (if (nil? page) lmt page) is ugly. is there some functions in clojure like (get_default_value_3_if_a_is_null a 3) ? If you're OK with false being treated the same as nil, you can do (or page

Re: boolean problem

2014-04-17 Thread Michael Gardner
On Apr 17, 2014, at 02:34 , Tassilo Horn t...@gnu.org wrote: And now you have an if without then which will give you another exception. Not true. It's more common to use 'when', but single-branch ifs are perfectly fine. -- You received this message because you are subscribed to the Google

Re: boolean problem

2014-04-17 Thread Michael Gardner
On Apr 17, 2014, at 07:38 , Tassilo Horn t...@gnu.org wrote: Michael Gardner gardne...@gmail.com writes: And now you have an if without then which will give you another exception. Not true. It's more common to use 'when', but single-branch ifs are perfectly fine. Yes

Re: creating a map

2014-03-26 Thread Michael Gardner
For reasons unclear to me, (into {} ...) expects a sequence of 2-element *vectors*, not just 2-element collections. partition returns a seq of lists, not vectors, which is why you're getting that exception. You could try (into {} (map vec (partition 2 2 12))) instead. On Mar 26, 2014, at 15:36

Re: XOR two arrays into a third on Clojure

2014-03-13 Thread Michael Gardner
Might be slow because of the polymorphic nature of nth. If you replace nth with aget (and turn on *warn-on-reflection*, which is a good idea when performance-tuning), you'll get reflection warnings because Clojure doesn't know what Java method to use since it doesn't know what type of objects a

Re: XOR two arrays into a third on Clojure

2014-03-13 Thread Michael Gardner
On Mar 13, 2014, at 07:34 , Alex Miller a...@puredanger.com wrote: Agreed with all the comments on this so far. I would also say that dotimes is slower than loop for stuff like this so I would also make that change. The dotimes version is slightly faster on my hardware. Why would it be

Re: Comparing Regular Expression pattens for equality?

2014-02-26 Thread Michael Gardner
You can compare the output of the .pattern or .toString methods if all you care about is finding regexes made from the exact same patterns. There's no simple way to detect equivalent regexes made from different patterns, though. As for why = doesn't do this, you'd have to talk to the Java folks

Re: Function that weaves two collections together - looking for feedback

2014-02-18 Thread Michael Gardner
You may be interested in the core function 'interleave'. As for (into []), it's perfectly idiomatic as long as you actually need to return a vector and not just some kind of sequence (the more common case). But note also the mapv/filterv/reduce-kv family of functions, though they're not

Re: [ANN] Clojure 1.6.0-beta1

2014-02-14 Thread Michael Gardner
On Feb 14, 2014, at 17:25 , Alex Miller a...@puredanger.com wrote: The names of these functions were chosen by Rich. There was already some name overloading of some even before these new functions with some (truthy) and some-/some- (not nil). The new functions keep with the latter meaning.

Re: range-sum

2014-02-13 Thread Michael Gardner
On Feb 13, 2014, at 08:56 , Stuart Sierra the.stuart.sie...@gmail.com wrote: No. Clojure's `apply` is lazy. Varargs are passed to the function as a lazy sequence, and it's up to the function to realize them or not. It's worth noting (for people who might try to rely on that laziness) that

Re: range-sum

2014-02-13 Thread Michael Gardner
On Feb 13, 2014, at 14:31 , Michael Gardner gardne...@gmail.com wrote: On Feb 13, 2014, at 08:56 , Stuart Sierra the.stuart.sie...@gmail.com wrote: No. Clojure's `apply` is lazy. Varargs are passed to the function as a lazy sequence, and it's up to the function to realize them

Re: range-sum

2014-02-13 Thread Michael Gardner
On Feb 13, 2014, at 15:17 , Mauricio Aldazosa mauricio.aldaz...@ciencias.unam.mx wrote: My guess is that when using a rest-param a call to next is involved thus realizing two elements of the sequence. A destructured vararg is nil when there are no more items, which indeed requires realizing

Re: map semantics

2014-02-08 Thread Michael Gardner
On Feb 8, 2014, at 15:14 , Andy C andy.coolw...@gmail.com wrote: It all boils down this: is it possible to have two clojure.lang.PersistentHashSet with identical values (in mathematical sense) but producing different seqs? Are you serious? The entire point of the email you responded to was

Re: map semantics

2014-02-07 Thread Michael Gardner
On Feb 7, 2014, at 22:17 , Andy C andy.coolw...@gmail.com wrote: Having map to produce a lazy seq implies that the input must be serializable (or linear). That's just what map is in Clojure: an operation on sequences. It works on various concrete types because those can be viewed as

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-30 Thread Michael Gardner
On Jan 30, 2014, at 01:36 , Steffen steffen.die...@gmail.com wrote: If you would like to use a specific codec other than :byte or :ubyte but also restrict the number of bytes read this would only work if you expected to have some kind of optional padding after your objects, like:

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-30 Thread Michael Gardner
On Jan 30, 2014, at 08:10 , Steffen Dienst steffen.die...@gmail.com wrote: That's exactly what padding is designed to do: Let's say you know there is a run of bytes with a known length (from a header field maybe) and you want to parse an unbounded number of objects within this area. You

Re: ANN: Another binary parser combinator - this time for java's streams

2014-01-29 Thread Michael Gardner
Looks good! A few questions: 1) Is it possible to specify a byte length for a 'repeated codec, rather than a number of objects? 2) Would you consider an enum type, for convenience? Something like: (defn enum [type m] (compile-codec type m (clojure.set/map-invert m))) 3) In the

Re: [ANN] Buffy, The Byte Buffer Slayer 1.0.0-beta1

2014-01-28 Thread Michael Gardner
I'm looking to deal with a stream of data that includes a structured, variable-length header followed by a (potentially large) binary blob. I'd like to parse only the header while leaving the stream (can be a java stream or NIO channel, whichever works best) positioned at the start of the

Re: [Large File Processing] What am I doing wrong?

2014-01-21 Thread Michael Gardner
On Jan 21, 2014, at 07:11 , Chris Perkins chrisperkin...@gmail.com wrote: This part: (some #{hashed} already-seen) is doing a linear lookup in `already-seen`. Try (contains? already-seen hashed) instead. Or just (already-seen hashed), given that OP's not trying to store nil hashes. To OP:

Re: clojure.java.shell/sh and expand wildcard

2014-01-21 Thread Michael Gardner
Try (sh “bash” “-c” “ls *.txt”). On Jan 21, 2014, at 21:51 , John Gabriele jmg3...@gmail.com wrote: I'd like to do something like: user= (require '[clojure.java.shell :as sh]) user= (sh/sh ls *.txt) but get: {:exit 2, :out , :err ls: cannot access *.txt: No such file or

Re: Clojure development laptop battery usage

2014-01-20 Thread Michael Gardner
On Jan 20, 2014, at 11:14 , Mars0i marsh...@logical.net wrote: Just to be clear, Leiningen only eats CPU when started in an arbitrary directory. When started from a Leiningen project directory, it doesn't use CPU unless I tell it to. I have not investigated what it is in the project

Re: [ANN] play-clj, a game library

2014-01-20 Thread Michael Gardner
On Jan 20, 2014, at 09:31 , Zach Oakes zsoa...@gmail.com wrote: Today I'm releasing play-clj, a Clojure wrapper for LibGDX that allows you to write games for desktop OSes, Android, and iOS from the same Clojure codebase. Neat! How is Clojure’s performance on the latest Android devices? Good

Re: Contributors needed for Rouge (Clojure on Ruby)

2014-01-04 Thread Michael Gardner
On Jan 4, 2014, at 11:52 , gvim gvi...@gmail.com wrote: This looks like the best of the scripting language implementations of Clojure in that it attempts to match the JVM implementation on PyPy. Sadly, however, there doesn't seem to have been any activity since last April so it may be a

Re: Finding available methods or docs for a value type

2013-12-24 Thread Michael Gardner
On Dec 24, 2013, at 07:58 , John Kida jdk...@gmail.com wrote: Or is there some technique I can use in the repl to tell me what methods are available to work with this particular datastructure.. that sounds not possible due to the dynamic lisp nature of clojure, but I wanted to ask the

Re: Breaking out of a map type function

2013-11-24 Thread Michael Gardner
On Nov 24, 2013, at 10:19 , David Simmons shortlypor...@gmail.com wrote: I wish to process each item in a vector. I know I can use map to do this e.g. (map my-func my-vector). My problem is that I need to be able to break out of the map if my-func returns an error when processing any of the

Re: Potential improvement to select-keys ?

2013-11-01 Thread Michael Gardner
On Nov 1, 2013, at 14:18 , Mark Engelberg mark.engelb...@gmail.com wrote: I'm sure it's possible to imagine both needs, but if you have have a sorted-map, and you do a select-keys, don't you think the principle of least surprise is for it to stay a sorted-map? I'm not sure about that, given

Re: Request for help optimising a Clojure program

2013-10-23 Thread Michael Gardner
On Oct 23, 2013, at 12:30 , Andy Fingerhut andy.finger...@gmail.com wrote: If you can think of a different hash function for vectors that doesn't lead to these types of collisions, I'm all ears. The issue is that the hash function for sets adds up the hash values of its elements. Those

Re: Request for help optimising a Clojure program

2013-10-23 Thread Michael Gardner
On Oct 23, 2013, at 14:34 , Mark Engelberg mark.engelb...@gmail.com wrote: Another example of why this has more to do with the hashing of sets, than underlying elements: = (hash #{#{1 2} 3}) 6 = (hash #{#{1 3} 2}) 6 The hash-combining function for sets must be commutative. But in order

Re: Request for help optimising a Clojure program

2013-10-23 Thread Michael Gardner
On Oct 23, 2013, at 17:03 , Mark Engelberg mark.engelb...@gmail.com wrote: It is true that it must be commutative, but not true that it must be non-associative. Here is a sample implementation of a hash function for sets that is commutative and associative but doesn't collide for these

Re: tools for minimizing forward declaration

2013-08-19 Thread Michael Gardner
On Aug 19, 2013, at 06:38 , Tim Visher tim.vis...@gmail.com wrote: The most annoying thing to me about forward declaration is that it prevents what Uncle Bob calls 'Newspaper Style Code' where I can structure my code in such a way that the high-level functions are right at the top and the

Re: Wrong documentation of contains?

2013-08-07 Thread Michael Gardner
Wouldn't changing collection to associative collection be enough? Though maybe a note about its behavior on vectors would also be good. On Aug 7, 2013, at 11:15 , Mark Engelberg mark.engelb...@gmail.com wrote: Yes, the discussion about contains? has come up before, but there's a new aspect

Re: putting 2-element colls into a map: works with vectors, but not with lists?

2013-06-25 Thread Michael Gardner
On Jun 25, 2013, at 15:03 , Michael-Keith Bernard (SegFaultAX) mkbernard@gmail.com wrote: https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/APersistentMap.java#L24 The implementation assumes you're attempting to conj one of the following 3 things into the hash map:

Re: putting 2-element colls into a map: works with vectors, but not with lists?

2013-06-24 Thread Michael Gardner
On Jun 24, 2013, at 11:14 , Sean Corfield seancorfi...@gmail.com wrote: On Mon, Jun 24, 2013 at 8:49 AM, John Gabriele jmg3...@gmail.com wrote: Why does `into` fail when the 2-element collections are lists and not vectors? : Because the implementation special cases vectors :) It's the

Re: lazy sequence termination

2013-05-28 Thread Michael Gardner
On May 28, 2013, at 15:05 , Mond Ray mondraym...@gmail.com wrote: Quite a few views but no bites ... what have I done wrong in asking this question? If you can't help with the problem would you please take a moment to help me understand what has put you off? It would help to post less

Re: noob question about try/catch

2013-04-26 Thread Michael Gardner
On Apr 26, 2013, at 10:01 , larry google groups lawrencecloj...@gmail.com wrote: java.lang.RuntimeException: java.sql.SQLException: Cannot convert value '-00-00 00:00:00' from column 6 to TIMESTAMP. I believe Clojure is wrapping the java.sql.SQLException in a java.lang.RuntimeException

Re: noob question about try/catch

2013-04-26 Thread Michael Gardner
On Apr 26, 2013, at 11:55 , Michael Gardner gardne...@gmail.com wrote: I believe Clojure is wrapping the java.sql.SQLException in a java.lang.RuntimeException because of reasons[1][2], so you'd need to catch java.lang.RuntimeException and examine the exception's cause property to get

Re: merge nested maps

2013-04-25 Thread Michael Gardner
On Apr 25, 2013, at 15:41 , Joachim De Beule joachim.de.be...@gmail.com wrote: I was searching for an easy way to combined nested maps, e.g. as in (combine {:foo {:bar baz}} {:foo {:x y}}) = {:foo {:bar baz, :x y}} user= (merge-with merge {:foo {:bar baz}} {:foo {:x y}}) {:foo {:x y, :bar

Re: Parallelizing tasks

2013-04-11 Thread Michael Gardner
On Apr 10, 2013, at 21:46 , Ulises ulises.cerv...@gmail.com wrote: Have you tried replacing all your calls to map for pmap yet? That will not work. He'll need to rearrange his algorithm to something like this before pmap will help: (defn iterated-difference [f a b] Yields a lazy seq of

Re: how can I count lines of code?

2013-03-27 Thread Michael Gardner
On Mar 27, 2013, at 14:36 , larry google groups lawrencecloj...@gmail.com wrote: I am curious, is there a simple command line script I could use to count lines of code? Or is there some trick in emacs that I can do? I'd like to know how many lines there are, minus the comments and white

Re: Get difference between two lists with java objects of same class

2013-03-12 Thread Michael Gardner
On Mar 11, 2013, at 17:09 , Ryan arekand...@gmail.com wrote: What if, i had two clojure lists, with hash-maps which have the same keys and based on a specific key, i wanted to find the items from list-a which do not exist in list-b. Would i go with the two functions you suggested or is there

Re: Get difference between two lists with java objects of same class

2013-03-12 Thread Michael Gardner
On Mar 12, 2013, at 04:11 , Marko Topolnik marko.topol...@gmail.com wrote: This is almost exactly the same as the one from an earlier post here: (remove (comp (into #{} (map key-fn list-b)) key-fn) list-a) I'd prefer remove to filter + complement, though. Ah, I should have read the rest

Re: contains? for vectors

2013-03-01 Thread Michael Gardner
On Feb 28, 2013, at 17:17 , AtKaaZ atk...@gmail.com wrote: According to this, can a vector have keys that are not numbers? like :a , if not, then wouldn't it make more sense that (contains? [:a :b :c] :a) would throw ? It's probably just me. This is a reasonable point, and one I haven't

Re: contains? for vectors

2013-03-01 Thread Michael Gardner
On Mar 1, 2013, at 13:36 , AtKaaZ atk...@gmail.com wrote: I don't think I understand what you mean (could you rephrase/example?), I cannot think of a case when I wouldn't want it to throw when I'm passing a non-number (contains? [:a :b :c] :a), I mean, rather than just silently ignoring.

Re: contains? for vectors

2013-02-28 Thread Michael Gardner
This is a sore spot that has been discussed many times on this list[1]. The short version is that many people agree that the name contains? is misleading to newcomers, but according to Rich it's not changing any time soon[2]. What you want for linear searches is 'some (as mentioned in the doc

Re: Clojure Performance For Expensive Algorithms

2013-02-24 Thread Michael Gardner
On Feb 24, 2013, at 10:46 , Marko Topolnik marko.topol...@gmail.com wrote: from what I hear, idiomatic Haskell is a performance devil as well Does this mean very good, or very bad? On a related note, is there currently any way to get the Clojure compiler to tell you where boxing is occurring,

Re: clojure API documentation

2013-01-29 Thread Michael Gardner
On Jan 29, 2013, at 11:42 , cej38 junkerme...@gmail.com wrote: Should these symbols be added to the documentation? The dot is documented at http://clojure.org/java_interop#dot -- which you'll be pointed to if you try (doc .) at a repl. It's also linked from http://clojure.org/special_forms.

Re: [ANN] vectorz-clj - high performance vector maths for Clojure

2012-12-03 Thread Michael Gardner
On Dec 2, 2012, at 06:24 , Mikera mike.r.anderson...@gmail.com wrote: Contributions / comments / suggestions very welcome. API is not yet set in stone, so I'm very open to ideas on how to make it better. Since the vast majority of physical applications will use 2D or 3D vectors, did you

Re: Can anyone explain this behavior of clojure.java.shell/sh ?

2012-11-09 Thread Michael Gardner
I can't duplicate your results on my Debian wheezy box (Clojure 1.4, openjdk 1.6.0_24, xdg-open 1.1.0 rc1); the call to (sh xdg-open …) returns immediately. The only possibilities I can think of are that your version of xdg-open blocks when run from a non-interactive shell, or that your version

Re: Cdr car

2012-11-06 Thread Michael Gardner
On Nov 6, 2012, at 11:48 , Sean Corfield seancorfi...@gmail.com wrote: On Tue, Nov 6, 2012 at 9:34 AM, JvJ kfjwhee...@gmail.com wrote: There's quite a number of functions like caar, cadr, cadadr, etc. It's lengthy to do that in clojure with just first and rest. Clojure does have ffirst,

Re: Evaluating an anonymous function with closure

2012-10-16 Thread Michael Gardner
On Oct 16, 2012, at 5:16 AM, Jim foo.bar wrote: so you're saying that if I write a for-loop in Java that populates an array with constants from 1-1 and then a 2nd loop to add them up, it would happen at compile-time and i would get the same timing-result? Maybe, maybe not. Compilers are

Re: Evaluating an anonymous function with closure

2012-10-15 Thread Michael Gardner
On Oct 15, 2012, at 7:45 PM, Andy Fingerhut wrote: For the case of arithmetic on compile-time constants, I believe that many C, Java, etc. compilers already perform the arithmetic at compile time. Known as constant folding, yes. -- You received this message because you are subscribed to the

Re: genuine help needed to speed up minimax algorithm!

2012-08-18 Thread Michael Gardner
If you haven't already, start by eliminating reflection warnings[1]. As for pmap, it's unfortunately useless. You could roll your own using e.g. Java's thread pools, or you could wait for the new reducers library[2]. Reducers should offer not only useful parallelism, but also better performance

Re: genuine help needed to speed up minimax algorithm!

2012-08-18 Thread Michael Gardner
On Aug 18, 2012, at 7:27 AM, Jim - FooBar(); wrote: As far as pmap goes, I originally thought of starting a new future for each starting branch but that is what pmap does essentially, so it looked very handy at first... Yes, pmap is essentially a trap in that it looks like the perfect tool

Re: Just wanted to say how much I like ClojurePY

2012-08-17 Thread Michael Gardner
On Aug 16, 2012, at 8:52 AM, Timothy Baldridge wrote: With pip/easy_install and virtual_env, there's really not much of a point. Would lein-py be nice? Yeah, but it's hardly a show-stopper. What's the story like for code that depends on another clojure-py library? Would the Python Package

Re: Question about sets

2012-08-05 Thread Michael Gardner
On Aug 5, 2012, at 4:18 PM, Mark Engelberg wrote: Also, although it was a breaking change to add throw-on-duplicate behavior to many types of maps and sets, reverting back to 1.2 behavior could not possibly be a breaking change in the literal sense. Anyone whose code works right now on

Re: Alternative to (or (:k1 m) (:k2 m))

2012-07-31 Thread Michael Gardner
On Jul 31, 2012, at 12:00 AM, Ben Smith-Mannschott wrote: ((some-fn :k1 :k2) m) Ah, excellent. Yet another hidden gem in clojure I'd somehow overlooked until now! -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Alternative to (or (:k1 m) (:k2 m))

2012-07-30 Thread Michael Gardner
Is there an elegant way to say '(or (:k1 m) (:k2 m)), without repeating m? Using a let can be awkward if the expression isn't already wrapped in one; '(apply #(or %1 %2) (map m [:k1 :k2])) is similarly bad. Hopefully there's something clever I'm missing; any ideas? -- You received this

Re: Alternative to (or (:k1 m) (:k2 m))

2012-07-30 Thread Michael Gardner
On Jul 30, 2012, at 6:08 PM, Aaron Cohen wrote: For even more fun, try (some m [:k1 :k2]) :) Wow, that's perfect. It even works with string keys! Thanks, guys. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to

Re: General subsequence function

2012-06-27 Thread Michael Gardner
On Jun 27, 2012, at 9:39 AM, Warren Lynn wrote: I am surprised that there seems to be no general sub-sequence function that will return a segment of a sequence without changing the underlying concrete type. I found subvec, but it works only on vectors. subseq is not what I thought it is.

Re: General subsequence function

2012-06-27 Thread Michael Gardner
On Jun 27, 2012, at 1:02 PM, Warren Lynn wrote: Do you mean something like this: (defn subseqx [s start end] (into (empty s) (drop-last (- (count s) end) (drop start s Two things I don't like it: 1. It does not work (subseqx [1 2 3] 1 3) = [2 3] (subseqx '(1 2 3) 1 3) = (3 2)

Re: (#({:a %}) :b)

2012-06-03 Thread Michael Gardner
On Jun 3, 2012, at 8:53 PM, Steven Obua wrote: The expression (#({:a %}) :b) should evaluate to {:a :b}, but raises an exception instead: Wrong number of args (0) passed to: PersistentArrayMap This is a pretty irritating bug and makes the #% form essentially unusable for me,

Re: Different behavior at REPL vs compiled code

2012-05-19 Thread Michael Gardner
On May 19, 2012, at 3:19 AM, Andy Fingerhut wrote: Whereas Perl would automatically convert from a string to a number in a case like this, Clojure does not. One could argue that such auto-conversion of types, while convenient in many cases in Perl, is also a source of errors in programs.

Re: docstrings of if-let and when-let incorrect

2012-05-16 Thread Michael Gardner
On May 16, 2012, at 8:16 AM, Aaron Cohen wrote: Saying something is obvious and then using the word monad a paragraph later is contradictory. ;) If the word monad is scary, just pretend he said it should short-circuit instead. ;) What should happen on the else branch of the if-let; which

Re: Faster application startup for rapid development

2012-05-15 Thread Michael Gardner
There's also nailgun: it keeps a JVM running in the background that Java programs can connect to, eliminating JVM startup time completely. It's totally insecure on multi-user machines and hasn't been updated in a while, but it may be sufficient to ease the pain on developer machines. -- You

Re: docstrings of if-let and when-let incorrect

2012-05-15 Thread Michael Gardner
On May 15, 2012, at 3:15 PM, Andy Fingerhut wrote: If if-let/when-let had multiple bindings, how would you propose to define the condition of whether to do the then branch? As the logical AND of all of the multiple forms? The OR? Only use the first expression? Only the last? I don't

Re: code as data vs. code injection vulnerability

2012-05-09 Thread Michael Gardner
On May 9, 2012, at 11:01 AM, Rostislav Svoboda wrote: This is the point! On one hand I need to evaluate data from a client on the other hand I'd like to filter out things like rm -rf /, drop table users etc. To me it looks like a contradiction impossible to circumvent. So I ask if there's

Re: Returning Success

2012-03-19 Thread Michael Gardner
If the success/failure of the function makes sense to represent in game-world terms, you could encode the information in the world object, perhaps as a flag that can be attached to the relevant object. In your example, the unit might be given a state with the value :blocked, indicating that

Re: Returning Success

2012-03-19 Thread Michael Gardner
On Mar 19, 2012, at 5:31 PM, Michael Gardner wrote: Or the simplest option: just have your functions return nil to indicate that the world state should remain unchanged from its previous value. If your world state is a hash-map, you could also return partial states and merge them

Re: Bret Victor - Inventing on Principle

2012-02-24 Thread Michael Gardner
On Feb 24, 2012, at 1:51 PM, Daniel E. Renfer wrote: Ken Wesson was noted for having strong opinions as was a noted hater of videos where text will do. He was also the only guy who would post replies with just you're welcome as the body. Until Cedric, that is... -- You received this message

Re: Why does (= [] (range)) not terminate?

2012-02-17 Thread Michael Gardner
On Feb 17, 2012, at 12:32 PM, Bill Smith wrote: It might help to know that (= (range) (range)) does not terminate either. Of course, since a pairwise sequential comparison (what I assume is going on under the hood) will never find a non-matching pair. It appears that the = operator wants to

  1   2   3   >