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

2015-02-11 Thread Herwig Hochleitner
Also, since you probably want defined order of columns for CSV, replace (map #(interpose ", " (vals %))) with (map #(interpose ", " (map % [:one :two :three :four]))) in the str - sequence version or #(eduction (comp (map val) (interpose-xf ", ")) %) with #(eduction (comp (map %) (interpose

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

2015-02-11 Thread Herwig Hochleitner
The most versatile way to do this is a pattern, I like to call concatenated lists of strings. You implement the parts as functions returning sequences of strings. You combine parts with concat. And map parts over input data with mapcat. Interpose and interleave have the role of str/join. Another u

Re: Let bindings and immutability

2015-02-11 Thread James Reeves
On 12 February 2015 at 02:06, gvim wrote: > > That explains it but I think Clojure's syntax is misleading here. Without > knowledge of this magic the mind doesn't readily translate: > > (let [x 1 > x (inc x) > x (inc x) > x (inc x)] >x) > > into: > > (let [x 1] >

Re: [ANN] closp - leiningen template combining luminus and chestnut + some more features

2015-02-11 Thread Alan Moore
FYI - I found the tool I mentioned @ modularity.org Alan On Wednesday, February 11, 2015 at 7:11:31 PM UTC-8, Alan Moore wrote: > > Nice - thanks! > > I was thinking it would be cool to create a meta-lein template that would > allow the user to specify which libraries (or features?) to include

[ANN] closp - leiningen template combining luminus and chestnut + some more features

2015-02-11 Thread Alan Moore
Nice - thanks! I was thinking it would be cool to create a meta-lein template that would allow the user to specify which libraries (or features?) to include and the template would (magic happens here) pull in each library and make the needed mods to the base template. Obviously this would requ

Re: OO Programmer trying to move to Clojure: Encapsulation

2015-02-11 Thread Herwig Hochleitner
Hm, the most common way to encapsulate in clojure is with a closure: Your account repository would be: (defn account-repository [connection] ;; <- here goes additional constructor logic (fn save [account] (sql-save connection account)) If the repository has more methods than just save, y

Re: Let bindings and immutability

2015-02-11 Thread Herwig Hochleitner
2015-02-12 3:06 GMT+01:00 gvim : > > That explains it but I think Clojure's syntax is misleading here. Without > knowledge of this magic the mind doesn't readily translate: > > In some other lisps, clojure's let is called let* for this reason. Their let binds only in parallel, similar to clojure's

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

2015-02-11 Thread Matching Socks
There was also some discussion of this back in November, where Fluid Dynamics suggested higher-order functions, and tbc++, multimethods(!). The main source of complexity in get-percentage has to do with selecting what it should do. Also, both percentage computation and rounding could potentially

Re: Let bindings and immutability

2015-02-11 Thread Herwig Hochleitner
I think that, from a user perspective, the important difference from mutation to shadowing is, that outer x is available even in the inner context, if captured by a closure. Likewise, a second thread, that runs an outer closure, would see the original x. Observe: (let [x :outer f (fn [] x)

Re: 1.7.0-alpha5 clobber warning error?

2015-02-11 Thread Andy Fingerhut
Sam: I believe if you proceed to do the following in your REPL: (in-ns 'monger.collection) (doc update) You will see that the name 'update' _from within the namespace monger.collection_ refers to monger.collection/update, not clojure.core/update. That is what the message is intended to convey.

Re: Let bindings and immutability

2015-02-11 Thread gvim
On 12/02/2015 01:53, Ben Wolfson wrote: The multiple-binding form of let can be recursively transformed into nested lets: (let [name1 value1 name2 value2 ... name value] body) > (let [name1 value1] (let [name2 value2] ... (let [name value] body))) All you're doing with your let form is sha

Re: Let bindings and immutability

2015-02-11 Thread Ambrose Bonnaire-Sergeant
Local bindings are immutable. Your example demonstrates lexical shadowing of bindings. This is an equivalent program semantically. (let [x 1 x_1 (inc x) x_2 (inc x_1) x_3 (inc x_2)] x_3) By the rules of lexical scoping, you cannot access the first `x` but it is never mutat

Re: Let bindings and immutability

2015-02-11 Thread Justin Smith
(let [x 0 f #(println x) x 1 g #(println x) x 2] (f) (g) x) there is no mutation of x, only scope shadowing hiding the other binding. Most functional languages (all that I know) allow shadowing. -- You received this message because you are subscribed to the Goo

Re: Let bindings and immutability

2015-02-11 Thread Ben Wolfson
The multiple-binding form of let can be recursively transformed into nested lets: (let [name1 value1 name2 value2 ... name value] body) > (let [name1 value1] (let [name2 value2] ... (let [name value] body))) All you're doing with your let form is shadowing the name; there's no mutation. If y

1.7.0-alpha5 clobber warning error?

2015-02-11 Thread Sam Raker
I just added monger as a dependency to my Clojure 1.7.0-alpha5 project, and saw the following in my repl: user=> (require '(monger [core :as mg] [collection :as mc])) WARNING: update already refers to: #'clojure.core/update in namespace: monger.collection, being replaced by: #'monger.collection/

Re: Let bindings and immutability

2015-02-11 Thread gvim
On 12/02/2015 01:44, Laurens Van Houtven wrote: Hi, You’re confusing mutation with single assignment. You’re not mutating anything: 1 is still 1, 2 is still 2; you’re just assigning the same name to different numbers. The numbers themselves are immutable. It's x that bothers me, not the val

Re: Let bindings and immutability

2015-02-11 Thread Laurens Van Houtven
Hi, > On Feb 11, 2015, at 5:42 PM, gvim wrote: > > Why is this possible in a language based on immutability: > > (let [x 1 >x (inc x) >x (inc x) >x (inc x)] > x) > > ;;=> 4 > > Maybe under the hood (ie. memory registers/pointers etc.) this isn't strictly > mutation

Let bindings and immutability

2015-02-11 Thread gvim
Why is this possible in a language based on immutability: (let [x 1 x (inc x) x (inc x) x (inc x)] x) ;;=> 4 Maybe under the hood (ie. memory registers/pointers etc.) this isn't strictly mutation but as a relative newcomer to Clojure I find it goes against the grain

Improving stacktraces in your custom ClojureScript REPL (Cider, Weasel, ...)

2015-02-11 Thread David Nolen
This message is mostly aimed at Clojure and ClojureScript REPL developers - Cider, Weasel, etc. I've written up some details on how to integrate the new automatic source mapping functionality: https://github.com/clojure/clojurescript/wiki/Custom-REPLs#source-mapping Feedback welcome and preferabl

Performant string concatenation (of many, large strings)

2015-02-11 Thread mark
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)) (clojur

Re: Question about ClojureScript Testing

2015-02-11 Thread David Nolen
You can run tests in any REPL that ships with ClojureScript - we include two JVM based ones Rhino and Nashorn. Rhino is older and more mature. Nashorn probably needs some further work to be good for testing. Patches welcome. Both of these options suffer from different forms of slowness (Rhino is ju

Re: Question about ClojureScript Testing

2015-02-11 Thread Elric Erkose
Thanks, I've seen figwheel. It doesn't address what I'm asking. -- 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

Re: [ANN] closp - leiningen template combining luminus and chestnut + some more features

2015-02-11 Thread martin_clausen
Link: https://github.com/sveri/closp On Wednesday, February 11, 2015 at 11:59:20 AM UTC+1, Sven Richter wrote: > > Hi, > > I took some time to put together a leiningen template which combines the > awesome proecjts luminus and chestnut and adds some more features to start > development sideproje

Re: Question about ClojureScript Testing

2015-02-11 Thread Stephen Nelson
That's really not the answer Elric is looking for. Figwheel does all the things you're talking about but doesn't provide a javascript execution environment, which is required for running tests (which you might want for testing in a CI environment, for example). If you want a purely leiningen/JVM s

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

2015-02-11 Thread Michael Blume
I think you could replace your condp = with case, since all your mode keywords are known at compile-time, otherwise looks about right. On Tue Feb 10 2015 at 11:32:58 PM Cecil Westerhof wrote: > I needed a function to get the percentage as an int. Input is place and > total-count. > I want the no

Re: Question about ClojureScript Testing

2015-02-11 Thread Mike Thompson
On Thursday, February 12, 2015 at 6:29:10 AM UTC+11, Elric Erkose wrote: > > I started looking at coljurescript testing yesterday and find it > disappointing that every example I find focuses on pantomjs. I'm looking > for a solution that doesn't require external software. By external > softwa

Re: Extending the LispReader with "embeded language lorms"

2015-02-11 Thread Steven Yi
For what it's worth, I see two things intertwined here, one being the desire to embed text in an arbitrary format and interpret it, the other being the mechanism in which you're doing it. To me, it seems you can do the kinds of things you have shown as examples by using just functions, macros,

Question about ClojureScript Testing

2015-02-11 Thread Elric Erkose
I started looking at coljurescript testing yesterday and find it disappointing that every example I find focuses on pantomjs. I'm looking for a solution that doesn't require external software. By external software, I mean anything that is not "jared" up and accessible through lein. I haven't pl

Re: OO Programmer trying to move to Clojure: Namespace Organization

2015-02-11 Thread Colin Yates
I wouldn't get too hung up on imitation as whilst there are style guides [1] I you will find a lot of diversity in "published" Clojure code. I would suggest you internalise the style guide, lean on "lein kibit" and "lein eastwood" and then do some navel gazing and ask yourself what problem you are

Re: OO Programmer trying to move to Clojure: Namespace Organization

2015-02-11 Thread Dru Sellers
Yeah, it wouldn't surprise me if I'm over thinking it too much. But in the model of 'shu-ha-ri' I am still very much in the shu stage so i'm looking for concrete stuff to imitate. :) Thank you everyone for the ideas and thoughts, -d On Saturday, February 7, 2015 at 10:23:43 AM UTC-6, Dru Sell

Re: Anyone know why cheat sheet links sometimes don't keep anchors?

2015-02-11 Thread Gary Verhaegen
Sometimes, when I go to the clojure.org website, I see my address bar flashing a few urls on the wikispaces domain. I would look in that direction: these redirects might not keep the fragment in the url. I do not think this is related to the cheat sheet itself; i seem to remember losong fragments

Re: OO Programmer trying to move to Clojure: Encapsulation

2015-02-11 Thread Dru Sellers
Thank you everyone for all of the helpful ideas. I def like the Component library and I will have to sit down and figure out how to best work that into my application while it is still young. All of the links have been consumed and I am starting to absorb more and more. Thank you for taking the

Re: ANN: ClojureScript 0.0-2814, Nashorn REPL, async testing, and much more

2015-02-11 Thread David Nolen
On Wed, Feb 11, 2015 at 6:52 AM, Daniel Skarda wrote: > Could you please write few examples how to take advantage of new unified > source-map support? I tried 0.0-2816 with node.js without success. I tried > with piggieback and without. But the only solution was with 'npm install > source-map-sup

Anyone know why cheat sheet links sometimes don't keep anchors?

2015-02-11 Thread Andy Fingerhut
There are multiple links in the Clojure cheat sheet here: http://jafingerhut.github.io/cheatsheet/clojuredocs/cheatsheet-tiptip-cdocs-summary.html that go to clojure.org/somewhere#some-anchor For example, in the "Special Forms" section, and the sub-section "Binding Forms / Destructuring", there

Why can't I override equals & hashCode in defrecord?

2015-02-11 Thread Michael Sperber
I'm implementing some low-level data structures using arrays, and I'd like to use defrecord to make type for them. I need to override equals & hashCode, but defrecord won't let me do it. I know this has been discussed before: https://groups.google.com/forum/#!topic/clojure/Nvz0WDhj0qk The advice

Re: Extending the LispReader with "embeded language lorms"

2015-02-11 Thread Chris Ford
As an example of pushing data into an external DSL you could check out John Cowie's Scenic wrapper for Bidi - https://github.com/johncowie/scenic. Note that Scenic loads data from the external file at _compile_ time - so it comes closer to being like embedding a DSL in Clojure source and less like

Re: Why STM read are not cached?

2015-02-11 Thread Stefan Kamphausen
Hi, It's been quite a while since I last looked into the impl of STM but I seem to remember that the committing transaction actively notifies other running transactions (see method barge) to restart and thus the restart is not triggered by the second deref at all. You could also find out by

Re: ANN: ClojureScript 0.0-2814, Nashorn REPL, async testing, and much more

2015-02-11 Thread Robin Heggelund Hansen
Does there exist a tutorial for how to setup a project using cljs.test? And some details on how the async testing works? 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

Re: ANN: ClojureScript 0.0-2814, Nashorn REPL, async testing, and much more

2015-02-11 Thread Daniel Skarda
David, thank you for all improvements and work you do for ClojureScript! Could you please write few examples how to take advantage of new unified source-map support? I tried 0.0-2816 with node.js without success. I tried with piggieback and without. But the only solution was with 'npm install s

[ANN] closp - leiningen template combining luminus and chestnut + some more features

2015-02-11 Thread Sven Richter
Hi, I took some time to put together a leiningen template which combines the awesome proecjts luminus and chestnut and adds some more features to start development sideprojects for the web without much hassle. The rationale behind this is that I found myself adding these features again and agai

Re: [RFC] Testing ClojureScript code with clojurescript.test and Karma

2015-02-11 Thread Mike Thompson
On Wednesday, February 11, 2015 at 6:00:15 AM UTC+11, Kevin Bell wrote: > > We at CircleCI have been running our clojurescript.test tests with Karma > lately, with great results. Easy access to Chrome devtools for unit tests > is great, and it provides great community plugins like junit-formatt

Re: Extending the LispReader with "embeded language lorms"

2015-02-11 Thread Henrik Heine
Hi, Am Dienstag, 10. Februar 2015 21:07:50 UTC+1 schrieb Gary Verhaegen: > > For the sake of completeness, in this context "other users" is not limited > to humans: what about IDE support? Refactoring tools? Code analysis? I agree. You lock out "others" and that takes away a lot. For me that's