Re: What's up with IMeta?

2017-11-05 Thread Michał Marczyk
About realizing the head of lazy seqs in with-meta: On 5 November 2017 at 01:57, Didier wrote: > > That said, metadata and its relationship to an object is immutable - an >>> object with different metadata is a different object. One consequence of >>> this is that applying metadata to a lazy seq

Re: varying realization of a lazy-seq of strings?

2017-10-04 Thread Michał Marczyk
That's right. This happens is because collection classes' toString implementations currently delegate to RT.printString, which in turn is affected by the value of *print-readably*. Filed https://dev.clojure.org/jira/browse/CLJ-2248 with a fix. Cheers, Michał On 18 September 2017 at 03:08, Justi

Re: Help ship Clojure 1.9!

2017-10-04 Thread Michał Marczyk
I've run into a behaviour change that was actually already present in alpha20 – with the CLJ-99 patch in place, {min,max}-key now return the first argument with the minimum/maximum key, whereas previously they returned the last such argument. The new behaviour seems like the more natural one, but

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

2016-11-21 Thread Michał Marczyk
: 2.956519 sec Execution time std-deviation : 22.423970 ms Execution time lower quantile : 2.930938 sec ( 2.5%) Execution time upper quantile : 2.978283 sec (97.5%) Overhead used : 21.423788 ns On 22 November 2016 at 05:21, Michał Marczyk wrote: > Some furt

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

2016-11-21 Thread Michał Marczyk
Some further optimizations for a factor of ~2.3 speed-up over nth5 as copy & pasted from upthread (6.713742 ms → 2.897630 ms) in (c/quick-bench (nth-shell 100 (point. 0 0))) (1) java.util.HashSet has a ctor that takes initial capacity of the set as an int. Passing in (* 4 (.size s1)) when const

[ANN] maxiphobe 0.0.1 – Persistent Meldable Priority Queues

2016-11-21 Thread Michał Marczyk
Hi, I am pleased to announce the initial release of maxiphobe, a meldable priority queue library based on Okasaki's maxiphobic heaps (see Okasaki, "Alternatives to Two Classic Data Structures"). Maxiphobic heaps are a strikingly simple purely functional approach to implementing priority queues tha

[ANN] psq.clj 0.0.2 – Persistent Priority Search Queues

2016-11-20 Thread Michał Marczyk
Hi, I am pleased to announce the 0.0.2 release of psq.clj, a Clojure priority search queue library based on Ralf Hinze's priority search pennants (see Ralf Hinze, "A Simple Implementation Technique for Priority Search Queues"): https://github.com/michalmarczyk/psq.clj https://clojars.org/psq

Re: clojure.spec - relationship between :args

