Hi,
I sometimes (in fact quite often) want to use the - macro like this:
(- {}
(assoc :a a)
(assoc :b (some-fn CTX)))
where CTX should be the current value of the threaded element. Currently,
I'm forced to write a helper function
(defn add-some-fn [ctx]
(assoc ctx :b (some-fn ctx)))
Hi,
since 1.5 there is
as-http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/as-
:
(as- {} ctx
(assoc ctx :a a)
(assoc ctx :b (some-fn ctx)))
Kind regards
Meikel
--
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to
That looks like it can do the job; thanks!
On Tuesday, July 2, 2013 8:12:04 AM UTC+2, Meikel Brandmeyer (kotarak)
wrote:
Hi,
since 1.5 there is
as-http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/as-%3E
:
(as- {} ctx
(assoc ctx :a a)
(assoc ctx :b (some-fn
On 1 July 2013 21:39, Cedric Greevey cgree...@gmail.com wrote:
What bugs me is that sorted-set-by needs apply to convert a coll into
a sorted set; there's no short-and-pithy into for that case, and no
coll-taking and varargs version pair like vec/vector either.
(into (sorted-set) coll)
--
Er...that won't use my custom comparator. :)
On Tue, Jul 2, 2013 at 2:40 AM, Ray Miller r...@1729.org.uk wrote:
On 1 July 2013 21:39, Cedric Greevey cgree...@gmail.com wrote:
What bugs me is that sorted-set-by needs apply to convert a coll into
a sorted set; there's no short-and-pithy into
Hi all
my english poor i hope someone could know what i said.
i create Var in Java
such as
RT(mysapce xv object);
and then i load a clj file
RT.loadResourceScript(xx.clj);
the question is how to get Value of xv in xx.clj
and could reload it in nrepl.
i try to do something like
(use
On 2 July 2013 08:10, Cedric Greevey cgree...@gmail.com wrote:
Er...that won't use my custom comparator. :)
Sorry, I thought it was clear how to generalize from my previous example.
Here it is with a custom comparator:
(into (sorted-set-by ) [1 2 4 2 1 2 3])
;; = #{4 3 2 1}
On Tue, Jul 2,
One things that always bugged me about clojure is that most functions that
work on collections return seqs and not the original data structure type:
(= [2 4 6] (- [2 [4]] flatten (conj 6)))
= false
Every time I transform collections I need to be aware of this.
My questions is: is there a
Still seems verbose compared to (into #{}) ...
On Tue, Jul 2, 2013 at 4:41 AM, Ray Miller r...@1729.org.uk wrote:
On 2 July 2013 08:10, Cedric Greevey cgree...@gmail.com wrote:
Er...that won't use my custom comparator. :)
Sorry, I thought it was clear how to generalize from my previous
On 02/07/13 09:45, Islon Scherer wrote:
My questions is: is there a philosophical reason for that or it was
implement this way because it's easier?
the reason is that there is a common underlying abstraction tying all
these data-structures together and that is the 'Seq' abstraction. conj
is
It's not really breaking principle of least surprise if you expect such
functions to return sequences. A lot of people do expect this after a
little bit of Lisp experience (Clojure or otherwise)
I can see two advantages to having many functions return seqs:
- It's a shared abstraction, which
This is cool, thanks Zach!
Another set of mostly-isomporphic types that this could be applied to is
different matrix/array types in core.matrix. core.matrix already has
generic conversion mechanisms but they probably aren't as efficient as they
could be. I'll take a look and see if the same
Is there reset! and merge a possibility for (transient {})
sometimes we have a doseq and it might be requirement sometime.
--
--
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
Hi,
how we can achieve reset! and merge for (transient {})
e.g. when we have a doseq
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 from new members are
No merge will not work with transients because it uses conj instead of
conj!
If you absolutely have to do this define your own 'merge!' that uses conj!.
I'm not sure what you mean by reset! for transients...reset! is an
operation on reference types (atom, ref, agent etc)
Jim
On 02/07/13
If you really need to write functions that are polymorphic on collections
type, then you can use the idiom:
(defn some-fn
[xs]
(into (empty xs)
...
))
But there is value in having the return type of a function to be
predictable.
--
Dave
--
--
You received this message because you
On 02/07/13 11:48, David Powell wrote:
If you really need to write functions that are polymorphic on
collections type, then you can use the idiom:
(defn some-fn
[xs]
(into (empty xs)
...
))
hehe :) good one!
...in other words you can piggyback 'conj'...
Jim
--
--
You received
Maybe he means clear?
2013/7/2 Jim jimpil1...@gmail.com
No merge will not work with transients because it uses conj instead of
conj!
If you absolutely have to do this define your own 'merge!' that uses conj!.
I'm not sure what you mean by reset! for transients...reset! is an
operation on
what is 'clear' ? cannot find it anywhere...
Jim
On 02/07/13 12:03, dennis zhuang wrote:
Maybe he means clear?
2013/7/2 Jim jimpil1...@gmail.com mailto:jimpil1...@gmail.com
No merge will not work with transients because it uses conj
instead of conj!
If you absolutely have to do
Clear the collection.
user= (doc empty)
-
clojure.core/empty
([coll])
Returns an empty collection of the same category as coll, or nil
nil
2013/7/2 Jim jimpil1...@gmail.com
what is 'clear' ? cannot find it anywhere...
Jim
On 02/07/13 12:03, dennis zhuang wrote:
Thanks for all the answers.
Agreed that sequences are a great abstraction (100 functions in 1 data
structure instead of 10 to 10) and, as David said, there's value in having
the return type to be predictable.
I think a 'generics collection functions' library would be nice for those
edge cases
On 02/07/13 12:42, Islon Scherer wrote:
Well, maybe most of the time, but there's cases where the concrete
type semantics matters a lot, specially with sets but sometimes with
vectors too, right now i'm using into or just calling vec|set or
reducers library but maybe I'll try to implement this
I have already used this library and it is really really useful. Thanks
Zach.
Thomas
--
--
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 -
I believe the intended idiom for as- (and the reason it doesn't take a
binding vector, like other forms that create locals) is
(- {}
(assoc :a a)
(as- ctx
(assoc ctx :b (some-fn ctx
On Jul 2, 2013 1:12 AM, Meikel Brandmeyer (kotarak) m...@kotka.de wrote:
Hi,
since 1.5 there is
Note that `merge` is basically just `conj` plus nil-checking, so there's a
good chance `conj!` already does what you need.
On Jul 2, 2013 5:33 AM, Amir Wasim amir.wa...@gmail.com wrote:
Is there reset! and merge a possibility for (transient {})
sometimes we have a doseq and it might be
Introducing lein-spell, https://github.com/cldwalker/lein-spell - a library
to quickly and easily spell check your clojure libraries.
Usage
-
lein-spell prints misspelled words, one per line to STDOUT.
By default your library's docstrings and markdown/txt docs are searched:
$ lein-spell
On Tue, Jul 2, 2013 at 4:45 AM, Islon Scherer islonsche...@gmail.com wrote:
One things that always bugged me about clojure is that most functions that
work on collections return seqs and not the original data structure type:
(= [2 4 6] (- [2 [4]] flatten (conj 6)))
= false
Every time I
Ropes?
http://en.m.wikipedia.org/wiki/Rope_(data_structure)
Ben
--
This message was sent via electromagnetism.
On 02.07.2013, at 12:19, Mikera mike.r.anderson...@gmail.com wrote:
This is cool, thanks Zach!
Another set of mostly-isomporphic types that this could be applied to is
different
Hello all.
I have a following deftype:
(deftype NDArray
[^objects data
^long ndims
^longs shape
^longs strides])
(
https://github.com/si14/matrix-api/blob/70b376f58ec3846df6622b971001c3ade32d0725/src/main/clojure/clojure/core/matrix/impl/ndarray.clj#L30
)
Then, when I use
On 02/07/13 15:41, Dmitry Groshev wrote:
(let […
#^[Ljava.lang.Object; data (.data m)
…]
(aset data idx v
that is exactly how you type-hint non-primitive arrays...agreed it's
ugly but there is no other way :)
Jim
--
--
You received this message because you are
Jason, can you please help me with this:
I'm not sure if the protocol-based implementation can give users any help
writing new core operations efficiently (say, making a new array with
c[i] = a[i] + b[i]^2 / 2) -- unless there's some clever way of
combining protocols with macros (hmmm).
I think that is the only way.
The good news is that this is Clojure, so you can easily wrap it in an
object-array-cast macro
On Tuesday, 2 July 2013 15:41:02 UTC+1, Dmitry Groshev wrote:
Hello all.
I have a following deftype:
(deftype NDArray
[^objects data
^long ndims
= (def a (object-array 1))
#'user/a
= (set! *warn-on-reflection* true)
true
= (aset a 0 nil)
Reflection warning, NO_SOURCE_PATH:1:1 - call to aset can't be resolved.
nil
= (aset ^objects a 0 nil)
nil
hth,
Christophe
On Tue, Jul 2, 2013 at 5:13 PM, Mikera mike.r.anderson...@gmail.com wrote:
Hi all,
I'd like to get some feedback on an approach I took to limit the
concurrency of parallel processing in some of my Clojure codebase.
I've often found that I want to split work over some number of threads
greater than CPUs + 2, but less than infinity. In the past I had used
promises
Thank you, works like a charm and makes my code smell better.
On Tuesday, July 2, 2013 8:48:14 PM UTC+4, Christophe Grand wrote:
= (def a (object-array 1))
#'user/a
= (set! *warn-on-reflection* true)
true
= (aset a 0 nil)
Reflection warning, NO_SOURCE_PATH:1:1 - call to aset can't be
I'm really sorry for coming back to this but even after everything we
learned I'm still not able to get performance equal to java in a simple
factorial benchmark. I'd like to think that I'm doing all the correct
things to keep the comparison fair...observe this:
benchmarks.core= (crit/bench (jf!
I am pleased to announce a first public release of new (and different)
monads and friends library for Clojure.
Extensive *documentation* is at http://fluokitten.uncomplicate.org
Fluokitten is a Clojure library that implements category theory concepts,
such as functors, applicative functors,
Try longs instead of ints? Clojure doesn't support local ints, so you may
be casting longs to ints a lot.
On Tue, Jul 2, 2013 at 11:05 AM, Jim - FooBar(); jimpil1...@gmail.comwrote:
I'm really sorry for coming back to this but even after everything we
learned I'm still not able to get
2013/7/2 Dragan Djuric draga...@gmail.com
I am pleased to announce a first public release of new (and different)
monads and friends library for Clojure.
Extensive *documentation* is at http://fluokitten.uncomplicate.org
Good job, Dragan!
--
MK
http://github.com/michaelklishin
with a long counter it needs slightly longer (216 microseconds in
average instead of 196)!
any other ideas?
On 02/07/13 19:11, Leon Barrett wrote:
Try longs instead of ints? Clojure doesn't support local ints, so you
may be casting longs to ints a lot.
On Tue, Jul 2, 2013 at 11:05 AM, Jim -
Rob,
Sorry for the late reply. I've been a bit distracted the past few days.
I'll try to address your thoughts as best I can.
*There could even be a grid protocol and fluid, responsive, fixed, mobile,
etc be implementations of it, or multi-methods, or maybe its an overkill.*
I don't think this
a purely stylistic comment...
you may want to consider 'with-resources' to get rid of all the
try/finally clutter. I'd write your let statement like this:
(let [step (fn [x]
(with-resources [sem (Semaphore. limit true)]
#(.release ^Semaphore %)
(.acquire
On 02/07/13 18:30, Brian Kirkbride wrote:
In the past I had used promises that were fulfilled by a
FixedThreadPool. But that's a lot of setup and teardown that distracts
from what you're actually trying to achieve.
no it's not...you define it once you use it forever! :)
(defn pool-map
A
On Tuesday, July 2, 2013 1:37:20 PM UTC-5, Jim foo.bar wrote:
a purely stylistic comment...
you may want to consider 'with-resources' to get rid of all the
try/finally clutter. I'd write your let statement like this:
(let [step (fn [x]
(with-resources [sem (Semaphore.
I got nothin'. Stare at the bytecode?
On Tue, Jul 2, 2013 at 11:21 AM, Jim - FooBar(); jimpil1...@gmail.comwrote:
with a long counter it needs slightly longer (216 microseconds in
average instead of 196)!
any other ideas?
On 02/07/13 19:11, Leon Barrett wrote:
Try longs instead of
On 02/07/13 19:49, Brian Kirkbride wrote:
Interesting, I hadn't considered with-resources. I don't think your
code does the same thing, since the release happens in the calling
thread, not inside the future. Right?
oops! you're right...I rushed and I apologise...with-resources won't
work
On 02/07/13 19:49, Brian Kirkbride wrote:
In my case, processing each item can take a while, is not CPU
intensive and their aren't too many items.
so in your case you need an unbounded-pool...my work involves
cpu-intensive tasks and haven't written a version of pool-map that uses
an
On Tuesday, July 2, 2013 1:41:14 PM UTC-5, Jim foo.bar wrote:
On 02/07/13 18:30, Brian Kirkbride wrote:
In the past I had used promises that were fulfilled by a FixedThreadPool.
But that's a lot of setup and teardown that distracts from what you're
actually trying to achieve.
no
Are all Clojure concurrency primitives efficiently implementable on top of
core.async?
If so, could this be used to port Clojure from the JVM/CLR/JS to Go?
--
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
On 02/07/13 20:05, Brian Kirkbride wrote:
One thing that I really like about blocking in acquire vs submitting
everything to an ExecutorService/CompletionService right off the bat:
you can bail out of the remainder of the computation when one part
fails. I've got a function that creates a
I've not looked at core.async yet but I'd expect it to build on top of
the built-in concurrency primitives and not the other way around...
Jim
On 02/07/13 20:12, Robert wrote:
Are all Clojure concurrency primitives efficiently implementable on
top of core.async?
If so, could this be used
I haven't played around with this but it looks as if the second argument to
bind needs to know what kind of monad it's operating in, is that right?
Would it be possible to write agnostic functions like this in this lib?
monads.core (defn tst-reader [f]
(mdo env - ask
also what you're asking doesn't really make sensehow would you
implement synchronisation primitives (stm atoms promises) on top of
asynchronous infrastructure?
agents are asynchronous but I haven't got a clue about the potential
benefits (or not) of implementing them on top of core.async.
I had some time to play with core.async further today, and I learned some
more about it.
First let me say that I've completed the implementation of core.async on
top of Pulsar (I've copied the alt! macro from the core.async repository
and placed a copyright notice around it). I ran some of
I guess this is not connected to our issue.
You're using Clojure's BigInt, which is probably a bit slower than
BigInteger if you know you want it to be big:
user (class 1N)
clojure.lang.BigInt
Have you tried translating your Java code directly to see if that helps?
On Tue, Jul 2, 2013 at
Elastisch [1] is a minimalistic, feature rich, well documented Clojure
client for ElasticSearch.
1.1.1 is a bug fix release.
Release notes:
http://blog.clojurewerkz.org/blog/2013/07/02/elastisch-1-dot-1-1-is-released/
1. http://clojureelasticsearch.info
--
MK
http://github.com/michaelklishin
Pantomime [1] is a tiny Clojure library that deals with MIME types.
Release notes:
http://blog.clojurewerkz.org/blog/2013/07/02/pantomime-1-dot-8-0-is-released/
1. https://github.com/michaelklishin/pantomime
--
MK
http://github.com/michaelklishin
http://twitter.com/michaelklishin
--
--
You
On Tuesday, July 2, 2013 2:13:04 PM UTC-5, Jim foo.bar wrote:
On 02/07/13 20:05, Brian Kirkbride wrote:
One thing that I really like about blocking in acquire vs submitting
everything to an ExecutorService/CompletionService right off the bat:
you can bail out of the remainder of the
No, the second argument to bind only needs to be a function that takes a
plain value and return a monadic value; you do not need to specify anything
explicitly and it does not need to know what kind of monad it is operating
on. Whatever that function returns will be a monad that the eventual
I did look at the docs and I don't really get how to return a monadic value
in the right monad, the way return does automatically. All the examples I
saw have something like vector or atom or what-have-you.
On Tue, Jul 2, 2013 at 2:41 PM, Dragan Djuric draga...@gmail.com wrote:
No, the second
e.g., I'm not sure how to define the function f here:
$ ghci
GHCi, version 7.4.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Prelude let f :: (Monad m) = (a -
When I first wrote this code, I intentionally avoided any custom
syntactical sugar and worked as closely with the primitives as I could.
After a few days away, I've used fresh eyes to abstract and revamp. The new
code is *dramatically* cleaner and I only needed to introduce a few simple
and
These look great!
I would, however, avoid using go-as. In the JCSP example a style such as
this is prefered most of the time:
(defn inc-all
increments every int received in the input channel
([in]
(let [out (chan)]
(inc-all in out)
out))
([in out]
(go (while true
(! out
pure function, defined in applicative, is equivalent to return (In Haskell,
in Fluokitten there is only pure).
I think I understand what is your question now. Since Clojure does not
support polymorphysm based on the returning argument you cannot translate
that Haskell code exactly. For such a
I wanted to say THE pure function. Now I realize that pure function is
ambiguous :)
On Wednesday, July 3, 2013 1:03:26 AM UTC+2, Dragan Djuric wrote:
pure function, defined in applicative, is equivalent to return (In
Haskell, in Fluokitten there is only pure).
I think I understand what is
IMO you *always* want the monad to stay the same---the laws describing
monadic computations don't account for swapping the things out midstream,
at any rate. And it pays to be able to define monadic computations without
having to explicitly pass around a token to serve as the current monad.
FWIW,
And in this case you have to explicitly specify which monad you want to
use, every time you call bind. I understand that in some case it might be a
preferred way, but in my opinion for most cases that I care about I prefer
it the other way.
Regarding monadic laws, which one exactly demands
Hey Mike,
Please feel free to appropriate or adapt any code you think might be
useful. I've signed a CA, it should all be kosher.
As far as an immutable byte-data type, I'm a little skeptical it would be
useful in a wide variety of situations, since a dense array/matrix is going
to be much
On Tue, Jul 2, 2013 at 4:33 PM, Dragan Djuric draga...@gmail.com wrote:
And in this case you have to explicitly specify which monad you want to
use, every time you call bind. I understand that in some case it might be a
preferred way, but in my opinion for most cases that I care about I prefer
On Tue, Jul 2, 2013 at 5:06 PM, Ben Wolfson wolf...@gmail.com wrote:
On Tue, Jul 2, 2013 at 4:33 PM, Dragan Djuric draga...@gmail.com wrote:
Regarding monadic laws, which one exactly demands that you cannot change
the monad (not counting the fact that haskell's implementation does it that
Hi Jim,
I cannot reproduce your results. I see Clojure and Java with similar
performance when they are both using java.lang.BigInteger. Clojure's
arbitrary-precision integer defaults to clojure.lang.BigInt, which in my
test is about 12% slower than java.lang.BigInteger.
See
Puppet Labs [0] [1] builds open source and commercial systems automation
tools. We're in every major linux distribution, and we're managing
literally millions of systems at wide variety of shops (from Google to
GitHub to Spotify to CERN to Pinterest to NYSE ...). Even if you've not
heard of us
Promises and agents are both fairly straightforward. It's STM and atoms
that wouldn't be. But delivering things to blocking channel-gets could be
used as a latch to control access to critical sections, so you could
probably implement ordinary locks on top of core.async, and locks can then
be used
On Tue, Jul 2, 2013 at 3:27 PM, pron ron.press...@gmail.com wrote:
I do forget the meaning of ! and !; I mean, which is send and which is
receive? then I remember, oh, the ! stands for the channel, but again I
forget which side of the bang the arrow goes).
Bang's always on the right, and the
74 matches
Mail list logo