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 u

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 with

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. Th

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 native mutable collec

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 thought

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/ [2]

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, s

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 Google Groups "Clojure" g

Re: Reducing the pain of a clojars outage

2016-01-02 Thread Michael Gardner
> On Jan 2, 2016, at 10:27, Toby Crawley wrote: > > On Sat, Jan 2, 2016 at 12:47 AM, Michael Gardner wrote: >> >> I would caution against this approach. An attacker could easily target >> specific organizations, serving compromised artifacts only to particula

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 any checksum >ha

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 colleague and I are deb

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 JVM library ecosystem to be lack

Re: Single-atom update ordering guarantees

2015-06-09 Thread Michael Gardner
model guarantees as Java fields 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, J

Re: Single-atom update ordering guarantees

2015-06-09 Thread Michael Gardner
en by normal sequential > execution the atom should change from 1 to 2, then from 2 back to 1. > > Andy > > On Tue, Jun 9, 2015 at 9:38 AM, Atamert Ölçgen wrote: > > > On Tue, Jun 9, 2015 at 7:30 PM, Michael Gardner wrote: > This might be blindingly obvious t

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 mess

Re: Identifying dependency that's pulling in SLF4J

2015-06-08 Thread Michael Gardner
> On Jun 8, 2015, at 10:30 AM, Stephen Gilardi 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 Note that posts f

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 sub

Re: contains? on String

2015-05-12 Thread Michael Gardner
On May 12, 2015, at 3:28 PM, Fluid Dynamics 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 that it works on as

Re: contains? on String

2015-05-12 Thread Michael Gardner
On May 12, 2015, at 1:54 PM, Shantanu Kumar 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 odd that (contains?

Re: How to coerce to bigint ?

2015-04-04 Thread Michael Gardner
On Sat, Apr 4, 2015 at 11:36 AM, Paul Roush 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 conditiona

Re: Set equality bug?

2015-01-23 Thread Michael Gardner
On Jan 23, 2015, at 11:51 AM, Andy Fingerhut 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 1.5)) > true > user

Re: Set equality bug?

2015-01-23 Thread Michael Gardner
On Jan 23, 2015, at 8:23 AM, Andy Fingerhut 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 subscribed to the Google Grou

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 obje

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 > wrote: > > Agree, it's broken... in java... > Has it has b

Re: Set equality bug?

2015-01-23 Thread Michael Gardner
On Jan 23, 2015, at 1:33 AM, Immo Heikkinen 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, it > is inevitable

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 ni

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 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 lmt). -- You re

Re: boolean problem

2014-04-17 Thread Michael Gardner
On Apr 17, 2014, at 07:38 , Tassilo Horn wrote: > Michael Gardner 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 >>

Re: boolean problem

2014-04-17 Thread Michael Gardner
On Apr 17, 2014, at 02:34 , Tassilo Horn 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 Groups "Cloj

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:3

Re: XOR two arrays into a third on Clojure

2014-03-13 Thread Michael Gardner
On Mar 13, 2014, at 07:34 , Alex Miller 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 slower? -- You receive

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: 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 directly

Re: [ANN] Clojure 1.6.0-beta1

2014-02-14 Thread Michael Gardner
On Feb 14, 2014, at 17:25 , Alex Miller 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. > Many other

Re: range-sum

2014-02-13 Thread Michael Gardner
On Feb 13, 2014, at 15:17 , Mauricio Aldazosa 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 at least the first item. But tha

Re: range-sum

2014-02-13 Thread Michael Gardner
On Feb 13, 2014, at 14:31 , Michael Gardner wrote: > On Feb 13, 2014, at 08:56 , Stuart Sierra 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. >

Re: range-sum

2014-02-13 Thread Michael Gardner
On Feb 13, 2014, at 08:56 , Stuart Sierra 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 apply will always realize i

Re: map semantics

2014-02-08 Thread Michael Gardner
On Feb 8, 2014, at 15:14 , Andy C 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 to answer that ques

Re: map semantics

