Re: ? stateful-map ?

2022-12-09 Thread Steve Miner
See also https://github.com/cgrand/xforms for a transducer version of reductions. The argument f must have a nullary arity. (You could probably create your own variant if you want an explicit init value.) I think something like this should work: (require '[net.cgrand.xforms :as x]) (defn

Re: Cognitect joins Nubank!

2020-07-23 Thread Steve Miner
Parabéns -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send

Re: [ANN] tarantella 1.1.1

2019-07-31 Thread Steve Miner
My original benchmarks were for Eight Queens. I ran some more tests with larger N and found that at N=14, the Tarantella version is the clear performance winner on my machine. > On Jul 30, 2019, at 7:03 PM, Mark Engelberg wrote: > > Thanks for writing the n-queens code and the blog post.

Re: [ANN] tarantella 1.1.1

2019-07-30 Thread Steve Miner
Thanks for updated Tarantella. I also enjoyed re-watching your talk. I just wrote a blog post to cover a simple solution to the Eight Queens problem using Tarantella. http://conjobble.velisco.com/2019/07/30/tarantella-queens.html

Re: [ANN] tools.deps.alpha

2017-07-26 Thread Steve Miner
). It would be good enough if you provided an option to turn off rlwrap so I could wrap your script with my own. I can file bugs and provide patches if you want. Steve Miner stevemi...@gmail.com <mailto:stevemi...@gmail.com> > On Jul 25, 2017, at 10:19 AM, Alex Miller <a...@puredange

Re: [ANN] Clojure 1.9 / clojure.spec split

2017-05-04 Thread Steve Miner
> On May 3, 2017, at 7:37 PM, Alex Miller wrote: > > A newer version (0.1.108) of spec.alpha is available that fixes the issue. > Note that this kind of update is exactly why the jars are split - you can > update the libs more frequently than the Clojure version. Thanks.

Re: [ANN] Clojure 1.9 / clojure.spec split

2017-05-03 Thread Steve Miner
[clojure.lang.AFn applyToHelper "AFn.java" 152] [clojure.lang.RestFn applyTo "RestFn.java" 132] [clojure.lang.Var applyTo "Var.java" 702] [clojure.main main "main.java" 37]]} I think it would be nice to have an inclusive jar as before. Or w

Re: Combinatorics partitions that preserves adjacency?

2017-03-17 Thread Steve Miner
fn [splits] (map (fn [start end] (subvec v start end)) (conj splits 0) (concat splits (list cnt (sized-subsets (range 1 cnt) smin smax)))) Steve Miner > On Mar 16, 2017, at 12:59 PM, Paul Gowder <paul.gow...@gmail.com> wrote: > >

Re: clojure.spec bug?

2017-01-02 Thread Steve Miner
> On Jan 1, 2017, at 7:13 PM, John Schmidt wrote: > > Steve: both ::game3 and ::game4 from your suggestions result in the same > error. > Sorry for my mistaken conjecture. My issue with the macroexpansion looks like a red herring. I guess I confused myself with

Re: Wrapping a string as-is

2017-01-01 Thread Steve Miner
Use clojure.edn/read-string. Note the clojure.edn namespace. clojure.core/read-string can execute code (controlled by *read-eval*), and as such should be used only with trusted sources. > On Jan 1, 2017, at 10:07 AM, Yehonathan Sharvit wrote: > > I’d like to write a

Re: clojure.spec bug?

