Re: Performant string concatenation (of many, large strings)

2015-02-14 Thread Mikera
If you really care about performance then I would use a macro for code 
generation and do something the following:

(defmacro appendfunc 
 ([m keys sb]
   `(do
  (.append ~sb (~m ~(first keys)))
  ~@(for [k (next keys)]
  `(do 
 (.append ~sb \,)
 (.append ~sb (~m ~k
  (.append ~sb \n

(let [sb (StringBuilder.)
 f (fn [^StringBuilder sb m] (appendfunc m [:one :two :three :four] 
sb))
 maps (repeat 25 {:one 1 :two 2 :three 3 :four 4})]
 (time (let [res (str (reduce f sb maps))] (count res

= Elapsed time: 118.105355 msecs

Could probably optimise a bit more but that's under 400ns per row... pretty 
decent I think.


On Thursday, 12 February 2015 09:25:12 UTC+8, Mark Watson wrote:

 I'm looking for the most performant way to transform a huge seq (size 
 25) of maps into a single CSV.

 The data structure looks something like:

 (def data-struct

   (repeat 25 {:one 1 :two 2 :three 3 :four 4}))


 A naive implementation would be:

 (let [f #(- % (map (comp str val)) (clojure.string/join ,))]

   (- data-struct

 (map f)

 (clojure.string/join \n)))


 However, this takes far too long for my application (an the order of 10s 
 of seconds).

 Another attempt using reducers:

 (require '[clojure.core.reducers :as r])

  

 (let [f #(- % (map (comp str val)) (clojure.string/join ,))

   r-join (fn

([] nil)

  ([x y]

   (if (and x y) (str x \n y)

 (if x (str x)

   (if y (str y))]

   (- data-struct

 (r/map f)

 (r/fold r-join)))


 Still not great.

 But, Looking at the sources of clojure.string/join and clojure.core/str, 
 it becomes apparent that the both implementations create an instance of 
 java.lang.StringBuilder 
 for each element in the sequence. (I have to imagine this is the main 
 issue, even though GC seems to only be ~5% of the runtime)

 Would it make sense to instantiate one java.lang.StringBuilder for all of 
 the concatenation (and call java.lang.StringBuilder append)?

 What's the best way to do this with idiomatic Clojure?

 Thanks a lot!


-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: getting enlive not to parse something

2015-02-14 Thread Sam Raker
I think the easiest solution for me is to just use clj-http to get the 
content of the leaf pages and then hit 'em with a regex. It's not pretty, 
but, then again, neither is the tagsoup documentation.

On Saturday, February 14, 2015 at 1:03:23 PM UTC-5, Herwig Hochleitner 
wrote:

 Enlive by default uses tagsoup to parse html and can also use jsoup, so 
 I'd start with parsing options for those. It can also be used with other 
 parsers, provided you can get them to generate clojure's xml map format.

 2015-02-13 18:55 GMT+01:00 Sam Raker sam@gmail.com javascript::

 I'm trying to parse some stuff with enlive, but part of at least of the 
 pages look like:
 ...
 pre
 ...
 8-bar break...
 ...
 /pre

 Enlive interprets the text in the pointy braces as html, which it isn't, 
 and that's messing up my application. Is there a way to tell enlive to not 
 parse anything within a given tag?

 -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com 
 javascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is this the good way to write get-percentage

2015-02-14 Thread Cecil Westerhof
2015-02-13 11:30 GMT+01:00 Jonathan Winandy jonathan.wina...@gmail.com:

 (defn to-mode-fn [mode]
   (if (keyword? mode)
 (case mode :highMath/ceil
:low Math/floor
:normal  Math/round
   (throw  (Exception. ERROR: get-percentage [:high|:low|:normal]
 PLACE TOTAL_COUNT)))
 mode))


​If I execute that I get:
CompilerException java.lang.RuntimeException: Unable to find static
field: ceil in class java.lang.Math, compiling:(NO_SOURCE_PATH:3:5)

I am using clojure 1.6.0 on Linux.​

-- 
Cecil Westerhof

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is this the good way to write get-percentage

2015-02-14 Thread Cecil Westerhof
2015-02-11 8:32 GMT+01:00 Cecil Westerhof cldwester...@gmail.com:


 I needed a function to get the percentage as an int. Input is place and
 total-count.
 I want the normal definition (which is the default) and a high and low
 variant.

 I came up with the following code:
 (defn get-percentage
   ([place total-count] (get-percentage :normal place total-count))
   ([mode place total-count]
 (let [percentage
 ​​
 (/ (* place 100.0) total-count)]
   (condp = mode
 :high (int (Math/ceil  percentage))
 :low  (int (Math/floor percentage))
 :normal   (int (Math/round percentage))
 (throw (Exception. ERROR: get-percentage [:high|:low|:normal]
 PLACE TOTAL_COUNT))

 Is this a good version, or could it be done better?


​Everyone thanks for the comments. I did the following.

I made three round functions:
(defn round  [x] (int (Math/round x)))
(defn round-high [x] (int (Math/ceil  x)))
(defn round-low  [x] (int (Math/floor x)))

And rewrote get-percentage to:
(defn get-percentage
  ([place total-count] (get-percentage :normal place total-count))
  ([mode place total-count]

  (let [mode-fn (case mode
  :highround-high
  :low round-low
  :normal  round
  (throw (Exception.
  ERROR: get-percentage [:high|:low|:normal]
PLACE TOTAL_COUNT)))]
(- place (* 100.0) (/ total-count) mode-fn int

But I wanted to do it a little neater.

I wrote a new round function:
(defn round
  ([x] (round :normal x))
  ([mode x]
(println mode)
(println x)
(case mode
  :high(Math/ceil  x)
  :low (Math/floor x)
  :normal  (Math/round x)
  (throw (Exception.
  ERROR: round [:high|:low|:normal] VALUE)

Then I tried to rewrite get-percentage:
(defn get-percentage
  ([place total-count] (get-percentage :normal place total-count))
  ([mode place total-count]

(if-not (contains? #{:high :low :normal} mode)
(throw (Exception.
ERROR: get-percentage [:high|:low|:normal] PLACE
TOTAL_COUNT)))
(round mode ​(/ (* place 100.0) total-count

But this gives on the last line:
CompilerException java.lang.RuntimeException: Unable to resolve symbol:
​ in this context,

When I put before that statement:
​(println mode)
(println place)
(println total-count)
(println ​(/ place total-count))
(println ​(/ (* place 100.0) total-count))

I get the same error on:
(println ​(/ place total-count))

What is happening here?

I am using Clojure 1.6.0 on Linux.​

-- 
Cecil Westerhof

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Roll up! Bodil on microKanren at Skills Matter London 3 March

2015-02-14 Thread Bruce Durling
Roll up! Roll up!

Bodil Stokke will be speaking about microKanren at Skills Matter
London on 3rd March

Details and sign up here:

https://skillsmatter.com/meetups/7025-kanren-running-the-little-things-backwards

cheers,
Bruce

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is this the good way to write get-percentage

2015-02-14 Thread Cecil Westerhof
2015-02-14 15:46 GMT+01:00 Jonathan Winandy jonathan.wina...@gmail.com:

 Unable to resolve symbol: ​ in this 

 I get this error when I have a non-breaking space in my code :
 http://en.wikipedia.org/wiki/Non-breaking_space


​It was not a non-breaking space (those I see), but something like it, with
code #x200b. After removing these characters it worked.

-- 
Cecil Westerhof

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is this the good way to write get-percentage

2015-02-14 Thread Jonathan Winandy
Unable to resolve symbol: ​ in this 

I get this error when I have a non-breaking space in my code :
http://en.wikipedia.org/wiki/Non-breaking_space

Jon

On Sat, Feb 14, 2015 at 3:21 PM, Matching Socks phill.w...@gmail.com
wrote:

 A Clojure fn is an Object, but Math's ceil method is not an Object.  The
 Java-Interop notation for static methods, eg (Math/ceil...), papers over
 this difference.  If you want to manipulate something like Math/ceil as a
 Clojure fn, you can wrap it in one such as your round-high.


 http://stackoverflow.com/questions/8623109/how-to-get-a-clojure-handle-on-a-java-static-method-similar-to-memfn-for-a-ja

 http://clojure.org/java_interop

 P.S. If you find this error message puzzling and think the compiler could
 reasonably do better, would you file a Jira ticket about it?
 http://dev.clojure.org/jira/

 --
 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 email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Name of a function

2015-02-14 Thread Cecil Westerhof
In Bash I use the following construct:
printf ${FUNCNAME} needs an expression\n

In this way I do not have to change the print statement when the name of
the function changes. Is something like this also possible in clojure?

-- 
Cecil Westerhof

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is this the good way to write get-percentage

2015-02-14 Thread Matching Socks
A Clojure fn is an Object, but Math's ceil method is not an Object.  The 
Java-Interop notation for static methods, eg (Math/ceil...), papers over 
this difference.  If you want to manipulate something like Math/ceil as a 
Clojure fn, you can wrap it in one such as your round-high.

http://stackoverflow.com/questions/8623109/how-to-get-a-clojure-handle-on-a-java-static-method-similar-to-memfn-for-a-ja

http://clojure.org/java_interop

P.S. If you find this error message puzzling and think the compiler could 
reasonably do better, would you file a Jira ticket about it?  
http://dev.clojure.org/jira/

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Is this the good way to write get-percentage

2015-02-14 Thread Cecil Westerhof
2015-02-14 12:33 GMT+01:00 Cecil Westerhof cldwester...@gmail.com:


 2015-02-11 8:32 GMT+01:00 Cecil Westerhof cldwester...@gmail.com:


 I needed a function to get the percentage as an int. Input is place and
 total-count.
 I want the normal definition (which is the default) and a high and low
 variant.

 I came up with the following code:
 (defn get-percentage
   ([place total-count] (get-percentage :normal place total-count))
   ([mode place total-count]
 (let [percentage
 ​​
 (/ (* place 100.0) total-count)]
   (condp = mode
 :high (int (Math/ceil  percentage))
 :low  (int (Math/floor percentage))
 :normal   (int (Math/round percentage))
 (throw (Exception. ERROR: get-percentage
 [:high|:low|:normal] PLACE TOTAL_COUNT))

 Is this a good version, or could it be done better?


 ​Everyone thanks for the comments. I did the following.

 I made three round functions:
 (defn round  [x] (int (Math/round x)))
 (defn round-high [x] (int (Math/ceil  x)))
 (defn round-low  [x] (int (Math/floor x)))

 And rewrote get-percentage to:
 (defn get-percentage
   ([place total-count] (get-percentage :normal place total-count))
   ([mode place total-count]

   (let [mode-fn (case mode
   :highround-high
   :low round-low
   :normal  round
   (throw (Exception.
   ERROR: get-percentage [:high|:low|:normal]
 PLACE TOTAL_COUNT)))]
 (- place (* 100.0) (/ total-count) mode-fn int

 But I wanted to do it a little neater.

 I wrote a new round function:
 (defn round
   ([x] (round :normal x))
   ([mode x]
 (println mode)
 (println x)
 (case mode
   :high(Math/ceil  x)
   :low (Math/floor x)
   :normal  (Math/round x)
   (throw (Exception.
   ERROR: round [:high|:low|:normal] VALUE)

 Then I tried to rewrite get-percentage:
 (defn get-percentage
   ([place total-count] (get-percentage :normal place total-count))
   ([mode place total-count]

 (if-not (contains? #{:high :low :normal} mode)
 (throw (Exception.
 ERROR: get-percentage [:high|:low|:normal]
 PLACE TOTAL_COUNT)))
 (round mode ​(/ (* place 100.0) total-count

 But this gives on the last line:
 CompilerException java.lang.RuntimeException: Unable to resolve
 symbol: ​ in this context,

 When I put before that statement:
 ​(println mode)
 (println place)
 (println total-count)
 (println ​(/ place total-count))
 (println ​(/ (* place 100.0) total-count))

 I get the same error on:
 (println ​(/ place total-count))

 What is happening here?

 I am using Clojure 1.6.0 on Linux.​


​I have now something that is working OK I think. This is what it has
become:​
​(defmacro static-fn [f] `(fn [x#] (~f x#)))

(defn round
  ([x] (round :normal x))
  ([mode x]
(let [fn (case mode
   :high(static-fn Math/ceil)
   :low (static-fn Math/floor)
   :normal  (static-fn Math/round)
   (throw (Exception.
   ERROR: round [:high|:low|:normal] VALUE)))]
  (long (fn x)

(defn get-percentage
  ([place total-count] (get-percentage :normal place total-count))
  ([mode place total-count]
(if-not (contains? #{:high :low :normal} mode)
(throw (Exception.
ERROR: get-percentage [:high|:low|:normal] PLACE
TOTAL_COUNT)))
(round mode (/ (* place 100.0) total-count
​

​I made two other handy functions:
(defn round-precision [value precision]
  (let [multiplier (Math/pow 10.0 precision)]
(/ (Math/round (* value multiplier)) multiplier)))


(defn round-div-precision [dividend divisor precision]
(round-precision (/ (float dividend) divisor) precision))

For example:
(round-div-precision 22000 7 3)
gives:
3142.857
​
and:
(round-div-precision 22000 7 -3)
gives:
3000.0

-- 
Cecil Westerhof

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: getting enlive not to parse something

2015-02-14 Thread Herwig Hochleitner
Enlive by default uses tagsoup to parse html and can also use jsoup, so I'd
start with parsing options for those. It can also be used with other
parsers, provided you can get them to generate clojure's xml map format.

2015-02-13 18:55 GMT+01:00 Sam Raker sam.ra...@gmail.com:

 I'm trying to parse some stuff with enlive, but part of at least of the
 pages look like:
 ...
 pre
 ...
 8-bar break...
 ...
 /pre

 Enlive interprets the text in the pointy braces as html, which it isn't,
 and that's messing up my application. Is there a way to tell enlive to not
 parse anything within a given tag?

 --
 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 email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ANN] cqrs-server - An opinionated CQRS/ES implementation using Onyx, Datomic, DynamoDB, Kafka and Zookeeper.

2015-02-14 Thread Christopher Small
Good catch; Thanks for correcting me.

On Fri, Feb 13, 2015 at 11:57 PM, Lucas Bradstreet 
lucasbradstr...@gmail.com wrote:

 Just a small clarification: both Storm and Onyx both depend on Zookeeper. Onyx
 is masterless as of 0.5.0, however it still requires Zookeeper IN order to
 write an append only log used by the peers in order to coordinate. In
 contrast to Storm, Onyx does not have dedicated coordinator nodes (in
 Storm these are Nimbus nodes). The masterless design is described at
 http://michaeldrogalis.github.io/jekyll/update/2015/01/20/Onyx-0.5.0:-The-Cluster-as-a-Value.html
 .

 Lucas

 On 14 Feb 2015, at 07:57, Christopher Small metasoar...@gmail.com wrote:

 I'll chime in with a couple of comments about Storm vs Onyx.

 I've used Storm in a production application, so I'm fairly familiar with
 it. I haven't spent too much time playing with Onyx yet, but will be soon.
 From what I do know about it and Storm though, I can say the following:

 Both Storm and Onyx are similar in that you specify distributed
 computations via computational topologies. So in general, you can do
 similar pretty things with them. So for the differences:

- Storm is certainly much more mature at this point.
- At the moment, Storm is much faster, though Michael D. has some
plans for stealing some of the performance tricks and intergrating them
into Onyx.
- The *main *difference: As Deon points out, Storm's functionality is
heavily built on macros, and rather opaque. In contrast, Onyx embraces
using simple data structures to describe the flow of a computation. This
makes the specification of computational flow much more modular and
composable, to the extant that it's even possible to modify the
computational flow at runtime.
- Onyx is built from the ground up in Clojure, for Clojure, whereas
Storm has a lot of Java under the hood, and places stronger emphasis on
it's Java API than it's Clojure API
- Onyx is moving (has moved? forget now...) to a very clever
masterless architecture, while Storm depends on Zookeper, which is a pretty
massive piece of software.

 If you need something that's battled tested right away, Storm may be your
 best bet. But I think as it matures (and it's developing quickly and
 beginning to get production adoption), it's going to win out over Storm, at
 least within the Clojure community, for the strengths mentioned above. The
 value of embracing data structures for the sake of composability is well
 argued and described in Zach Tellman's Always Be Composing
 https://www.youtube.com/watch?v=3oQTSP4FngY talk; this is something
 that seems to be catching on among Clojurists, and will likely see Onyx
 gain significant traction.

 My two cents...

 Chris Small


 On Friday, February 13, 2015 at 11:34:36 AM UTC-8, Deon Moolman wrote:

 Hi Aaron,

 Onyx is still quite young, but incredibly promising. I absolutely enjoy
 the way that they have teased apart the different bits of distributed
 systems. I highly recommend getting involved in the project, they're going
 to do great things.

 As for Storm, I haven't really used it so I'm not really qualified to
 comment. I've stayed away from it mostly because the defspout and defbolt
 macros made a deep part inside me cringe. Other than that, I'm sure it's a
 perfectly capable platform and I've heard people doing a lot of great
 things with it.

 Onyx really just translates to a library, at the end of the day. You
 build your application on top of it and manage firing up your peers inside
 each process yourself. This gives you as an application developer immense
 flexibilty. Deployment is outside the scope of Onyx - it assumes you've got
 that covered. I think that's a very wise assumption, given that the ways to
 deploy jars are diverse.

 Cheers,
  - Deon

 On Friday, 13 February 2015 02:04:26 UTC+2, Aaron France wrote:

 Hi,

 What are your opinions on Onyx?

 What are your opinions on Onyx compared to Storm?

 What are your opinions on Onyx deployment?

 Aaron


 On Thursday, 12 February 2015 10:15:44 UTC+1, Deon Moolman wrote:

 Hi everyone,

 I spent some time putting together an implementation of the CQRS
 pattern in Clojure and wrote an article on it:

 http://yuppiechef.github.io/cqrs-server/


 It mostly boils down to an Onyx (http://www.github.com/
 MichaelDrogalis/onyx) configuration, but it's been an interesting
 journey that I felt is worthwhile sharing.

 Feedback really appreciated!

 Cheers,
  - Deon

  --
 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 email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the 

Re: Name of a function

2015-02-14 Thread Cecil Westerhof
2015-02-14 18:58 GMT+01:00 Jony Hudson jonyepsi...@gmail.com:

 There might be a neater way, but

 (name (:name (meta (var reduce

 = reduce


​That is not what I meant. I have the following function:
(defn round
  ([x] (round :normal x))
  ([mode x]
(let [fn (case mode
   :high(static-fn Math/ceil)
   :low (static-fn Math/floor)
   :normal  (static-fn Math/round)
   (throw (Exception.
   ERROR: round [:high|:low|:normal] VALUE)))]
  (long (fn x)

I would like to use the function name in the throw. So that when I change
the function name to round-long, I do not need to change the throw
statement, because the name of the function is automatically filled.

​


 On Saturday, 14 February 2015 16:11:48 UTC, Cecil Westerhof wrote:

 In Bash I use the following construct:
 printf ${FUNCNAME} needs an expression\n

 In this way I do not have to change the print statement when the name of
 the function changes. Is something like this also possible in clojure?

 --
 Cecil Westerhof

  --
 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 email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.




-- 
Cecil Westerhof

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Name of a function

2015-02-14 Thread Jony Hudson
Unless I'm mistaken, in the output you show:

Exception ERROR: round [:high|:low|:normal] VALUE  user/round 
(repl-startup.clj:30)​
 

user/round is the name of the function, as desired.


Jony

On Saturday, 14 February 2015 19:09:53 UTC, Cecil Westerhof wrote:

 2015-02-14 20:03 GMT+01:00 Jony Hudson jonye...@gmail.com javascript::

 Ah, I see. I don't know how to do that. But, the function name should be 
 in the stack trace associated with the exception. Is there a particular 
 reason you also want to put it in the message?


 ​Well if I enter in the REPL:
 (round :dummy 12.4)
 I only get:
 Exception ERROR: round [:high|:low|:normal] VALUE  user/round 
 (repl-startup.clj:30)​
  

 ​So it is very useful to have it in the message. ;-)


 On Saturday, 14 February 2015 18:45:12 UTC, Cecil Westerhof wrote:



 2015-02-14 18:58 GMT+01:00 Jony Hudson jonye...@gmail.com:

 There might be a neater way, but

 (name (:name (meta (var reduce

 = reduce


 ​That is not what I meant. I have the following function:
 (defn round
   ([x] (round :normal x))
   ([mode x]
 (let [fn (case mode
:high(static-fn Math/ceil)
:low (static-fn Math/floor)
:normal  (static-fn Math/round)
(throw (Exception.
ERROR: round [:high|:low|:normal] 
 VALUE)))]
   (long (fn x)

 I would like to use the function name in the throw. So that when I 
 change the function name to round-long, I do not need to change the throw 
 statement, because the name of the function is automatically filled.

 ​
  

 On Saturday, 14 February 2015 16:11:48 UTC, Cecil Westerhof wrote:

 In Bash I use the following construct:
 printf ${FUNCNAME} needs an expression\n

 In this way I do not have to change the print statement when the name 
 of the function changes. Is something like this also possible in clojure?


 -- 
 Cecil Westerhof
  

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Name of a function

2015-02-14 Thread Jony Hudson
There might be a neater way, but

(name (:name (meta (var reduce

= reduce


Jony

On Saturday, 14 February 2015 16:11:48 UTC, Cecil Westerhof wrote:

 In Bash I use the following construct:
 printf ${FUNCNAME} needs an expression\n

 In this way I do not have to change the print statement when the name of 
 the function changes. Is something like this also possible in clojure?

 -- 
 Cecil Westerhof
  

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Name of a function

2015-02-14 Thread Jony Hudson
Ah, I see. I don't know how to do that. But, the function name should be in 
the stack trace associated with the exception. Is there a particular reason 
you also want to put it in the message?


Jony


On Saturday, 14 February 2015 18:45:12 UTC, Cecil Westerhof wrote:



 2015-02-14 18:58 GMT+01:00 Jony Hudson jonye...@gmail.com javascript::

 There might be a neater way, but

 (name (:name (meta (var reduce

 = reduce


 ​That is not what I meant. I have the following function:
 (defn round
   ([x] (round :normal x))
   ([mode x]
 (let [fn (case mode
:high(static-fn Math/ceil)
:low (static-fn Math/floor)
:normal  (static-fn Math/round)
(throw (Exception.
ERROR: round [:high|:low|:normal] VALUE)))]
   (long (fn x)

 I would like to use the function name in the throw. So that when I change 
 the function name to round-long, I do not need to change the throw 
 statement, because the name of the function is automatically filled.

 ​
  

 On Saturday, 14 February 2015 16:11:48 UTC, Cecil Westerhof wrote:

 In Bash I use the following construct:
 printf ${FUNCNAME} needs an expression\n

 In this way I do not have to change the print statement when the name of 
 the function changes. Is something like this also possible in clojure?

 -- 
 Cecil Westerhof
  
  -- 
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.com 
 javascript:
 Note that posts from new members are moderated - please be patient with 
 your first post.
 To unsubscribe from this group, send email to
 clojure+u...@googlegroups.com javascript:
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 --- 
 You received this message because you are subscribed to the Google Groups 
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an 
 email to clojure+u...@googlegroups.com javascript:.
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Cecil Westerhof
  

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Name of a function

2015-02-14 Thread Cecil Westerhof
2015-02-14 20:03 GMT+01:00 Jony Hudson jonyepsi...@gmail.com:

 Ah, I see. I don't know how to do that. But, the function name should be
 in the stack trace associated with the exception. Is there a particular
 reason you also want to put it in the message?


​Well if I enter in the REPL:
(round :dummy 12.4)
I only get:
Exception ERROR: round [:high|:low|:normal] VALUE  user/round
(repl-startup.clj:30)​


​So it is very useful to have it in the message. ;-)


On Saturday, 14 February 2015 18:45:12 UTC, Cecil Westerhof wrote:



 2015-02-14 18:58 GMT+01:00 Jony Hudson jonye...@gmail.com:

 There might be a neater way, but

 (name (:name (meta (var reduce

 = reduce


 ​That is not what I meant. I have the following function:
 (defn round
   ([x] (round :normal x))
   ([mode x]
 (let [fn (case mode
:high(static-fn Math/ceil)
:low (static-fn Math/floor)
:normal  (static-fn Math/round)
(throw (Exception.
ERROR: round [:high|:low|:normal] VALUE)))]
   (long (fn x)

 I would like to use the function name in the throw. So that when I change
 the function name to round-long, I do not need to change the throw
 statement, because the name of the function is automatically filled.

 ​


 On Saturday, 14 February 2015 16:11:48 UTC, Cecil Westerhof wrote:

 In Bash I use the following construct:
 printf ${FUNCNAME} needs an expression\n

 In this way I do not have to change the print statement when the name
 of the function changes. Is something like this also possible in clojure?


-- 
Cecil Westerhof

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Name of a function

2015-02-14 Thread Herwig Hochleitner
Well, one of the many reasons, that clojure is faster than bash is, that
during compilation, code is divorced from the original source symbols.
That means you can only access information about the original source that
you, or some library code you use, put in there for you.

Jony stated correctly, that the regular namespace/var/defn infrastructure
records function names in the var metadata.

Of course, you are using a different facility called static-fn, presumably
a macro that generates a clojure fn around a static java method.
So your question really is: Does static-fn put the name of the method it
wraps into metadata of the generated function and if so, which key?

I can't answer that, since static-fn is not in the standard library and you
didn't provide a definition or reference. I recommend you look your
definition of static-fn.rce code.
Given that you just want to reconstruct the mode in which round was called,
you could just include the keyword itself in the error message.

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Performant string concatenation (of many, large strings)

2015-02-14 Thread Ivan L
What is the best way to profile Clojure? I tried a reduce doto thing but it was 
way slowe than apply str.  would love to know why.

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 function.  Useful for 
pre-conditions,
;; logging and error reporting.
(defmacro defn0 [fname  fdcls]
  `(let [~'%0 (symbol (name (ns-name *ns*)) (name '~fname))]
 (defn ~fname ~@fdcls)))

;; For example...
(defn0 my-func [x]  
  (println calling %0 x)  
  (+ x 3))

user= (my-func 11)
calling user/my-func 11
14

The downside to using something like this is that other people might have a 
harder time reading your code.  I thought it was clever when I wrote it, but I 
don't actually use it much.


 On Feb 14, 2015, at 11:11 AM, Cecil Westerhof cldwester...@gmail.com wrote:
 
 In Bash I use the following construct:
 printf ${FUNCNAME} needs an expression\n
 
 In this way I do not have to change the print statement when the name of the 
 function changes. Is something like this also possible in clojure?

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Name of a function

2015-02-14 Thread Shantanu Kumar
You can probably omit try and throw to achieve the same effect.

(let [ste# (aget (.getStackTrace (Exception.)))]
  ..)

Shantanu

On Sunday, 15 February 2015 00:58:28 UTC+5:30, Shantanu Kumar wrote:

 See if you can put this to any use (implies no warranty) - applicable to 
 the JVM only:

 (defmacro whereami
   []
   `(try (throw (Exception.))
 (catch Exception e#
   ;; (.printStackTrace e#) ; uncomment this line to inspect stack 
 trace
   (let [ste# (aget (.getStackTrace e#) 0)]
 {:class-name  (.getClassName  ste#)
  :file-name   (.getFileName   ste#)
  :line-number (.getLineNumber ste#)
  :method-name (.getMethodName ste#)}

 (defn foo []
   (println This is at (whereami)))

 Shantanu

 On Saturday, 14 February 2015 21:41:48 UTC+5:30, Cecil Westerhof wrote:

 In Bash I use the following construct:
 printf ${FUNCNAME} needs an expression\n

 In this way I do not have to change the print statement when the name of 
 the function changes. Is something like this also possible in clojure?

 -- 
 Cecil Westerhof
  


-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Name of a function

2015-02-14 Thread Shantanu Kumar
See if you can put this to any use (implies no warranty) - applicable to 
the JVM only:

(defmacro whereami
  []
  `(try (throw (Exception.))
(catch Exception e#
  ;; (.printStackTrace e#) ; uncomment this line to inspect stack 
trace
  (let [ste# (aget (.getStackTrace e#) 0)]
{:class-name  (.getClassName  ste#)
 :file-name   (.getFileName   ste#)
 :line-number (.getLineNumber ste#)
 :method-name (.getMethodName ste#)}

(defn foo []
  (println This is at (whereami)))

Shantanu

On Saturday, 14 February 2015 21:41:48 UTC+5:30, Cecil Westerhof wrote:

 In Bash I use the following construct:
 printf ${FUNCNAME} needs an expression\n

 In this way I do not have to change the print statement when the name of 
 the function changes. Is something like this also possible in clojure?

 -- 
 Cecil Westerhof
  

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ANN] cqrs-server - An opinionated CQRS/ES implementation using Onyx, Datomic, DynamoDB, Kafka and Zookeeper.

2015-02-14 Thread Mike Haney
Deon,

This is outstanding.  I experimented with a similar approach last summer, but 
struggled with a couple of things.  First was what to use for the event store.  
I considered a few options, like using Datomic for that as well (I.e. annotate 
transactions and treat the sequence of transactions as the event stream) and 
even just using Kafka and retaining the logs indefinitely.  Both of those 
options have problems.  I like your approach of using a simple KV store - I'm 
embarrassed that I didn't think of that earlier.

Probably the biggest issue was the overall glue to tie the system together in 
an extensible way.  This was before Onyx was released, and although when I saw 
Onyx I thought it was promising, I had moved on to a different project and 
didn't have the time look into it fully.  I'm glad to see someone else has done 
that work.

I think this approach is very promising, and I will be digging into your system 
at the first opportunity.  Thank you so much for sharing this work with the 
community.

Mike

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Performant string concatenation (of many, large strings)

2015-02-14 Thread Michael Blume
Basically same way you profile java, I usually use jvisualvm, if you feel
like shelling out for yourkit that can be nicer.

On Sat Feb 14 2015 at 11:23:12 AM Ivan L ivan.laza...@gmail.com wrote:

 What is the best way to profile Clojure? I tried a reduce doto thing but
 it was way slowe than apply str.  would love to know why.

 --
 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 email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Name of a function

2015-02-14 Thread Cecil Westerhof
2015-02-14 20:21 GMT+01:00 Jony Hudson jonyepsi...@gmail.com:

 Unless I'm mistaken, in the output you show:

 Exception ERROR: round [:high|:low|:normal] VALUE  user/round
 (repl-startup.clj:30)​


 user/round is the name of the function, as desired.


​You are right: I was not looking correctly. :-(

In a way it is even better, because it also gives the namespace.

The only 'bad' thing is that the function name comes after the parameters,
but with rewriting the error message and becoming used to it, that should
not be a problem.

Still it could be useful for log messages to get the function name. So I
will look into the other replies.

​


 On Saturday, 14 February 2015 19:09:53 UTC, Cecil Westerhof wrote:

 2015-02-14 20:03 GMT+01:00 Jony Hudson jonye...@gmail.com:

 Ah, I see. I don't know how to do that. But, the function name should be
 in the stack trace associated with the exception. Is there a particular
 reason you also want to put it in the message?


 ​Well if I enter in the REPL:
 (round :dummy 12.4)
 I only get:
 Exception ERROR: round [:high|:low|:normal] VALUE  user/round
 (repl-startup.clj:30)​


 ​So it is very useful to have it in the message. ;-)


 On Saturday, 14 February 2015 18:45:12 UTC, Cecil Westerhof wrote:



 2015-02-14 18:58 GMT+01:00 Jony Hudson jonye...@gmail.com:

 There might be a neater way, but

 (name (:name (meta (var reduce

 = reduce


 ​That is not what I meant. I have the following function:
 (defn round
   ([x] (round :normal x))
   ([mode x]
 (let [fn (case mode
:high(static-fn Math/ceil)
:low (static-fn Math/floor)
:normal  (static-fn Math/round)
(throw (Exception.
ERROR: round [:high|:low|:normal]
 VALUE)))]
   (long (fn x)

 I would like to use the function name in the throw. So that when I
 change the function name to round-long, I do not need to change the throw
 statement, because the name of the function is automatically filled.

 ​


 On Saturday, 14 February 2015 16:11:48 UTC, Cecil Westerhof wrote:

 In Bash I use the following construct:
 printf ${FUNCNAME} needs an expression\n

 In this way I do not have to change the print statement when the name
 of the function changes. Is something like this also possible in clojure?


-- 
Cecil Westerhof

-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Performant string concatenation (of many, large strings)

2015-02-14 Thread Michael Blume
For minimal change to the presented code, what about

(defprotocol appendable (append-to [this ^StringBuilder sb]))

(extend-protocol appendable
  String
  (append-to [this ^StringBuilder sb] (.append sb this))
  clojure.lang.IFn
  (append-to [this ^StringBuilder sb] (this sb))
  Object
  (append-to [this ^StringBuilder sb] (.append sb (str this

(defn final-str [a]
  (let [sb (StringBuilder.)]
(append-to a sb)
(str sb)))

(defn par-join [sep xs]
  (fn [sb]
(when-let [xs (seq xs)]
  (append-to (first xs) sb)
  (doseq [x (next xs)]
(append-to sep sb)
(append-to x sb)

(let [f #(- % (map (comp val)) (par-join ,))]
  (- data-struct
(map f)
(par-join \n)
final-str))

Which winds up taking about a second and only creates one StringBuilder.



On Fri Feb 13 2015 at 8:02:27 PM Andy Chambers achambers.h...@gmail.com
wrote:

 Is there a reason you're collecting the result into a string rather than
 just writing out to a file?

 --
 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 email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.


-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Performant string concatenation (of many, large strings)

2015-02-14 Thread Michael Blume
er, s/(comp val)/val

On Sat Feb 14 2015 at 12:17:18 AM Michael Blume blume.m...@gmail.com
wrote:

 For minimal change to the presented code, what about

 (defprotocol appendable (append-to [this ^StringBuilder sb]))

 (extend-protocol appendable
   String
   (append-to [this ^StringBuilder sb] (.append sb this))
   clojure.lang.IFn
   (append-to [this ^StringBuilder sb] (this sb))
   Object
   (append-to [this ^StringBuilder sb] (.append sb (str this

 (defn final-str [a]
   (let [sb (StringBuilder.)]
 (append-to a sb)
 (str sb)))

 (defn par-join [sep xs]
   (fn [sb]
 (when-let [xs (seq xs)]
   (append-to (first xs) sb)
   (doseq [x (next xs)]
 (append-to sep sb)
 (append-to x sb)

 (let [f #(- % (map (comp val)) (par-join ,))]
   (- data-struct
 (map f)
 (par-join \n)
 final-str))

 Which winds up taking about a second and only creates one StringBuilder.



 On Fri Feb 13 2015 at 8:02:27 PM Andy Chambers achambers.h...@gmail.com
 wrote:

 Is there a reason you're collecting the result into a string rather than
 just writing out to a file?

 --
 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 email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.



-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Performant string concatenation (of many, large strings)

2015-02-14 Thread Michael Blume
...Annoyingly, almost all the time for my version is spent in protocol
dispatch, so there's probably a much faster way to do that.

On Sat Feb 14 2015 at 12:21:11 AM Michael Blume blume.m...@gmail.com
wrote:

 er, s/(comp val)/val

 On Sat Feb 14 2015 at 12:17:18 AM Michael Blume blume.m...@gmail.com
 wrote:

 For minimal change to the presented code, what about

 (defprotocol appendable (append-to [this ^StringBuilder sb]))

 (extend-protocol appendable
   String
   (append-to [this ^StringBuilder sb] (.append sb this))
   clojure.lang.IFn
   (append-to [this ^StringBuilder sb] (this sb))
   Object
   (append-to [this ^StringBuilder sb] (.append sb (str this

 (defn final-str [a]
   (let [sb (StringBuilder.)]
 (append-to a sb)
 (str sb)))

 (defn par-join [sep xs]
   (fn [sb]
 (when-let [xs (seq xs)]
   (append-to (first xs) sb)
   (doseq [x (next xs)]
 (append-to sep sb)
 (append-to x sb)

 (let [f #(- % (map (comp val)) (par-join ,))]
   (- data-struct
 (map f)
 (par-join \n)
 final-str))

 Which winds up taking about a second and only creates one StringBuilder.



 On Fri Feb 13 2015 at 8:02:27 PM Andy Chambers achambers.h...@gmail.com
 wrote:

 Is there a reason you're collecting the result into a string rather than
 just writing out to a file?

 --
 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 email to
 clojure+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/clojure?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/d/optout.



-- 
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 email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Clojure group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.