2014-02-07 Thread Michael Gardner
On Feb 7, 2014, at 22:17 , Andy C 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 sequences; map knows nothing

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 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 could use > > (paddin

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 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: > > (padding inner-codec 40

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 mp3.

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 binary

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 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: [Large File Processing] What am I doing wrong?

2014-01-21 Thread Michael Gardner
On Jan 21, 2014, at 07:11 , Chris Perkins 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: note that if you’re stori

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

2014-01-20 Thread Michael Gardner
On Jan 20, 2014, at 09:31 , Zach Oakes 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 enough for simp

Re: Clojure development & laptop battery usage

2014-01-20 Thread Michael Gardner
On Jan 20, 2014, at 11:14 , Mars0i 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 > directory that Leinin

Re: Contributors needed for Rouge (Clojure on Ruby)

2014-01-04 Thread Michael Gardner
On Jan 4, 2014, at 11:52 , gvim 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 > dead project.

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 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 > community to see

Re: Breaking out of a map type function

2013-11-24 Thread Michael Gardner
On Nov 24, 2013, at 10:19 , David Simmons 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 items. I know > map

Re: Potential improvement to select-keys ?

2013-11-01 Thread Michael Gardner
On Nov 1, 2013, at 14:18 , Mark Engelberg 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 how map and similar

Re: Request for help optimising a Clojure program

2013-10-23 Thread Michael Gardner
On Oct 23, 2013, at 17:03 , Mark Engelberg 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 sorts of > common rearran

Re: Request for help optimising a Clojure program

2013-10-23 Thread Michael Gardner
On Oct 23, 2013, at 14:34 , Mark Engelberg 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 for the hashes of

Re: Request for help optimising a Clojure program

2013-10-23 Thread Michael Gardner
On Oct 23, 2013, at 12:30 , Andy Fingerhut 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 sums of > vector hash va

Re: tools for minimizing forward declaration

2013-08-19 Thread Michael Gardner
On Aug 19, 2013, at 06:38 , Tim Visher 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 primitives that they

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 wrote: > Yes, the discussion about contains? has come up before, but there's a new > aspect to this particular i

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) 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: > • A MapEntry o

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 wrote: > On Mon, Jun 24, 2013 at 8:49 AM, John Gabriele wrote: >> Why does `into` fail when the 2-element collections are lists and not >> vectors? : > > Because the implementation special cases vectors :) > > It's the one place where a two element vec

Re: lazy sequence termination

2013-05-28 Thread Michael Gardner
On May 28, 2013, at 15:05 , Mond Ray 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 code, to make it easier

Re: noob question about try/catch

2013-04-26 Thread Michael Gardner
On Apr 26, 2013, at 11:55 , Michael Gardner 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: noob question about try/catch

2013-04-26 Thread Michael Gardner
On Apr 26, 2013, at 10:01 , larry google groups 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 because of reasons[1][2]

Re: merge nested maps

2013-04-25 Thread Michael Gardner
On Apr 25, 2013, at 15:41 , Joachim De Beule 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 "baz"

Re: Parallelizing tasks

2013-04-11 Thread Michael Gardner
On Apr 10, 2013, at 21:46 , Ulises 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 the differences between (

Re: how can I count lines of code?

2013-03-27 Thread Michael Gardner
On Mar 27, 2013, at 14:36 , larry google groups 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 space. On Linux or Mac,

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 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 of the thread more c

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 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 > something else

Re: contains? for vectors

2013-03-01 Thread Michael Gardner
On Mar 1, 2013, at 13:36 , AtKaaZ 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. I'm talking a

Re: contains? for vectors

2013-03-01 Thread Michael Gardner
On Feb 28, 2013, at 17:17 , AtKaaZ 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 seen made before.

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 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, like *warn-on-reflectio

Re: clojure API documentation

2013-01-29 Thread Michael Gardner
On Jan 29, 2013, at 11:42 , cej38 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. It's not in the API

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

2012-12-03 Thread Michael Gardner
On Dec 2, 2012, at 06:24 , Mikera 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 consider building around javax.

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 versio

Re: Cdr car

2012-11-06 Thread Michael Gardner
On Nov 6, 2012, at 11:48 , Sean Corfield wrote: > On Tue, Nov 6, 2012 at 9:34 AM, JvJ 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, fnext, nfirst, nnext tho' - and I'd qu

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 a

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

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 too

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: Just wanted to say how much I like ClojurePY

2012-08-16 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 I

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

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 t

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 cl

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 message

Re: Clojure shell calls results inconsistent with actual shell calls.

2012-07-11 Thread Michael Gardner
On Jul 11, 2012, at 5:40 PM, Eric in San Diego wrote: > Unfortunately the application in question is kinda...involved. It's a call > to a tool provided by a third party, and installing the whole thing is > non-trivial. > > That's why I'm hoping there is some way I can compare and contrast the

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)

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 i

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 m

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 > program

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; w

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? > >

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

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 ther

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 in

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 so

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 mess

  1   2   3   >