2016-11-07 Thread Michał Marczyk
Only one quick bit of feedback – it's preferable to use test.check facilities instead of (rand) because they're "repeatable": the seed emitted in test.check output can be used to rerun the test with the same test.check PRNG state (see the docstring on clojure.test.check/quick-check, specifically th

[ANN] data.avl 0.0.17 – tree balance bugfix, more generative tests

2016-10-31 Thread Michał Marczyk
Hi, I am pleased to announce the 0.0.17 release of data.avl, a Clojure Contrib library providing highly performant drop-in replacements for Clojure(Script)'s built-in sorted maps and sets that support O(log n) nth, rank-of, first-class submaps/subsets (like subseq, but preserving collection type;

[ANN] data.avl 0.0.16 – bugfix to one-sided subrange

2016-08-23 Thread Michał Marczyk
Hi, data.avl 0.0.16 is now available with a bugfix to the "one-sided subrange past end of collection" case of subrange partly fixed in 0.0.15. [org.clojure/data.avl "0.0.16"] org.clojure data.avl 0.0.16 org.clojure:data.avl:0.0.16 Cheers, Michał -- You received this mes

[ANN] data.avl 0.0.15 – BUGFIX to subrange

2016-08-23 Thread Michał Marczyk
Hi, I am pleased to announce the 0.0.15 release of data.avl, a Clojure Contrib library providing highly performant drop-in replacements for Clojure(Script)'s built-in sorted maps and sets that support O(log n) nth, rank-of, first-class submaps/subsets (like subseq, but preserving collection type;

Re: [ANN] data.avl 0.0.14 – BUGFIX to splits, faster map/set reductions

2016-08-23 Thread Michał Marczyk
Esp on the reduce stuff - great to see that. Any reason you > didn't go the IReduce path in Clojure too instead of CollReduce? Generally, > I'd say that's preferred when you control the data structure. > > > On Monday, August 22, 2016 at 7:43:51 PM UTC-5, Michał Marcz

[ANN] data.avl 0.0.14 – BUGFIX to splits, faster map/set reductions

2016-08-22 Thread Michał Marczyk
Hi, I am pleased to announce the 0.0.14 release of data.avl, a Clojure Contrib library providing highly performant drop-in replacements for Clojure(Script)'s built-in sorted maps and sets that support O(log n) nth, rank-of, first-class submaps/subsets (like subseq, but preserving collection type;

Re: is reduce/reduced faster than loop/recur?

2016-04-30 Thread Michał Marczyk
And just to add a pointer in case anybody's interested in opting in to this behaviour in a custom type, it's possible to do so by implementing clojure.core.protocols/IKVReduce (data.avl does this) or clojure.lang.IKVReduce (the iface implemented by built-in maps; clojure.core provides implementatio

Re: Scripting with Clojure / "slow" boot time

2016-02-10 Thread Michał Marczyk
FYI, you may want to have a look at the following commits: commit 71930b6b6537a796cdf13c4ffa7cf93eb53b6235 Author: Rich Hickey Date: Mon Feb 28 17:55:14 2011 -0500 improve startup time via lazy defn loading commit c5681382da775e898915b17f3ab18b49c65359ec Author: Rich Hickey Date: Tue A

Re: [ANN] data.avl 0.0.13 – fast sorted collections with O(log n) slices and nth

2015-12-09 Thread Michał Marczyk
Just noticed that I forgot to include dependency info and links… Here they are: https://github.com/clojure/data.avl [org.clojure/data.avl "0.0.13"] org.clojure data.avl 0.0.13 compile "org.clojure:data.avl:0.0.13" Cheers, Michał On 9 December 2

[ANN] data.avl 0.0.13 – fast sorted collections with O(log n) slices and nth

2015-12-09 Thread Michał Marczyk
Hi, I am pleased to announce the 0.0.13 release of data.avl, a Clojure Contrib library providing highly performant drop-in replacements for Clojure(Script)'s built-in sorted maps and sets with the following headline features: 0. performance often superior to the built-ins (owing to the smaller

Re: [ClojureScript] Re: [ANN] Clojure 1.7.0-beta1 released

2015-04-13 Thread Michał Marczyk
Just noticed that I sent my previous email to clojure-dev only – reposting to all groups involved: On 13 April 2015 at 16:25, Michał Marczyk wrote: > On 13 April 2015 at 15:48, Alex Miller wrote: > To get the effect you want in this, using #_ *inside* the reader conditional woul

Re: Transducers: sequence versus eduction

2015-04-02 Thread Michał Marczyk
It may be worth noting that while the return value of range is wrapped in lazy-seq and thus isn't itself a clojure.lang.IChunkedSeq, what you get when you realize it is indeed chunked: (contains? (ancestors (class (seq (range 128 clojure.lang.IChunkedSeq) true It doesn't implement c.l.IReduce

Re: Update multiple values in vector at once

2015-03-30 Thread Michał Marczyk
(defn upd-vec [input-vector ids new-values] (reduce-kv #(assoc %1 %3 (new-values %2)) input-vector ids)) (upd-vec [0 0 0 0 0] [1 3] [1.44 1.45]) ;= [0 1.44 0 1.45 0] On 30 March 2015 at 20:05, Alexandr wrote: > Hello everybody, > > How can I update values in the vector given vector of id-s a

Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008

2015-02-20 Thread Michał Marczyk
On 20 February 2015 at 20:09, David James wrote: > Yes, exactly, you read my mind. > > (I'd also like to do this a sorted-map / PersistentTreeMap (nudge, nudge) > -- all that is missing would be public 'left' and 'right' accessors. I > don't n

Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008

2015-02-20 Thread Michał Marczyk
PS. Well, I suppose you'd want to make sure that you're not getting a key that lies past the right endpoint of the map when using the nearest-based approach. On 20 February 2015 at 16:39, Michał Marczyk wrote: > Do you mean you'd like to compress > > {0 :a 1 :a 2 :a

Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008

2015-02-20 Thread Michał Marczyk
Do you mean you'd like to compress {0 :a 1 :a 2 :a 3 :a 4 :b 5 :b 6 :c 7 :c 8 :c 9 :c} to something like {[0 1 2] :a [4 5] :b [6 7 8 9] :c} while maintaining the ability to ask for the value at 0, 1, …, 9? If so, you could represent the above as {0 :a 2 :a 4 :b 5 :b 6 :c 9 :c} (notice

Re: Accessing branches in PersistentTreeMap / sorted-map / CLJ-1008

2015-02-19 Thread Michał Marczyk
gt;> If you don't want it soon, you could try persuading a few dozen people to >> vote on CLJ-1008, and hope the Clojure developers also want this change. >> No guarantees there. >> >> Andy >> >> On Thu, Feb 19, 2015 at 12:18 PM, David James wrote: >

Re: :keys and :or destructuring where defaults refer to one another

2014-12-12 Thread Michał Marczyk
I created a ticket and posted a patch: http://dev.clojure.org/jira/browse/CLJ-1613 On 12 December 2014 at 08:35, Michał Marczyk wrote: > (let [foo 1 >bar 2 >{:keys [bar foo] > :or {foo 3 bar (inc foo)}} {}] > {:foo foo :bar bar}) > ;= {:foo 3, :bar

Re: :keys and :or destructuring where defaults refer to one another

2014-12-11 Thread Michał Marczyk
Quoting Michael's Gist: (let [{:keys [bar foo] :or {foo 1 bar (inc foo)}} {}] (assert (= foo 1)) (assert (= bar 2))) The main problem I see with this is that I'd expect the foo in :or to refer to any foo in the enclosing scope. As things stand, whether it does or not depend

[ANN] ctries.clj 0.0.2 – concurrently modifiable, O(1)-snapshotable maps

2014-12-10 Thread Michał Marczyk
Hi, I am pleased to announce the immediate availability of version 0.0.2 of ctries.clj, a Clojure implementation of the Ctrie data structure introduced by Prokopec, Bronson, Bagwell and Odersky. This release includes some new tests, both single and multithreaded, exercising a number of features,

Re: clojure.edn won't accept clojure.java.io/reader? How to work around this and why isn't this documented anywhere?

2014-12-08 Thread Michał Marczyk
On 8 December 2014 at 21:17, Fluid Dynamics wrote: > On Monday, December 8, 2014 9:32:28 AM UTC-5, Las wrote: >> […] >> io/reader is not meant to be used solely as an input to edn/read. > > > AFAICT, PushbackReader is substitutable anywhere a reader is expected, but > apparently a plain unwrapped

Re: atoms, memoize, future-s and CAS

2014-12-08 Thread Michał Marczyk
On 8 December 2014 at 21:46, Fluid Dynamics wrote: > [...] > Which means it's locking or bust. You just get to either do the locking > yourself or delegate :) Sure, but isn't it nice when somebody else does your locking for you? :-) Incidentally, there is a trade-off here between lockless reads

Re: atoms, memoize, future-s and CAS

2014-12-08 Thread Michał Marczyk
like (fn [old-state] (if (contains? old-state :foo) (assoc old-state :foo (delay (foo))) old-state)) I'd probably prefer a CHM for this purpose, though. Michał On 8 December 2014 at 21:33, Michał Marczyk wrote: > On 8 December 2014 at 17:54, Andy L wrote: >

Re: atoms, memoize, future-s and CAS

2014-12-08 Thread Michał Marczyk
On 8 December 2014 at 17:54, Andy L wrote: >> But I'd personally just use a delay rather than "locking" for this >> purpose. > > > It is not that I like locking at all. However I still fail to see, how in a > multithreaded context memoize/cache prevents executing a given function more > than once

[ANN] ctries.clj, a Clojure implementation of Ctries

2014-12-07 Thread Michał Marczyk
Hi, I am pleased to announce the initial release of ctries.clj, a port of the original Scala implementation of this fascinating data structure with a Clojure API that allows usage scenarios such as this: (def x (ct/concurrent-map :foo 1)) ;; @ takes independently mutable snapshots; ;; persi

Re: Using an atom for a caching map

2014-09-02 Thread Michał Marczyk
java.util.concurrent.ConcurrentHashMap has a putIfAbsent method that could be used with delays to support this use case with a no recomputation guarantee: (def chm (java.util.concurrent.ConcurrentHashMap.)) ;; this will work as expected whether chm has a value for :foo or not (let [d (delay (+ 1

Re: Benchmarking structural sharing

2014-08-12 Thread Michał Marczyk
It seems hard to answer in a completely generic fashion. If there's a certain collection of vectors which you'd like to share structure, it may be possible to put a number on the degree of sharing achieved by examining the internals of those vectors. That wouldn't address the issue of intermediate

Re: printing lazy lists

2014-05-15 Thread Michał Marczyk
Use pr-str: user=> (str (lazy-seq (list 1 2 3))) "clojure.lang.LazySeq@7861" user=> (pr-str (lazy-seq (list 1 2 3))) "(1 2 3)" Cheers, Michał On 15 May 2014 16:29, Phillip Lord wrote: > > > I am trying to dump a representation of the contents of a list to file. > I've recently changed how I ge

Re: test.check

2014-05-14 Thread Michał Marczyk
Sure, here's a possible approach: user> (gen/sample (gen/fmap (partial apply concat) (gen/list (gen/fmap #(repeat 3 %) gen/int (() () (0 0 0) (3 3 3 3 3 3 2 2 2) (3 3 3 2 2 2 0 0 0 3 3 3) (2 2 2) (-4 -4 -4 -6 -6 -6) (4 4 4 5 5 5) (7 7 7 3 3 3) (3 3 3 7 7 7 9 9 9 7 7 7 4 4 4 -4 -4 -4))

Re: Expected inconsistency between set and map w/ ArrayList?

2014-05-13 Thread Michał Marczyk
any case I kind of like the separate isAlien. On 13 May 2014 14:47, Michał Marczyk wrote: > Unfortunately the Guava example means that this approach doesn't > really solve the problem at hand... Thanks for pointing it out. > > The earlier version with the three-way tes

Re: Expected inconsistency between set and map w/ ArrayList?

2014-05-13 Thread Michał Marczyk
Unfortunately the Guava example means that this approach doesn't really solve the problem at hand... Thanks for pointing it out. The earlier version with the three-way test in place of the "java.util." check should be semantically correct, at least. On 13 May 2014 14:40, Michał

Re: Expected inconsistency between set and map w/ ArrayList?

2014-05-13 Thread Michał Marczyk
2014 14:20, Michał Marczyk wrote: > It's not just to facilitate inlining, but also to limit the perf hit > for hashing non-collections, some of which make completely reasonable > map keys and set members. I've used the classes Alex Miller mentioned > he was interested in for ben

Re: Expected inconsistency between set and map w/ ArrayList?

2014-05-13 Thread Michał Marczyk
; implementations, but push the "default" cases down into the bottom of that > method. > > > On Tuesday, May 13, 2014 12:38:54 AM UTC-4, Michał Marczyk wrote: >> >> I've posted a patch that makes java.util.{List,Map,Map.Entry,Set} >> hashes consistent

Re: Expected inconsistency between set and map w/ ArrayList?

2014-05-12 Thread Michał Marczyk
I've posted a patch that makes java.util.{List,Map,Map.Entry,Set} hashes consistent with those of appropriate Clojure collection types on the ticket. Performance of repeated hasheq lookups on a single PHM actually seems to be slightly better with this patch applied. Adding the hasheqs of a PHM, a

Re: Immutable or Effectively Immutable?

2014-05-06 Thread Michał Marczyk
vec with a short array of objects is a special case in that it simply puts the existing array in a PersistentVector wrapper: user=> (def arr (object-array 16)) #'user/arr user=> (doseq [i (range 16)] (aset arr i i)) nil user=> (def v (vec arr)) #'user/v user=> v [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14

Re: [ANN] data.avl 0.0.12 -- sorted collections with slice, nth, transient support

2014-04-29 Thread Michał Marczyk
4 outliers in 60 samples (6.6667 %) low-severe 4 (6.6667 %) Variance from outliers : 1.6389 % Variance is slightly inflated by outliers On 24 April 2014 08:51, Michał Marczyk wrote: > Cheers Alex! > > See below for the results of yesterday's run of my benchmark suite for > t

Re: [ANN] data.avl 0.0.12 -- sorted collections with slice, nth, transient support

2014-04-23 Thread Michał Marczyk
2.115402 ns nil On 23 April 2014 18:37, Alex Miller wrote: > Great work as always! > > Are there any places where data.avl performs worse than the built-in sorted > maps and sets? > > > On Wednesday, April 23, 2014 7:59:59 AM UTC-5, Michał Marczyk wrote: >> >> Hi, >&

[ANN] data.avl 0.0.12 -- sorted collections with slice, nth, transient support

2014-04-23 Thread Michał Marczyk
Hi, I am pleased to announce the 0.0.12 release of data.avl, a Clojure Contrib library providing drop-in replacements for Clojure(Script)'s built-in sorted maps and sets with additional functionality: 1. real (non-view) logarithmic-time slicing and splits; 2. logarithmic-time nearest neighbour

[ANN] core.rrb-vector 0.0.11 -- Clojure 1.6 compatibility and bug fixes

2014-03-30 Thread Michał Marczyk
Hi, I am pleased to announce the 0.0.11 release of core.rrb-vector, a Clojure Contrib library extending the Clojure vector API with logarithmic-time concatenation and slicing: https://github.com/clojure/core.rrb-vector [org.clojure/core.rrb-vector "0.0.11"] org.clojure core.rrb-v

Re: Catching exception - lazy eval, lambdas and protocols

2014-03-30 Thread Michał Marczyk
The problem is that inner-lazy is a method of AProto which is implemented for ARecord, but actually called (in trigger-fn) on a vector of two ARecords. The exception thrown is an IllegalArgumentException complaining about the missing method. inner-lazy2 works, because it's just a regular function.

[ANN+RFC] data.avl 0.0.12-alpha1 -- sliceable & splittable sorted collections

2014-03-22 Thread Michał Marczyk
Hi, I am pleased to announce the 0.0.12-alpha1 release of data.avl, a Clojure Contrib library providing drop-in replacements for Clojure(Script)'s built-in sorted maps and sets with additional functionality including support for real (non-view) logarithmic-time slicing, splits, nearest neighbour l

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

2014-03-22 Thread Michał Marczyk
On 22 March 2014 00:47, Stefan Kamphausen wrote: > On Saturday, March 22, 2014 12:41:55 AM UTC+1, Andy Fingerhut wrote: >> That is odd. This is a shot in the dark, and probably unhelpful because I >> do not know a good way to verify whether my guess is true, but perhaps the >> seqFrom method went

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

2014-03-20 Thread Michał Marczyk
We're vulnerable to this problem anyway as long as hashing is deterministic, which is why I think it would be cool to use some universal-hashing-like scheme... I think Murmur3 actually uses a seed that could be randomized? Not really "safe" in the cryptographic sense of the word, but would make th

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

2014-03-20 Thread Michał Marczyk
On 19 March 2014 21:14, Alex Miller wrote: > Rich just pushed a change to the String hashing to address this. We're > going to grab the string hashcode (which is cached after first call) and > murmur the result of that. This gives us constant time hashcode after first > call with better distribut

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

2014-03-19 Thread Michał Marczyk
Hashes are cached for Clojure collections, keywords and symbols, but not for strings. I wonder if people who report these perf regressions use long string keys in their maps... For this to explain the regression they'd have to be looking up the same String objects a lot, of course (else hashCode c

Re: weird bug with cljs.core.async + macros

2014-02-18 Thread Michał Marczyk
that is O(log n) worst case (if > using Red-Black trees) or O(1) average case (hashing) > > * (get { ... } key) does not have integer/string limitation > > Therefore: why are we not "compiling down to get" ? Are the big-Oh > constants enormous? > > On Tue,

Re: weird bug with cljs.core.async + macros

2014-02-18 Thread Michał Marczyk
.clojure.org/jira/browse/CLJS-713. > > David > > > On Tue, Feb 18, 2014 at 4:35 PM, t x wrote: >> >> Looking at >> https://github.com/clojure/clojurescript/blob/r2156/src/clj/cljs/core.clj#L1144-L1147 >> , you win. :-) >> >> On Tue, Feb 18, 2014

Re: weird bug with cljs.core.async + macros

2014-02-18 Thread Michał Marczyk
On 18 February 2014 22:31, Michał Marczyk wrote: > Actually in ClojureScript case dispatch is O(n), since it's > implemented as a macro expanding to cond. As of release 2156: https://github.com/clojure/clojurescript/blob/r2156/src/clj/cljs/core.clj#L1119 -- You received this mess

Re: weird bug with cljs.core.async + macros

2014-02-18 Thread Michał Marczyk
On 18 February 2014 22:15, t x wrote: > I've picked case over cond/condp because I want a O(1) dispatch > rather than linear execution since there are many patterns [though I'm > probably guilty of premature optimization here]. Actually in ClojureScript case dispatch is O(n), since it's impleme

Re: weird bug with cljs.core.async + macros

2014-02-18 Thread Michał Marczyk
On 18 February 2014 02:14, t x wrote: > Does this mean: > (a) the reported behavior is normal (and my bug report is invalid) or > (b) this error happens in both cljs + clojure ? I'd say (b). -- You received this message because you are subscribed to the Google Groups "Clojure" group. To p

Re: weird bug with cljs.core.async + macros

2014-02-17 Thread Michał Marczyk
Just to be clear, the above is a version of t x's bug-report modified to use a StringWriter instead of console.log. Cheers, Michał On 18 February 2014 01:25, Michał Marczyk wrote: > The same thing happens in Clojure: > > (defmacro silly [object pat1 body1 pat2 body2] > `(c

Re: weird bug with cljs.core.async + macros

2014-02-17 Thread Michał Marczyk
The same thing happens in Clojure: (defmacro silly [object pat1 body1 pat2 body2] `(case (:tag ~object) ~pat1 ~body1 ~body2)) (def out (java.io.StringWriter.)) (defn log [& args] (doseq [arg args] (.write out (str arg)) (.write out "\n"))) (defn init [] (silly {:tag :dog

Re: rseq for subvec in clojurescript

2014-02-16 Thread Michał Marczyk
It is now, thanks for the report! Ticket with patch: http://dev.clojure.org/jira/browse/CLJS-765 On 16 February 2014 17:48, Sunil S Nandihalli wrote: > Hi Everybody, > > I get the following error when I do a rseq on a subvec in clojurescript > Uncaught Error: No protocol method IReversible.-rs

Re: range-sum

2014-02-13 Thread Michał Marczyk
str is much faster with apply than with reduce; in fact, with reduce it is O(n^2), whereas with apply it is O(n). (The constants are better with apply too.) In general, (apply foo ...) takes advantage of any optimizations the author of foo might be aware of for speeding up its operation when given

Re: map semantics

2014-02-09 Thread Michał Marczyk
The Contrib library algo.generic provides a function fmap which does preserve the type of its input. As for the idea that clojure.core/map should preserve type, it's worth remembering that in order to map a function over a set and return a set, we must do two things: (1) apply the function to each

Re: Confused by Clojure floating-point differences (compared to other languages)

2014-02-05 Thread Michał Marczyk
This returns (.getTotalPhysicalMemorySize (java.lang.management.ManagementFactory/getOperatingSystemMXBean)) You could use this in your project.clj, perhaps by including ~(str "-Xms" (quot (.getTotalPhysicalMemorySize ...) appropriate-number)) in :jvm-opts. Also, you can absolutely use your ow

Re: how does source work?

2014-02-04 Thread Michał Marczyk
source-fn is a private Var in the clojure.repl namespace; you can still use source to display its definition, but you'll have to use the fully qualified name: user=> (source clojure.repl/source-fn) (defn source-fn "Returns a string of the source code for the given symbol, if it can find it. T

Re: order of returned values from keys and vals

2014-02-01 Thread Michał Marczyk
Oh, sorry, for some reason Gmail didn't alert me to some of the recent messages coming in while I was viewing this thread. On 2 February 2014 05:32, Michał Marczyk wrote: > I'd expect > > (persistent! > (reduce-kv (fn [acc k v] (assoc! acc k (inc v))) > (tran

Re: order of returned values from keys and vals

2014-02-01 Thread Michał Marczyk
eySeq defines first/next, but never >> explicitly walks the seq. >> >> That's left to the user of the KeySeq. >> >> Thanks, >> Ambrose >> >> >> On Sun, Feb 2, 2014 at 12:18 PM, Michał Marczyk wrote: >> >> On 2 February 2014 05:1

Re: order of returned values from keys and vals

2014-02-01 Thread Michał Marczyk
That doesn't mean that we're not walking the seq twice, however. keys and vals work off of separate calls to seq on the map, which of necessity produce distinct seq objects (otherwise traversing a seq over a map would permanently increase its memory consumption). On 2 February 2014 05:

Re: order of returned values from keys and vals

2014-02-01 Thread Michał Marczyk
On 2 February 2014 05:14, Justin Smith wrote: > Pardon my ignorance but if this is producing a lazy result, how is it > doing so? > > https://github.com/clojure/clojure/blob/dff9600387b962f16fc78e6477e10e34651fd366/src/jvm/clojure/lang/APersistentMap.java#L134 > APersistentMap's KeySeq.create an

Re: order of returned values from keys and vals

2014-02-01 Thread Michał Marczyk
On 2 February 2014 04:54, Ambrose Bonnaire-Sergeant < abonnaireserge...@gmail.com> wrote: > zipmap could also potentially use transients (which would be a nice > addition). > My patch for this has been waiting in JIRA since end of May 2012: http://dev.clojure.org/jira/browse/CLJ-1005 Cheers, Mi

Re: core.async over websocket + cljs + clojure

2014-01-25 Thread Michał Marczyk
If the application is structured in such a way that messages from the other side of the client/server divide are put on channels upon arrival, which seems to be a reasonable idea, why not encapsulate the connection-handling logic in a black box exposing a (bunch of) channel(s)? On 26 January 2014

Re: avoiding repetition in ns declarations

2014-01-22 Thread Michał Marczyk
Not addressing the main problem, but require takes multiple libspecs, so you can write (ns foo (:require [foo.bar :as bar] [foo.quux :as quux])) to avoid repeating the keyword, at least. :require in ns expands to a call to require-the-function, so the latter supports multiple

Re: closing-buffer

2014-01-14 Thread Michał Marczyk
lt! / alts! approach works satisfactorily, or if another approach based on the available public primitives does, I'd definitely avoid implementing new funky stuff. Fun problem to think about, though. On 14 January 2014 09:47, Michał Marczyk wrote: > A sketch of a different approach: > > a

Re: closing-buffer

2014-01-14 Thread Michał Marczyk
f the timing is that close, the end result is no different to what would happen had we arrived at a slightly later time. On 14 January 2014 09:37, Michał Marczyk wrote: > Ah, of course, the mutex is not reentrant. > > So, one possible way to fix the situation would be to close the own

Re: closing-buffer

2014-01-14 Thread Michał Marczyk
t; * > https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/impl/channels.clj#L55 > > isn't this a deadlock by acquiring the mutex while holding the mutex? > > > On Mon, Jan 13, 2014 at 10:27 PM, Michał Marczyk > wrote: >> >> Instead of ac

Re: closing-buffer

2014-01-13 Thread Michał Marczyk
Instead of actually implementing a new channel type, you could use the regular MTMCs, but with your own factory function, custom buffers and a sprinkle of mutability: (defprotocol PBufferThatMightCloseAChannel (this-is-your-channel! [this c] "Informs the buffer that c is the channel it might

[ANN] data.avl 0.0.11 -- transient-enabled sorted maps and sets with nth

2014-01-08 Thread Michał Marczyk
Hi, I am pleased to announce that version 0.0.11 of data.avl, a Clojure Contrib library implementing drop-in replacements for Clojure(Script)'s core sorted collections, is now available from Maven Central. See below for more information. Changes in this release: * two bugs squashed in the Cloju

Re: [ANN] data.avl 0.0.10 -- fast sorted maps and sets with log-time rank queries

2014-01-06 Thread Michał Marczyk
On 6 January 2014 00:33, Brandon Bloom wrote: > Michał: This is awesome. Thanks for the continued awesome work on data > structures! > >> >> ;; if the key is not present in the collection, -1 is returned: >> (avl/rank-of (avl/sorted-set 3 4 5) 0) >> ;= -1 > > > Curious: Why not return nil in

[ANN] data.avl 0.0.10 -- fast sorted maps and sets with log-time rank queries

2014-01-04 Thread Michał Marczyk
Hi, I am pleased to announce the initial Clojure Contrib release of data.avl (previously known as avl.clj), a library implementing drop-in replacements for Clojure(Script)'s sorted maps and sets with faster lookups, support for the transient API (leading to unambiguously improved performance for m

[ANN] core.rrb-vector 0.0.10 -- vector concatenation for Clojure(Script)

2014-01-04 Thread Michał Marczyk
Hi, I am pleased to announce the immediate availability of version 0.0.10 of core.rrb-vector, a Clojure Contrib library enabling logarithmic-time concatenation and slicing of Clojure(Script) vectors. Leiningen: [org.clojure/core.rrb-vector "0.0.10"] Maven: org.clojure core.rrb-vec

Re: bug in clojure.zip when calling next on empty list node?

2013-12-31 Thread Michał Marczyk
No worries. Incidentally, akhudek's fast-zip seems to have the same issue. Here's a PR fixing it: https://github.com/akhudek/fast-zip/pull/3 Cheers, Michał On 1 January 2014 02:12, Lee Spector wrote: > > On Dec 31, 2013, at 6:53 PM, Michał Marczyk wrote: > >> Ticket

Re: bug in clojure.zip when calling next on empty list node?

2013-12-31 Thread Michał Marczyk
s fixing, but I think the current behaviour makes sense; perhaps the docstring should be adjusted, though. Cheers, Michał On 1 January 2014 00:53, Michał Marczyk wrote: > Ticket with patch at > > http://dev.clojure.org/jira/browse/CLJ-1317 > > The problem is that seq-zip uses

Re: bug in clojure.zip when calling next on empty list node?

2013-12-31 Thread Michał Marczyk
Ticket with patch at http://dev.clojure.org/jira/browse/CLJ-1317 The problem is that seq-zip uses clojure.core/identity as the "children" argument to zipper. Applied to (), this returns (), but clojure.zip expects the "children" function to return nil when there are no children. The patch attache

Re: When does clojure.lang.PersistentArrayMap become clojure.lang.PersistentHashMap

2013-12-23 Thread Michał Marczyk
On 24 December 2013 07:35, Michał Marczyk wrote: > ;; persistent maps only > (instance? clojure.lang.IPersistentMap %) Additionally, this one's better written (map? %) (map? is in fact defined as instance? IPM.) Cheers, M. > > ;; all Java maps > (instance? java.util.Map %

Re: When does clojure.lang.PersistentArrayMap become clojure.lang.PersistentHashMap

2013-12-23 Thread Michał Marczyk
;; persistent maps only (instance? clojure.lang.IPersistentMap %) ;; all Java maps (instance? java.util.Map %) On 24 December 2013 04:28, larry google groups wrote: > I find this surprising. I do this: > > (supers %) > > inside of my :post condition, and I get: > > java.lang.ClassCastException:

Re: core.async timeout channels are values - is this intended

2013-11-20 Thread Michał Marczyk
t;> timeout channels in two different alts, and if the timeout channels are >> aliased, then perhaps only one of the alts would actually get notified. >> >> >> On Wed, Nov 20, 2013 at 5:05 AM, Michał Marczyk >> wrote: >>> >>> The reason = considers

Re: core.async timeout channels are values - is this intended

2013-11-20 Thread Michał Marczyk
le bug into the library? One could use "two different" > timeout channels in two different alts, and if the timeout channels are > aliased, then perhaps only one of the alts would actually get notified. > > > On Wed, Nov 20, 2013 at 5:05 AM, Michał Marczyk > wrote: &

Re: core.async timeout channels are values - is this intended

2013-11-20 Thread Michał Marczyk
The reason = considers you timeout channels to be equal is that they are, in fact, the same object. In fact, they may end up being the same object even with different timeout values: (identical? (timeout 1) (timeout 2)) ;= true Except I got a false just now with a fresh REPL and same timeout valu

Re: Functions using locks are slowed even when locks are never taken

2013-11-03 Thread Michał Marczyk
g o >> (dec x >> >> foo' is fast, but foo'' is slow. So something about wrapping the locking >> clause in a let makes it fast. Still no idea why. >> >> On Sunday, November 3, 2013 9:30:45 AM UTC-8, Michał Marczyk wrote: >>> >>>

Re: Functions using locks are slowed even when locks are never taken

2013-11-03 Thread Michał Marczyk
2 is printed NB. this could also happen with alter-var-root or set! to a Var with a thread-local binding. Cheers, Michał On 3 November 2013 18:30, Michał Marczyk wrote: > You have a typo in foo -- monitor-exit's argument is 0 (zero) rather > than o (the sentinel object). > > Bes

Re: Functions using locks are slowed even when locks are never taken

2013-11-03 Thread Michał Marczyk
You have a typo in foo -- monitor-exit's argument is 0 (zero) rather than o (the sentinel object). Besides that, in foo both monitor-enter and monitor-exit get their arguments from a Var. Rewriting to use locking, which first puts the object whose monitor will be used in a local (that is, (let [lo

Re: About with-meta source, can explain it by itself?

2013-09-21 Thread Michał Marczyk
trange, thank you > very much! > (def with-meta (fn ^:static with-meta [^clojure.lang.IObj x m] > (. x (withMeta m > > > On Saturday, September 21, 2013 3:30:30 PM UTC+8, Michał Marczyk wrote: >> >> Actually with-meta's definitio

Re: About with-meta source, can explain it by itself?

2013-09-21 Thread Michał Marczyk
Actually with-meta's definition does not refer to with-meta. Rather, it calls withMeta, a method in the clojure.lang.IObj interface which the first argument to with-meta is supposed to implement. Cheers, Michał On 21 September 2013 09:01, wrote: > Hi, > I read the source about with-meta, and

Re: [ANN] avl.clj: sorted maps and sets with fast rank queries via nth

2013-09-21 Thread Michał Marczyk
hmark results to clojure-dev; I'll post a similar message here once I'm ready to cut an 0.1.0 release (which basically needs more tests for added confidence, a test suite on the ClojureScript side and such). Cheers, Michał On 21 September 2013 04:28, Michał Marczyk wrote: > On 21 Se

Re: [ANN] avl.clj: sorted maps and sets with fast rank queries via nth

2013-09-20 Thread Michał Marczyk
On 21 September 2013 02:42, Michał Marczyk wrote: > [avl.clj "0.0.1"] > > > avl.clj > avl.clj > 0.0.1 > Make that [avl.clj "0.0.2"] and avl.clj avl.clj 0.0.2 Cheers, Michał -- --

[ANN] avl.clj: sorted maps and sets with fast rank queries via nth

2013-09-20 Thread Michał Marczyk
Hi, I have just released avl.clj, a library implementing drop-in replacements for Clojure(Script)'s sorted maps and sets which additionally support the transients API and logarithmic time rank queries via clojure.core/nth: (require '[avl.clj :as avl]) (nth (apply avl/sorted-set (range 10

Re: [ANN] Leiningen 2.3.0 released

2013-08-10 Thread Michał Marczyk
On 10 August 2013 08:39, Michael Klishin wrote: > I personally think there should be a fallback location for the jar that does > not use SSL. As long as it isn't used automatically or after flashing a y/n prompt. (Offering a flag like --no-ssl and mentioning it to the user when appropriate would

Re: primitive array casts

2013-07-20 Thread Michał Marczyk
Also, ^foo-style hints are "soft hints" in the following sense: (let [^ints xs [1 2 3]] xs) ; no complaint from compiler or RTE In contrast, ints & Co. demand that the casts be correct: (let [xs (ints [1 2 3])] xs) ; ClassCastException On 20 July 2013 11:29, Michał Marczyk

Re: primitive array casts

2013-07-20 Thread Michał Marczyk
)] (aget xs 0)) (let [^ints xs (get-some-ints)] (aget xs 0)) Cheers, Michał On 20 July 2013 11:25, Michał Marczyk wrote: > I think it's more about clojure.core/{ints,longs,...}. These are > basically tools for removing reflection: > > (let [xs (ints (get-some-ints))] >

Re: primitive array casts

2013-07-20 Thread Michał Marczyk
I think it's more about clojure.core/{ints,longs,...}. These are basically tools for removing reflection: (let [xs (ints (get-some-ints))] (aget xs 0)) ; no reflection here thanks to the cast Cheers, Michał On 20 July 2013 10:47, Mikera wrote: > Do you mean something like (int-array [1 2 3

Re: Proposed change to let-> syntax

2013-07-19 Thread Michał Marczyk
On 19 July 2013 10:24, Daniel Dinnyes wrote: > Why don't we have a "candidate" name-space, a separate library, like the > contrib before, which most people who prefer to be on the cutting edge just > include automatically. That would give reasonable feedback on how much > traction new stuff like t

  1   2   3   4   5   >