Re: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-30 Thread Sean Corfield
On Fri, Mar 30, 2012 at 11:01 AM, Larry Travis wrote: > user=> (time (dotimes [i 10] (average1 mill-float-numbs))) > "Elapsed time: 526.674 msecs" > > user=> (time (dotimes [i 10] (average2 mill-float-numbs))) > "Elapsed time: 646.608 msecs" > > user=> (time (dotimes [i 10] (average3 mill-float-nu

Re: What is fn*, fn suffixed with asterisk?

2012-03-30 Thread Timothy Baldridge
fn* is a compiler intrinsic...it's pretty low-level, it doesn't support destructuring,. So instead, core.clj creates a macro called fn that adds all this other functionality and eventually spits out the fn* in a format the compiler wants. Basically it's set up this way so that you can write the maj

What is fn*, fn suffixed with asterisk?

2012-03-30 Thread simon.T
Recently, when looking into the clojure source code, core.clj in particular, I found multiple occurrence of 'fn*' instead of 'fn'. Can anyone help explain what fn* is and the difference between fn and fn* Thanks Simon -- You received this message because you are subscribed to the Google

Re: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-30 Thread simon.T
Hi Rob, Appreciate it, I like the code and explanation, great! Simon On Thursday, March 29, 2012 6:28:48 PM UTC+8, Rob Nagle wrote: > > You can reduce in one pass with a function that tracks both the sum > and the count. > > (defn avg [coll] > (apply / (reduce (fn [[sum n] x] [(+ sum x) (i

Re: ClojureScript release 0.0-1006

2012-03-30 Thread Dave Sann
A quick comment on item 13 in the release. I think that this sort causes some code that I have to fail. The reason is that the code in question inserts js scripts into the header of the page - when bootstrap loads. Subsequent modules require this js to be present - but do not "depend" on it. Ex

[ANN] data.zip 0.1.1

2012-03-30 Thread Aaron Bedra
Hi everyone, Thanks to a patch from Justin Kramer, data.zip now works properly with the updates to data.xml. org.clojure data.zip 0.1.1 or [org.clojure/data.zip "0.1.1"] Cheers, Aaron -- You received this message because you are subscribed to the Google Groups "Clojure" gro

Re: Source code as metadata

2012-03-30 Thread Cedric Greevey
On Fri, Mar 30, 2012 at 6:17 PM, Lee Spector wrote: > > On Mar 30, 2012, at 5:11 PM, Cedric Greevey wrote: >> >> That opens a giant can of worms. How, for example, do we discover that >> (partial * 2) and #(* % 2) and (fn [x] (* 2 x)) and #(+ %1 %1) are all >> equal? Nevermind once we get into sit

Re: Source code as metadata

2012-03-30 Thread Cedric Greevey
2012/3/30 Vinzent : > Counter-example: one could write if-authenticated macro, which will take > fixed number of args, but should be indented as normal if. OK, check the macro structure to see if any args are incorporated as invokable forms -- so, in arguments in special forms and macros that are

Re: Source code as metadata

2012-03-30 Thread Lee Spector
On Mar 30, 2012, at 5:11 PM, Cedric Greevey wrote: > > That opens a giant can of worms. How, for example, do we discover that > (partial * 2) and #(* % 2) and (fn [x] (* 2 x)) and #(+ %1 %1) are all > equal? Nevermind once we get into situations like #(reduce + (map > (constantly 1) %) equals #(l

Re: ClojureScript release 0.0-1006

2012-03-30 Thread Evan Mezeske
Awesome, I've been looking forward to this release. The new release has made it out to the upstream maven repository. I just pushed out lein-cljsbuild 0.1.4, which has the new 0.0-1006 dependency (as well as some other features [1]. It works on my personal projects! -Evan [1] https://github

Better ways to make time tansformations?

2012-03-30 Thread Goldritter
I wanted to track a program and set a maximum runtime for it in a way which is readable for the user. So I needed to write a time tansformation which I could use in my track function. First I wanted to use something like the 'defunits' macro from "Let over Lambda" from Doug Hoyte, but I'm not so fi

Re: Source code as metadata

2012-03-30 Thread Phil Hagelberg
Vinzent writes: > Probably you slightly misunderstood what I mean. Consider this > scenario: > I've set up a project which uses a new library with non-standart > indent. I've connected to swank and compiled it. Then I'm calling > some clojure-mode-update-indent function, which walks through all >

Re: Source code as metadata

2012-03-30 Thread Vinzent
Counter-example: one could write if-authenticated macro, which will take fixed number of args, but should be indented as normal if. суббота, 31 марта 2012 г. 3:07:23 UTC+6 пользователь Cedric Greevey написал: > > On Fri, Mar 30, 2012 at 1:26 PM, Vinzent wrote: > > Another idea is to put :indenta

Re: Source code as metadata

2012-03-30 Thread Vinzent
Probably you slightly misunderstood what I mean. Consider this scenario: I've set up a project which uses a new library with non-standart indent. I've connected to swank and compiled it. Then I'm calling some clojure-mode-update-indent function, which walks through all loaded namespaces and coll

Re: Source code as metadata

2012-03-30 Thread Cedric Greevey
On Fri, Mar 30, 2012 at 2:48 PM, Nathan Matthews wrote: > Also it bothers me that > > (= (partial * 2) (partial * 2)) > > is false. Logically it shouldn't be right?  If we captured the function > forms, that would enable better equality for functions. That opens a giant can of worms. How, for ex

Re: Source code as metadata

2012-03-30 Thread Cedric Greevey
On Fri, Mar 30, 2012 at 1:26 PM, Vinzent wrote: > Another idea is to put :indentation metadata on vars, so user-defined macros > could be indented properly. Currently I have (define-clojure-indent ...) > with a number of forms in my emacs config file, and it seems to be pretty > common solution. I

Re: Where to post job ad

2012-03-30 Thread blcooley
On Mar 30, 7:35 am, David Jagoe wrote: > G'day everyone > > I am increasingly relying on clojure and plan to use clojureclr and > clojurescript in production too. I will soon need to hire a clojure > developer and was hoping that someone could suggest a good place to post a > job ad. I've never

Re: Source code as metadata

2012-03-30 Thread Phil Hagelberg
Vinzent writes: > I'm not sure how I feel about indentation rules > changing depending on whether slime is active or not. > > What I was thinking, is that there'd be some function which would > collect and save indentation metadata, so it can be used later. Thus, > active slime connection

Re: Source code as metadata

2012-03-30 Thread Phil Hagelberg
Nathan Matthews writes: > I wrote some code which re-programmed the fn macro to capture the > closures as well as the actual function form, and attach them as > meta-data also on the actual function object. Could you submit it as a patch to serializable-fn? It would be nice to have everything in

Re: kibit is to Clojure what SOUL is to Smalltalk

2012-03-30 Thread Devin Walters
Nice find. Thanks, '(Devin Walters) On Friday, March 30, 2012 at 2:58 PM, David Nolen wrote: > http://soft.vub.ac.be/SOUL/ > > This project is worth looking at for directions that kibit might want to go. > It's also a good resource for cool ideas on how to leverage core.logic - > miniKanren

Re: Source code as metadata

2012-03-30 Thread Vinzent
> > I'm not sure how I feel about indentation rules > changing depending on whether slime is active or not. > What I was thinking, is that there'd be some function which would collect and save indentation metadata, so it can be used later. Thus, active slime connection required only the first t

kibit is to Clojure what SOUL is to Smalltalk

2012-03-30 Thread David Nolen
http://soft.vub.ac.be/SOUL/ This project is worth looking at for directions that kibit might want to go. It's also a good resource for cool ideas on how to leverage core.logic - miniKanren was designed from the get go to manipulate Lisp source. David -- You received this message because you are

Re: Source code as metadata

2012-03-30 Thread Phil Hagelberg
Nathan Matthews writes: > I wanted to serialise functions and send them over the network. The > problem with serializable-fn is that it doesn't capture closures. It's designed to capture closures; if it doesn't that would be an (unsurprising) bug. -Phil -- You received this message because yo

Re: Where to post job ad

2012-03-30 Thread Joseph Smith
This seems like a good place. Where's the job? :) On Mar 30, 2012, at 7:35 AM, David Jagoe wrote: > G'day everyone > > I am increasingly relying on clojure and plan to use clojureclr and > clojurescript in production too. I will soon need to hire a clojure developer > and was hoping that s

Re: Source code as metadata

2012-03-30 Thread Nathan Matthews
Hi, I wanted to serialise functions and send them over the network. The problem with serializable-fn is that it doesn't capture closures. I wrote some code which re-programmed the fn macro to capture the closures as well as the actual function form, and attach them as meta-data also on the ac

Re: Multiple ClojureScript (sub)projects with shared CLJS libraries per single clojure project

2012-03-30 Thread Evan Mezeske
I can confirm Mark Rathewell's note; that's part of what lein-cljsbuild is meant to do. With his configuration, the script1.js and script2.js files would both be built, and each would only contain the code from the project1 or project2 directories, respectively (unless they require code from ou

Re: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-30 Thread Stephen Compall
On Thu, 2012-03-29 at 23:31 -0700, Benjamin Peter wrote: > the sequence would have been traversed completely by the reduce call > and therefore clojure could know it's size and provide a constant time > count. > > Could this be implemented? Yes. You could probably implement it yourself, as a wra

Re: Where to post job ad

2012-03-30 Thread Sean Corfield
On Fri, Mar 30, 2012 at 8:18 AM, Devin Walters wrote: > Try meetup.com and look for Clojure and/or Lispish groups. Contact them with > details. I would be happy to put the word out in our group. Feel free to > pass me details. Also LinkedIn has a Clojure group and that has a Jobs section. If you

Re: Where to post job ad

2012-03-30 Thread Chas Emerick
David, You might want to try posting at Functional Jobs; I've heard good things about results from there: http://functionaljobs.com/ FYI, I have no affiliation or connection with whoever runs the service. Of course, tweet the opening. I think we'd all be surprised by how many jobs get fill

Re: Source code as metadata

2012-03-30 Thread Phil Hagelberg
Vinzent writes: > Phil, what do you think? Could it be experimentally implemented in > clojure-mode? No, clojure-mode determines indentation exclusively from static heuristics. There is dynamic indentation support in slime, but I've never looked into it; I'm not sure how I feel about indentation

Re: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-30 Thread Larry Travis
I too think this is interesting because because it serves to illustrate some important general aspects of Clojure with a very simple problem. I wrote four Clojure programs contrasting different ways of solving the problem, and then timed the application of each ten times to a million-item sequ

Re: Multiple ClojureScript (sub)projects with shared CLJS libraries per single clojure project

2012-03-30 Thread Mark Rathwell
I haven't tried yet, but lein-cljsbuild [1] is meant to support multiple builds, and I believe something like the below config would be what you are looking for: :cljsbuild { :builds [{:source-path "src/cljs/project1" :compiler {:output-to "resources/public/cljs/script1.js"

Re: Multiple ClojureScript (sub)projects with shared CLJS libraries per single clojure project

2012-03-30 Thread Stuart Sierra
At Relevance we are working on a project with just this structure. The project has a custom build script that produces mulitple advanced-mode-compiled .js files. We have not developed anything that would be generally reusable, but it's not hard to create custom code to do this. The ClojureScrip

ClojureScript release 0.0-1006

2012-03-30 Thread Stuart Sierra
Just pushed to Sonatype. Will be sync'd to other repos within 24 hours. Changes: http://build.clojure.org/job/clojurescript-release/9/ -- 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 Not

Re: Source code as metadata

2012-03-30 Thread Vinzent
Another idea is to put :indentation metadata on vars, so user-defined macros could be indented properly. Currently I have (define-clojure-indent ...) with a number of forms in my emacs config file, and it seems to be pretty common solution. It'd be nice to replace this hack with an IDE-independ

Multiple ClojureScript (sub)projects with shared CLJS libraries per single clojure project

2012-03-30 Thread Tom Krestle
Hi, The project I envision would consist of multiple completely independent conglomerates of CLJS scripts compiled into several separate final production .js with one single Clojure server. The reason for that is: 1. Smaller size of .js to load at each stage 2. Each time a browser transitions fr

Re: Alternative download site for Clojure 1.3?

2012-03-30 Thread Tamreen Khan
And like Sean mentioned, using Leiningen *really* helps. Especially when you have Emacs with clojure set up as well. On Fri, Mar 30, 2012 at 8:17 AM, Murphy McMahon wrote: > Learning Clojure is the fun part. Setup and maintenance of the tools is a > little less fun, IMO. But where there's a will

Re: Where to post job ad

2012-03-30 Thread Tamreen Khan
Yep, just make sure to mention that it's an offer and the location in the subject to make it easy to spot. On Fri, Mar 30, 2012 at 11:39 AM, David Powell wrote: > > > On Fri, Mar 30, 2012 at 1:35 PM, David Jagoe wrote: > >> G'day everyone >> >> I am increasingly relying on clojure and plan to us

Re: Where to post job ad

2012-03-30 Thread David Powell
On Fri, Mar 30, 2012 at 1:35 PM, David Jagoe wrote: > G'day everyone > > I am increasingly relying on clojure and plan to use clojureclr and > clojurescript in production too. I will soon need to hire a clojure > developer and was hoping that someone could suggest a good place to post a > job ad.

Re: Where to post job ad

2012-03-30 Thread Devin Walters
On Friday, March 30, 2012 at 7:35 AM, David Jagoe wrote: > G'day everyone > I am increasingly relying on clojure and plan to use clojureclr and > clojurescript in production too. I will soon need to hire a clojure developer > and was hoping that someone could suggest a good place to post a job ad

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

2012-03-30 Thread Cedric Greevey
On Thu, Mar 29, 2012 at 11:59 PM, Shantanu Kumar wrote: > The change needs to be least intrusive and doesn't justify exposing > more surface area than it should. It's a trade off. Injecting a version of defn that doesn't do anything different except make a new thing available inside the function

Where to post job ad

2012-03-30 Thread David Jagoe
G'day everyone I am increasingly relying on clojure and plan to use clojureclr and clojurescript in production too. I will soon need to hire a clojure developer and was hoping that someone could suggest a good place to post a job ad. I've never seen a job posted here but I would like to reach the

Re: Alternative download site for Clojure 1.3?

2012-03-30 Thread Murphy McMahon
Learning Clojure is the fun part. Setup and maintenance of the tools is a little less fun, IMO. But where there's a will (and a connection to freenode), there's a way. On Mar 30, 2012 9:09 AM, "Chris Webster" wrote: > Thanks for the advice, guys. > > I think it must just have been some temporary

Howto make println run as fast as python's

2012-03-30 Thread sean neilan
Hey All, I'm trying to print the numbers 0-99 as fast as possible. In python, this for i in range(99): print i runs super fast. In clojure, even with type hints, this is slow (def ^java.io.PrintWriter outoutout (java.io.PrintWriter. *out*)) ; yes, I know this one prints to infinity. I

Re: Howto make println run as fast as python's

2012-03-30 Thread Sean Neilan
Whoops! I'm sorry. I tried compiling my code into an uberjar and then ran (defn print2 [] (dotimes [n 99] (.println outoutout n))) from main It's very very fast!! Wow! On Thu, Mar 29, 2012 at 8:07 PM, sean neilan wrote: > Hey All, > > I'm trying to print the numbers 0-99 as fast as po

Re: Alternative download site for Clojure 1.3?

2012-03-30 Thread Chris Webster
Thanks for the advice, guys. I think it must just have been some temporary problem on the site, as I finally got it to download late last night. Now all I have to do is learn Clojure, eh? -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

Re: What's the efficient functional way to computing the average of a sequence of numbers?

2012-03-30 Thread Benjamin Peter
Hi, On Mar 29, 10:43 pm, Alan Malloy wrote: > "Very likely" strikes me as a huge overstatement here. Most sequences > that you want to average won't be source-code literals, they'll be > lazy sequences, and those aren't counted. I think this topic is interesting. My guess would be, that the sequ

Re: partition-distinct

2012-03-30 Thread Tassilo Horn
David Jagoe writes: Hi David, > Thanks! I had a nasty feeling that it could be done in a one-liner > using partition-by or something similar. But of course you need to be > able to look at previous elements... Here's a slightly shorter variant. --8<---cut here---start--

Re: partition-distinct

2012-03-30 Thread Jay Fields
Here's a version with reduce. It returns your elements as sets, but you could easily (map seq ,,,) if you really need lists. user=> (reduce (fn [r e] (if ((last r) e) (conj r #{e}) (update-in r [(dec (count r))] conj e))) [#{}] [1 2 2 3 4 4 1 6]) [#{1 2} #{2 3 4} #{1 4 6}] Cheers, Jay On M

Re: partition-distinct

2012-03-30 Thread David Jagoe
On 29 March 2012 21:41, Cedric Greevey wrote: > > On Thu, Mar 29, 2012 at 4:18 PM, David Jagoe wrote: > > Given a sequence like this: [1 2 1 2 1 1 2 1 2 2 2] > > > > partition it to get this: [(1 2) (1 2) (1) (1 2) (1 2) (2) (2)] > >! > > (defn partition-distinct [s] >  (lazy-seq >    (loop [see