2016-12-31 Thread Steve Miner
> On Dec 30, 2016, at 9:42 AM, John Schmidt wrote: > > (s/def ::game1 #(satisfies? Game %)) > (s/def ::game2 (partial satisfies? Game)) > > (s/explain ::game2 (spec-test.foo/->Foo)) > val: #spec_test.foo.Foo{} fails spec: :spec-test.core/game2 predicate: > (partial

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

2016-11-22 Thread Steve Miner
> On Nov 21, 2016, at 8:03 PM, Didier <didi...@gmail.com> wrote: > > @miner: Doesn't using the flag (set! *unchecked-math* :warn-on-boxed) gives > me unchecked math automatically? I was under the impression that +, -, /, * > etc. would all now perform in an equal way

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

2016-11-21 Thread Steve Miner
> On Nov 21, 2016, at 3:05 PM, Didier wrote: > > I experimented with this a lot, and took everyone's advice, and this is the > fastest I got, even faster then Michael Gardner's answer. > > (deftype point5 [^long i ^long j] > Object > (equals [this that] (and (= (.i

Re: Just quick review - "idiomaticy" check (Selection sort)

2016-10-10 Thread Steve Miner
> On Oct 10, 2016, at 6:50 AM, Rastko Soskic wrote: > > I am specially interested in better way for processing input which shrinks > after each step. Vectors have some nice properties if your action is mostly at the end. The peek and pop functions are useful for

Re: core.logic with 1.9.0-alpha12

2016-09-13 Thread Steve Miner
Filed LOGIC-180 bug with patch. http://dev.clojure.org/jira/browse/LOGIC-180 -- 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

Re: core.logic with 1.9.0-alpha12

2016-09-13 Thread miner
It looks like the problem is with the macro -inc. It should quote the internal fn name so that it stays an unqualified symbol during macro expansion. I need to test this a bit as I’m not familiar with this code. I’ll make a patch soon if David doesn’t fix it first. By the way, spec

Re: grouping and mapping

2016-08-14 Thread Steve Miner
Sorry, I got the semantics of the grouping-fn wrong. My code assumes that the key is always first in the elements and my grouping is more like a merging-fn. > On Aug 14, 2016, at 2:53 PM, miner <stevemi...@gmail.com> wrote: > > If your data elements are essentially map-entries (

Re: grouping and mapping

2016-08-14 Thread miner
If your data elements are essentially map-entries (key-value pairs), I'd use reduce. Maybe something like this would work for you... (defn mapping-group-by [grouping-fn mapping-fn coll] (reduce (fn [res [k v]] (update res k grouping-fn (mapping-fn v))) {} coll)) (def foos

Re: How does clojure.core quote function work for keyword?

2016-07-26 Thread Steve Miner
It’s working as expected. The :: notation is expanded by the reader, before evaluation. As keywords are basically constants (like numbers or strings), you rarely see them quoted. > On Jul 26, 2016, at 8:52 AM, Mamun wrote: > > Hi > > How does clojure.core quote

Re: meaning of spec/and ?

2016-07-21 Thread Steve Miner
It looks like you’ve got your #s misplaced. I think you want something like this: (s/and #(> % 0.0) #(< % 1.0)) Of course, the first predicate expression could be replaced by `pos?`. The `s/and` returns a single spec that combines multiple specs. Of course, `clojure.core/and` is basically

Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Steve Miner
> (s/and (s/double-in :min 0.0 :max 1.0) #(not= 0.0 %)) > > should be the same as > > (s/double-in :min Double/MIN_VALUE :max 1.0) I should have mentioned that Double/MIN_VALUE is the smallest positive double (just greater than 0.0), not a large negative value. It’s easy to get confused

Re: Enhance spec/double-in to handle open and half-open intervals?

2016-07-21 Thread Steve Miner
With a little help from Java, you can make equivalent open intervals for the desired bounds. For example, (s/and (s/double-in :min 0.0 :max 1.0) #(not= 0.0 %)) should be the same as (s/double-in :min Double/MIN_VALUE :max 1.0) Also, you can use java.lang.Math/nextUp and nextAfter to get

Re: Clojure for the Brave and True - infix notation exercise

2016-06-24 Thread Steve Miner
to prefix transformation. That’s probably closer to what you want. https://gist.github.com/miner/5224709 Note: the “Joy” code uses vector notation for grouping. You would have to adapt it to use lists. Here’s the relevant code from my gist, leaving out the data-reader part: (def

Re: clojure.spec

2016-05-24 Thread Steve Miner
> On May 24, 2016, at 8:10 AM, Alex Miller wrote: > > The first use is a namespace alias and the second is a var - they don't > overlap in usage. Right, but it’s still a potential source of confusion. The explanation distracts from the point of the example which is to

Re: Clojure as first language

2016-02-26 Thread Steve Miner
> On Feb 26, 2016, at 9:53 AM, Lee Spector wrote: > > But sometimes it does matter, e.g. (str '(1 2 3 4 5 6 7 8 9 10)) => "(1 2 3 4 > 5 6 7 8 9 10)", whereas (str (map inc (range 10))) => > "clojure.lang.LazySeq@c5d38b66" There’s a bit of subtlety around `str` vs.

Re: A call for an idiomatic rendering of Clojure EDN in info/error messages

2015-11-13 Thread Steve Miner
For what it’s worth, I like to use matching `backquotes` as a meta-syntax. (defn expected [exp was] (format "Expected `%s` but was `%s`" (pr-str exp) (pr-str was))) (println (expected 2 "2")) ;=> Expected `2` but was `"2"` > On Nov 13, 2015, at 6:55 AM, Colin Yates

Re: lazyseq?

2015-10-19 Thread Steve Miner
I’ll second what Timothy Baldridge wrote. By the way, you have to make sure you’re dealing with some sort of clojure.lang.IPending before you call realized? on it. I prefer to test against interfaces rather than concrete classes so I would try something like this

Re: partition-when?

2015-08-20 Thread Steve Miner
If you’re interested in a transducer version of partition-when, here’s my code from https://github.com/miner/transmuters ;; collection version by Frank on mailing list ;; SEM added transducer version, adapted from partition-by (defn partition-when Applies f to each value in coll, starting

Re: Opinion on take-while for stateful transducers

2015-05-11 Thread Steve Miner
#{} (complement contains?)) '(1 2 3 4 2 5 6)) ;;= [1 2 3 4] ;; dedupe (into [] (take-while-accumulating (fn [r x] x) ::void not=) '(1 2 1 3 4 4 5 6)) ;;= [1 2 1 3 4] ;; monotonically increasing (into [] (take-while-accumulating max 0 =) '(1 2 3 4 4 1 5 6)) [1 2 3 4 4] Steve Miner stevemi

Re: What is best practice regarding transducers

2015-05-10 Thread Steve Miner
xempty is a transducer that just returns an empty result, essentially ignoring the input. The thought was that a degenerate transducer might be useful in a complex chain if you want to stop processing. I haven’t actually used it for anything, just experimenting. On May 10, 2015, at 3:12 PM,

Re: What is best practice regarding transducers

2015-05-08 Thread Steve Miner
I wouldn’t make any claims about “best practices” but I’ve been playing with transducers in my little project: https://github.com/miner/transmuters I have a blog post about how to “chain” transducers. (Not sure that’s the best term.) Basically, I wanted to use a transducer that might

Re: Transducers: sequence versus eduction

2015-04-03 Thread Steve Miner
rewriting. Wouldn't a macro make more sense? (defmacro educe- [coll xfs] `(-Eduction (comp ~@xfs) ~coll)) So the rewrite could be just educe- for -, without having to wrap the xforms at all. (educe- s (interpose 5) (partition-all 2)) Steve Miner stevemi...@gmail.com -- You received

Re: partition-when

2015-03-05 Thread Steve Miner
For the transducer version, I don’t think you need to keep track of the previous value (fval). The decision to start a new partition group depends only on the current item. Here’s my version. (Warning: virtually untested.) I assume that the first item goes into the first partition no matter

Re: printf does not always generate output

2015-02-27 Thread Steve Miner
Try adding (flush) at the end. On Feb 27, 2015, at 2:12 PM, Cecil Westerhof cldwester...@gmail.com wrote: My core.clj ends with: (println (format Started: %s (println) (java.util.Date.))) (printf Started: %s (printf)\n (java.util.Date.)) I do not see the output from the printf

Re: should edn recognise defrecord?

2015-02-24 Thread Steve Miner
existed, there was a little library that I used to encode a Clojure record as a tagged literal (for edn compatibility). It’s only for the Clojure side at the moment, but I imagine it wouldn’t be hard to port to CLJS. However, I suggest that you use transit. https://github.com/miner/tagged https

Re: Can someone offer refactoring suggestions for my protocol example?

2015-02-24 Thread Steve Miner
It’s probably fine to do a linear search with .indexOf for small vectors, but I’ll just say as a matter of style I prefer to use a couple of maps to hold previous and next items. The maps are callable like functions, which I think reads very nicely. Using your example data for ranks: ;;

Re: Lucky Numbers again

2015-02-19 Thread Steve Miner
I found a better data structure for calculating lucky numbers. The contrib library data.avl (from Michał Marczyk) has a persistent sorted-set that supports nth. This runs much faster than my previous attempts. (require '[clojure.data.avl :as avl]) (defn lucky-avl ([max] (lucky-avl 1 (apply

Re: Lucky Numbers again

2015-02-18 Thread Steve Miner
One more try. This time using the int-map contrib library. (Thanks to Zack Tellman.) Warning: I'm assuming that the int-set seq is automagically sorted so I can reliably turn it back into a vector without sorting. It seems to be stable at least. I wanted a vector for fast nth access. (Nth

Re: Lucky numbers

2015-02-17 Thread Steve Miner
On Feb 17, 2015, at 4:39 PM, Colin Jones trptco...@gmail.com wrote: Sounds almost like a mirror image of `clojure.core/take-nth`, so something like this is kind of fun: (defn drop-nth [n coll] (lazy-seq (when-let [s (seq coll)] (concat (take (dec n) s) (drop-nth n (drop

Re: Name of a function

2015-02-14 Thread Steve Miner
Clojure doesn't give you direct access to the name of the function you're defining. However, you could use a macro to get that. Here’s one way. This macro binds the strange symbol %0 to the symbol naming the current function. ;; %0 is bound to the function's symbolic name within the

Re: print-table bug?

2015-02-02 Thread Steve Miner
In any case, it would be nice if (str ()) returned “()”. By the way, (str {}) returns {} and (str []) returns []” as I would expect. I just filed CLJ-1653.Seems like the simple fix is to add a toString() method for PersistentList.EmptyList. -- You received this message because you are

Re: print-table bug?

2015-02-02 Thread Steve Miner
Looks like a bug in clojure.pprint/print-table. Probably should be use `pr-str` instead of `str`. user= (str ()) clojure.lang.PersistentList$EmptyList@1 user= (pr-str ()) () On Feb 2, 2015, at 3:10 PM, John Lawrence Aspden aspd...@googlemail.com wrote: These behave differently in 1.6

Re: [ANN] dformat 0.1.0

2015-01-15 Thread Steve Miner
Clever. The doc-strings for dformatter and dformat could use a little work. Remember, people will use (doc whatever) in the REPL so “same as above” isn’t very useful. Also, the dformatter doc implies more arguments than it actually takes. The order of arguments to dformat seems backwards to

Re: [ANN] Clojure 1.7.0-alpha5 now available

2015-01-15 Thread Steve Miner
Alpha5 works for me. I noticed that the doc-string for *unchecked-math* doesn't mention the :warn-on-boxed behavior. Suggestion: While bound to true, compilations of +, -, *, inc, dec and the coercions will be done without overflow checks. While bound to :warn-on-boxed, a warning will

Re: better way to group consecutive numbers in a vector?

2014-11-06 Thread Steve Miner
I would try to avoid last and but-last as they work in linear time. How about something like this? (defn congeal-consecutives [coll] (when (seq coll) (let [[_ group res] (reduce (fn [[succ group res] n] (if (== succ n)

Re: Is this behavior with recur and pre/post a bug?

2014-07-26 Thread Steve Miner
I'm giving up on this bug. My approach was adding too much complexity to handle an edge case. Hacking the fn macro is not as easy as it looks. :-) I recommend the loop work-around if you run into this problem. Or refactor the recursive code into a separate function and call it from another

Re: Is this behavior with recur and pre/post a bug?

2014-07-26 Thread Steve Miner
I tried the latest patch from Ambrose for CLJ-1475. Looks good to me. Well done. -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be

Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Steve Miner
I will call it a bug. It's definitely surprising to the user, and therefore worthy of a ticket. On first glance, it seems that the fix isn't too hard. In core.clj where the macro fn is redefined, we just need to wrap the section that handles the post condition either with a loop* or a fn* so

Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Steve Miner
Ticket CLJ-1475 with my patch. http://dev.clojure.org/jira/browse/CLJ-1475 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient

Re: Is this behavior with recur and pre/post a bug?

2014-07-25 Thread Steve Miner
and never during a recur. Any other opinions? On Jul 25, 2014, at 10:57 AM, Steve Miner stevemi...@gmail.com wrote: Ticket CLJ-1475 with my patch. http://dev.clojure.org/jira/browse/CLJ-1475 -- You received this message because you are subscribed to the Google Groups Clojure group. To post

Re: Critiques of my-flatten which uses CPS

2014-07-17 Thread Steve Miner
Slightly off-topic from original poster's question, but if you're interested in another implementation of flatten, I suggest you take a look at the reducers library. clojure.core/flatten is elegant but a bit slow. The reducers version is very fast as part of a reduce/fold operation. The

Re: How to take a subsequence out of an infinite lazy sequence?

2014-06-15 Thread Steve Miner
On Jun 15, 2014, at 9:42 AM, Yehonathan Sharvit vie...@gmail.com wrote: I have a infinite lazy sequence and I would like to create a lazy sub sequence with all the elements whose indices are between 100 and 1000. You can use `drop` and `take` with infinite sequences. Something like this

Re: [ANN] clojure.test.check 0.5.8

2014-05-15 Thread Steve Miner
is something like running a predicate backwards so maybe there's a way to do it with core.logic, but I haven't tried to do that yet. I'd be happy to consider any suggestions. Thanks, Steve Miner [1] https://github.com/miner/herbert -- You received this message because you are subscribed

Re: [ANN] clojure.test.check 0.5.8

2014-05-14 Thread Steve Miner
, it turns out 25 was a sufficient number of retries for my test. Works fine now. Steve Miner -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated

Re: Thoughts on a curly-infix reader macro?

2014-04-04 Thread Steve Miner
] https://gist.github.com/miner/5224709 -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe

Re: Clojure 1.6.0-RC1 - LAST CHANCE, PLEASE TEST

2014-03-19 Thread Steve Miner
I just tried to build master locally with the new JDK 1.8 on a Mac. I'm getting a build test failure. Sorry, I don't have time to look into it at the moment. JDK 1.7 worked fine for me. [java] clojure.test-clojure.reflect [java] [java] java.lang.IllegalArgumentException

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

2014-02-19 Thread Steve Miner
On Feb 19, 2014, at 12:28 AM, Laurent Droin laurentdr...@gmail.com wrote: Ah, thank you. interleave is what I was looking for. I looked for weave, zip, map, concat, and all the see also but did not find interleave. Interleave will of course not handle the last value in the categories

Re: Function to Generate EDN :readers Map for Namespace Records?

2013-12-06 Thread Steve Miner
I use a default reader to do something like what you're asking for in my 'tagged' library. You could hack a similar default reader that restricted itself just to your favorite namespaces. That way you don't have to explicitly track all your defrecord classes. https://github.com/miner/tagged

Re: Clojure 1.5 RC 14

2013-02-09 Thread Steve Miner
Maybe the registry has caught up with the updates yet. Leiningen found RC 14. % lein deps Retrieving org/clojure/clojure/1.5.0-RC14/clojure-1.5.0-RC14.pom from sonatype-oss-public Retrieving org/clojure/clojure/1.5.0-RC14/clojure-1.5.0-RC14.jar from sonatype-oss-public On Feb 9, 2013, at

Re: *read-eval* vulnerability

2013-01-30 Thread Steve Miner
I would prefer that *read-eval* default to false. In this case, security is more important than backwards compatibility. However, I want to point out that there is an issue with backwards compatibility, especially for users of *print-dup* (default false). In many cases, with *print-dup*

Re: Nilsafe operators from clojure.core.contrib fail when not referred

2013-01-30 Thread Steve Miner
In Clojure 1.5 pre-releases, there's a new macro called some- . The source looks like it would work fine in earlier versions of Clojure. At this point, I don't think it's a good idea to keep slightly different versions in contrib. -- -- You received this message because you are subscribed

Re: What's the current status of Clojure-in-Clojure?

2013-01-09 Thread Steve Miner
I think you're looking for: https://github.com/kanaka/clojurescript I just saw a tweet about a talk be accepted for ClojureWest: https://twitter.com/bus_kanaka/status/289037484787118080 On Jan 8, 2013, at 6:44 PM, Thor dth...@gmail.com wrote: I think this would be a fun project to contribute

Re: reader literal , tagged literal

2012-12-22 Thread Steve Miner
I'd say that tagged literal is the preferred term for expressions like #inst 2012. The term reader literal might perhaps refer to any literal (number, string, etc.) that doesn't need any further evaluation, although I think people use it loosely to mean the same thing as tagged literal. A

Re: clojure defining a var with a dot in the name is accepted in clojure 1.5-RC1, but probably shouldn't?

2012-12-22 Thread Steve Miner
It looks like Clojure 1.4 does the same thing so it's probably been hiding for a while. The fully qualified var works. user= (def foo1. 2) #'user/foo1. user= foo1. CompilerException java.lang.ClassNotFoundException: foo1., compiling:(NO_SOURCE_PATH:0) user= user/foo1. 2 On Dec 22, 2012, at

Re: Default random in Clojure doesn't seem to fit fp paradigm

2012-12-05 Thread Steve Miner
You should treat rand and friends like i/o. Don't bury them deep in your code. Write your pure functions so that they take a seed value (or sequence). Generate the random values from outside of the important functions, maybe providing a convenience wrapper function around your main logic.

Re: Proposed change to let- syntax

2012-12-01 Thread Steve Miner
. The e stands for every because multiple clauses can succeed as opposed to the short-circuiting cond. On Nov 30, 2012, at 2:49 PM, Rich Hickey richhic...@gmail.com wrote: On Nov 30, 2012, at 1:49 PM, Steve Miner wrote: I propose guard- to avoid the cond- confusion. Yeah, that came up

Re: Proposed change to let- syntax

2012-11-30 Thread Steve Miner
I propose guard- to avoid the cond- confusion. If we're voting, as- is good. I liked when-. On Nov 30, 2012, at 10:37 AM, Rich Hickey richhic...@gmail.com wrote: I'm not satisfied with the names for the new threading macros either. The new names being considered for let-, test- and when-

Re: syntax for defrecord literals and tagged literals

2012-11-20 Thread Steve Miner
CLJ-1100 Reader literals cannot contain periods has a patch that will allow tags to have periods. It does not address the issue of allowing a space after the record type for record literals. My patch for CLJ-1100 would also allow *default-readers* to override a defrecord definition. That's

Re: Tagged literals: undefined tags blow up reader

2012-09-19 Thread Steve Miner
a patch that I'm planning to submit if dev people indicate support for it. The alternative of binding another dynamic var as the unknown tag handler would also work for me. Steve Miner -- You received this message because you are subscribed to the Google Groups Clojure group. To post

Re: (merge) = nil

2012-08-29 Thread Steve Miner
metadata manipulations, and the edge case of no-arguments wasn't considered important. It looks like it would be easy to fix and probably wouldn't break any code since no one should be depending on the undocumented nullary behavior. Steve Miner stevemi...@gmail.com -- You received this message

Re: another why: (flatten #{:a :b}) = () ???

2012-08-29 Thread Steve Miner
flatten has been discussed before: https://groups.google.com/forum/?fromgroups=#!topic/clojure/ye70iNJ73zc See also CLJ-400, but it looks like no patch was submitted. http://dev.clojure.org/jira/browse/CLJ-400 I think the general policy for Clojure is that the core functions of course should

Re: Parallel doseq?

2012-05-27 Thread Steve Miner
On May 27, 2012, at 3:11 AM, Cedric Greevey wrote: Eh. For general use, that needs to be (partition 100 100 nil calls#) in case the total size of the job isn't divisible by 100; otherwise, the items after the last exact multiple of 100 will be silently not done. You could use partition-all.

Re: Tagged literals: undefined tags blow up reader

2012-04-28 Thread Steve Miner
was thinking that I actually want different unknown tags to be unequal. #unk1 [1 2] and #unk2 [1 2] should not accidentally be considered the same data value if the tags are unknown. Steve Miner stevemi...@gmail.com On Apr 27, 2012, at 8:04 PM, kovas boguta wrote: Thanks everyone involved

Re: Cheap way to find function (defn) name using a macro?

2012-03-28 Thread Steve Miner
defn0 [name fdcls] `(let [~'%0 (symbol (name (ns-name *ns*)) (name '~name))] (defn ~name ~@fdcls))) Steve Miner stevemi...@gmail.com On Mar 28, 2012, at 11:02 AM, Shantanu Kumar wrote: Hi, Is it possible to write a macro that when used in a top-level function (created using defn

Re: Question about this little method I wrote

2012-02-29 Thread Steve Miner
There's contrib library that you might find interesting: https://github.com/clojure/math.combinatorics -- 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

Re: lazy-sequences and memory leaks

2012-02-28 Thread Steve Miner
Sorry, I don't have any relevant experience to share. As an experiment, I suggest that you try deferring the sh execution. Maybe logging the generated commands to a script file rather than calling sh during processing. Then execute one big script file at the end. That should make the

Re: novice question, performance surprise

2012-02-09 Thread Steve Miner
filter is lazy so it won't actually do the work unless the values are needed. To get a reasonable time, you need to use the result for some computation. Try something like this: (defn sum-all [m] (reduce + (apply map + (vals m (time (sum-all (separate-nums (range 1 On Feb 9,

instant literal

2012-02-05 Thread Steve Miner
1.6.0_30-b12-404-11M3614) Java HotSpot(TM) 64-Bit Server VM (build 20.5-b03-404, mixed mode) Steve Miner stevemi...@gmail.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from

Re: How to loop over several sequences in parallel for side-effects?

2012-01-20 Thread Steve Miner
On Jan 20, 2012, at 2:41 PM, Lars Nilsson wrote: = (map #(vector %1 %2) [1 2 3] ['a 'b 'c]) ([1 a] [2 b] [3 c]) Sorry if I'm drifting a bit off topic, but I just wanted to point out that it's convenient to use just the function name if the arguments are already in the appropriate order.

Re: Problem with :pre checks against nil in 1.3.0?

2012-01-09 Thread Steve Miner
The precondition should be a vector of expressions. (defn foo [x] {:pre [(not (nil? x))]} (* 3 x)) On Jan 9, 2012, at 12:53 PM, Tom Chappell wrote: Ok, I've got a couple thousand lines of Clojure under my belt, but this has me stumped, unless it's a compiler etc. issue. If I'm missing

Re: Any char-based Java file I/O with arbitrary seek?

2012-01-05 Thread Steve Miner
On Jan 5, 2012, at 5:07 PM, Andy Fingerhut wrote: I realize that with variable-length multi-byte character encodings like UTF-8, it would be a bad idea to seek to a random byte position and start trying to decode a UTF-8 character starting at that byte position. I'm thinking of cases

Re: Matching core.match's syntactic keywords

2011-12-23 Thread Steve Miner
) :as :label]] [[expr ':as (label :when keyword?)]] {:expr expr :label label}) ;= {:expr (some expr), :label :label} -- Steve Miner stevemi...@gmail.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure

Re: Symbol matching in core.match

2011-11-30 Thread Steve Miner
opinions on that? Steve Miner -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from

Re: Symbol matching in core.match

2011-11-30 Thread Steve Miner
I filed the bug and attached a patch. The check for duplicate wildcards now ignores anything that's quoted. I'm in a rush so it might be good for others to try it out. http://dev.clojure.org/jira/browse/MATCH-42 Steve Miner stevemi...@gmail.com -- You received this message because you

Re: Exception handling changes in Clojure 1.3.0

2011-10-12 Thread Steve Miner
I've done something like this in Java projects but without any magic unwrapping. It worked well. Manual unwrapping wasn't too onerous in the rare cases where we wanted to do so. The Clojure-specific exception should be part of the public API for Java interop. Don't try to hide it. On Oct

Re: ANN: core.match 0.2.0-alpha5

2011-10-10 Thread Steve Miner
the match so I made a little macro to save a few characters. Free for anyone who wants it. :-) (defmacro match-let [bindings body] (let [bindvars# (take-nth 2 bindings)] `(let ~bindings (match [~@bindvars#] ~@body Steve Miner stevemi...@gmail.com -- You

Re: ANN: core.match 0.2.0-alpha5

2011-10-10 Thread Steve Miner
. By the way, there is a recurring typo in the README and the code: occurance should be occurrence. Steve Miner stevemi...@gmail.com -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from

Re: get keys from defrecord

2011-08-29 Thread Steve Miner
/design/defrecord+improvements Steve Miner -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe

Re: Apply concat and mapcat evaluate seqs unnecessarily

2011-08-24 Thread Steve Miner
I'd be careful about writing my own version of mapcat. You might save a call or two on the f function, but you'll probably lose in the general. Try some experiments with larger take numbers. You might be better off concentrating on your f function. I've found that trying to special-case

Re: Please stand firm against Steve Yegge's yes language push

2011-07-07 Thread Steve Miner
responded about how to contribute to the Getting Started documentation. If you want another place for language documentation, take a look at ClojureDocs.org. Anyone can sign up and contribute examples and usage notes. Steve Miner -- You received this message because you are subscribed to the Google

Re: hammock driven development...

2011-06-21 Thread miner
Here's some more support for the hammock: http://www.npr.org/blogs/health/2011/06/20/137300311/why-hammocks-make-sleep-easier-deeper Rocking increased the length of N2 sleep, a form of non-REM sleep that takes up about half of a good night's rest. It also increased slow oscillations and

Re: List comprehension not running

2011-06-16 Thread Steve Miner
(dotimes [x 10] ...) should do the trick if you're just interested in side effects. On Jun 16, 2011, at 12:24 PM, Baishampayan Ghose wrote: 'for' is not recommended for causing side-effects. Since you are not using the return value of the for comprehension, the lazy sequence is not getting

Re: CSV Handling

2011-06-06 Thread Steve Miner
On Jun 6, 2011, at 2:08 PM, octopusgrabbus wrote: Is there a core Java library that handles .csv files or do I need to download something like OpenCsv? Thanks. I've been using csvclj successfully. It's on clojars.org. [com.github.jonase.csv/csvclj 1.0.0-SNAPSHOT] -- You received this

Re: Efficient sparse vector representation...

2011-05-26 Thread Steve Miner
I've used this approach before. It was simple and worked well. Note that assoc can take multiple keys and vals so you can simplify it to (assoc m k v v k) instead of nesting the assoc calls. If there's any chance of a collision, you could be defensive and test for (contains? m k) or

Re: possibly non-intuitive behaviour of clojure.set/rename-keys and possible enhancement suggestion

2011-05-13 Thread Steve Miner
examples with key collisions. Regards, Steve Miner -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post

Re: Key order of literal maps

2011-05-03 Thread Steve Miner
On May 3, 2011, at 7:08 AM, David Jagoe wrote: Can I rely on (keys some-literal-map) always returning the keys in the order they were defined in the literal map? In general, the key order is not guaranteed, but an array-map will maintain the insertion order of the keys. Use the array-map

Re: closed maps / reducing runtime errors due to mistyped keywords

2011-04-26 Thread Steve Miner
could do that in a pre-condition. For example: (defn assert-key [m k] {:pre [(contains? m k)]} k) (defn assoc-closed [m k v] (assoc m (assert-key m k) v)) (defn get-closed [m k] (get m (assert-key m k))) Steve Miner stevemi...@gmail.com -- You received this message because you

Re: [ANN] fs - file system utilities for Clojure

2011-03-16 Thread Steve Miner
I've been using this to get the extension: (defn extension [file] (when file (let [base (fs/basename file) dot (.lastIndexOf ^String base .)] (when (pos? dot) (subs base (inc dot)) Steve Miner On Mar 15, 2011, at 5:56 PM, siyu798 wrote: Hi Miki, We

Re: Release.Next Version Number

2011-02-24 Thread Steve Miner
The choice boils down to whether or not you want to follow Semantic Versioning [1]. Apache (APR) [2], Eclipse [3], and OSGi [4] all seem to have equivalent policies. Personally, I think it's a perfectly logical approach to increment the major version number for any backwards incompatible

Re: [ANN] fs - file system utilities for Clojure

2011-01-13 Thread Steve Miner
not care about Java interop now, but either (a) you might later, or (b) your users might, now. Finally, gen-class will simply not work (last I checked) from a single-segment namespace. Best Regards, Steve Miner stevemi...@gmail.com -- You received this message because you are subscribed

  1   2   >