Re: Clojure/Luminus memory footprint

2014-01-10 Thread Mikera
An idle app isn't going to give you any useful benchmarks at all. The JVM 
is considerably faster and more scalable than either Ruby or Erlang when 
given a real application workload and maybe 2GB of RAM to play with (which 
you can certainly afford, if you are doing anything vaguely important on a 
modern machine).

Note that the JVM (+ Java libraries) is doing some very important stuff 
with the memory that it uses:
- Pre-allocating working memory, so that it can respond faster
- Compiling (via JIT) classes to optimised native code, so that your code 
runs fast
- Caching / interning things (e.g. commonly used Strings, or Clojure 
keywords). This takes some memory in the first instance, but pays off in 
the long term
- Delaying garbage collection until the most efficient time. This 
laziness is better for overall throughput, and if you aren't using the 
memory for anything else it is a smart thing for the JVM to do (if you do 
need all the memory suddenly, it will of course clear the garbage and let 
you use it as a priority).

The fact that the JVM does this and uses some memory to do so should 
inspire lots of confidence. That's what a good VM is *supposed* to do.

If you're running on a highly constrained embedded device, then everything 
is different of course. But in that case you should probably be looking at 
something closer to C rather than a VM-based language.

On Friday, 10 January 2014 01:33:35 UTC, g vim wrote:

 Gary 

 Pressing Perform GC reduced the Used Heap figures to 14Mb and 13Mb but 
 I now see these climbing to new heights while the app is completely 
 idle. JVM and main are now both using 75Mb each and climbing. This does 
 not inspire confidence for an app which is sitting idle. 

 gvim 


 On 09/01/2014 06:27, Gary Trakhman wrote: 
  what happens to the heap if you manually trigger a GC via the button? 
  
  
  On Thu, Jan 9, 2014 at 12:01 AM, gvim gvi...@gmail.com javascript: 
  mailto:gvi...@gmail.com javascript: wrote: 
  
  Here's the date from `jvisualvm`: 
  
  JVM: 
  char[]  19% 
  java.lang.object   15.5% 
  java.util.TreeMap$Entry  12% 
  java.io.ObjectStreamClass$__WeakClassKey   11% 
  byte[]11% 
  int[]   6% 
  
  main: 
  char[]   24% 
  byte[]   17% 
  java.lang.object   14% 
  java.util.TreeMap$Entry  10% 
  java.io.ObjectStreamClass$__WeakClassKey   10% 
  int[]   6% 
  
  
  Heap size: 366Mb 
  Used heap: 85Mb 
  
  gvim 
  
  
  
  On 09/01/2014 04:32, Gary Trakhman wrote: 
  
  you're still missing some basics about java memory management. 
  In 
  another thread, I mentioned the java VM will take more memory 
  than it 
  needs, that is because it prioritizes throughput over footprint. 
There 
  are knobs for all of that.  It's not clear what's taking so much 
  memory, 
  but it's certainly not luminus or clojure.  Use jvisualVM to 
  find out 
  for sure instead of comparing apples to oranges. 
  
  
  On Wed, Jan 8, 2014 at 4:24 PM, gvim gvi...@gmail.comjavascript: 
  mailto:gvi...@gmail.com javascript: 
  mailto:gvi...@gmail.com javascript: 
  mailto:gvi...@gmail.comjavascript: 
 wrote: 
  
   On OS X Mountain Lion I just compared the memory footprint 
 of 3 
   out-of-the-box web apps in these frameworks: 
  
   Clojure/Luminus:  152Mb (JVM) + 186Mb (main) = 338Mb 
  
   Ruby/Rails: 62Mb 
  
   Elixir (Erlang)/Weber: 32Mb 
  
   I was rather shocked, to say the least. Not to troll, it 
  has made me 
   think again about deploying Clojure web apps on hosting 
  platforms 
   with modest amounts RAM. I'm sure the figures for all 3 
 would 
   increase significantly once the web apps are fleshed out 
  but that 
   probably applies equally to all 3 frameworks. 
  
   gvim 
  
  
   -- 
   -- 
   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: mailto:
 clo...@googlegroups.com javascript: 
   mailto:clo...@googlegroups. javascript:__com 
  mailto: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+unsubscribe@__googlegr__oups.com 
  http://googlegroups.com 
   mailto:clojure%2Bunsubscribe@ javascript:__
 googlegroups.com 
  mailto:clojure%252bunsubscr...@googlegroups.com javascript: 

  
   For more options, visit 

JAVA_OPTS not accessible in my Clojure project

2014-01-10 Thread aidy lewis
Clojurians,

For some reason JAVA_OPTS are not accessible in my Clojure project.

The command line seems to be OK, if I:

$ lein repl

project-ns =  (System/getProperty javax.net.ssl.keyStore)

- /../certs/dev.bbc.co.uk.p12


However, if I load the nRepl in the lein project:

project-ns =  (System/getProperty javax.net.ssl.keyStore)

- nil

Not sure why this is the case?

Thanks
-- 
@AidyLewis

-- 
-- 
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/groups/opt_out.


Via mainstream twitter: Chinese spy manages to steal last 50MB of Lisp program governing U.S. missile launches.

2014-01-10 Thread russellc
 Fortunately, it was all closing parentheses.


-- 
-- 
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/groups/opt_out.


Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread christian jacobsen
I have +10 years experience of OO programming (C++, C# and a little Java) 
and a couple of years of FP programming (mainly F#, some Scala and a little 
Haskell). 
Are there any resources for learning Clojure that are particular good for 
someone with the above background?

-- 
-- 
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/groups/opt_out.


[ANN] Cloact 0.1.0 - Yet another React wrapper for ClojureScript

2014-01-10 Thread Dan Holmsand
Cloact is a minimalistic interface between ClojureScript and React.js, that now 
has a proper introduction, some documentation and a few examples here:

http://holmsand.github.io/cloact/

Project page and installation instructions are here:

https://github.com/holmsand/cloact

Enjoy,

/dan

-- 
-- 
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/groups/opt_out.


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread mynomoto
With that background I would go with Joy of Clojure by Michael Fogus and 
Chris Houser. http://manning.com/fogus2/

On Friday, January 10, 2014 10:52:53 AM UTC-2, christian jacobsen wrote:

 I have +10 years experience of OO programming (C++, C# and a little Java) 
 and a couple of years of FP programming (mainly F#, some Scala and a little 
 Haskell). 
 Are there any resources for learning Clojure that are particular good for 
 someone with the above background?


-- 
-- 
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/groups/opt_out.


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread Colin Yates
For me (a similarly entrenched OO guy) I found it very challenging.  

Nothing to do with the syntax, but you are moving from a world of locked up 
bits of data behind a (hopefully) impenetrable API to a world full of 
lightweight data with a myriad of tiny functions which pretty much all 
perform data transformations.  Let your data free! is the battle cry it 
seems.

After a number of years people start to become unconsciously competent 
which is where the pain lives - you need to deconstruct your intuition 
and gut feel, figure out the decisions you are taking and then challenge 
them.  At least for me I found a lot of the intuitively good solutions 
were actually quite poor when compared to the benefits and freedom FP 
brings.  They were still good solutions/implementations in the locked down 
Java land, but not over in FP land.  This is particularly prevalent because 
a lot of people don't separate out 'design' and 'implementation'.  Does the 
solution require encapsulation?  Yep, but that doesn't mean reaching for a 
class (or protocols or multi-methods for that matter).  And so on.  For me, 
forcing myself to learn Clojure (and Scala before hand) has made me a much 
better developer in general, even when working on OO implementations.

It is worth mentioning that 99% of the battle is changing the way you 
think, it has little to do with the tools.

Go watch every single Rich Hickey video.  Go watch them again. 
 Particularly the simple made easy and the one where he talks about time.

Pick up a really simple 'Clojure syntax' book or tutorial and then read 
'Joy of Clojure'.  

Now read through the core API.  You need to internalise that API and the 
code is pretty idiomatic (arguably by definition given the authors).

Keep going though - it really really is worth it.

On Friday, 10 January 2014 12:52:53 UTC, christian jacobsen wrote:

 I have +10 years experience of OO programming (C++, C# and a little Java) 
 and a couple of years of FP programming (mainly F#, some Scala and a little 
 Haskell). 
 Are there any resources for learning Clojure that are particular good for 
 someone with the above background?


-- 
-- 
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/groups/opt_out.


How can I improve this?

2014-01-10 Thread Colin Yates
I have a sequence of file names and I want to make them unique.  (uniquify 
[a b c a]) = [a b c a_1])

This is what I have come up with, but surely there is a better way?

What would you all do?  Feedback welcome (including the word 'muppet' as I 
am sure I have missed something simple) :)

(defn uniquify
  Return a sequence, in the same order as s containing every element
  of s. If s (which is presumed to be a string) occurs more than once
  then every subsequent occurrence will be made unique.

  Items will be updated to include an incrementing numeric count using
  the specified formatter function. The formatter function will be
  given the name and the number and should return a combination of the
  two.

  The set of unique s's in the returned sequence will be the count of
  s's in s.  
  ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
  ([s formatter]
 (let [occurrences (atom {})
   register-occurrence (fn [item]
 (if (get @occurrences item)
   (swap! (get @occurrences item) inc)
   (swap! occurrences assoc item (atom 1)))
 @(get @occurrences item))
   process (fn [item]
 (let [duplicates (dec (register-occurrence item))]
   (if ( duplicates 0)
 (formatter item duplicates)
 item)))
   unique-s (map process s)]
   unique-s)))

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Guru Devanla
Hi Colin,

Clojure has a distinct function that does this. I may be missing some
context on what you what out of your new method that 'distinct' does not
provide. The distinct functions source code is a good reference.

Thanks


On Fri, Jan 10, 2014 at 6:59 AM, Colin Yates colin.ya...@gmail.com wrote:

 I have a sequence of file names and I want to make them unique.  (uniquify
 [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?

 What would you all do?  Feedback welcome (including the word 'muppet' as I
 am sure I have missed something simple) :)

 (defn uniquify
   Return a sequence, in the same order as s containing every element
   of s. If s (which is presumed to be a string) occurs more than once
   then every subsequent occurrence will be made unique.

   Items will be updated to include an incrementing numeric count using
   the specified formatter function. The formatter function will be
   given the name and the number and should return a combination of the
   two.

   The set of unique s's in the returned sequence will be the count of
   s's in s.
   ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
   ([s formatter]
  (let [occurrences (atom {})
register-occurrence (fn [item]
  (if (get @occurrences item)
(swap! (get @occurrences item) inc)
(swap! occurrences assoc item (atom 1)))
  @(get @occurrences item))
process (fn [item]
  (let [duplicates (dec (register-occurrence item))]
(if ( duplicates 0)
  (formatter item duplicates)
  item)))
unique-s (map process s)]
unique-s)))

 --
 --
 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/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Alex Miller
I would not use an atom. Think about it as doing a reduce while passing 
along a set of the names you've seen so far. You might also look at the 
implementation of distinct in clojure.core which is similar (you want to 
detect duplicates in the same way, but emit new names instead of omitting 
dupes).


On Friday, January 10, 2014 8:59:10 AM UTC-6, Colin Yates wrote:

 I have a sequence of file names and I want to make them unique.  (uniquify 
 [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?

 What would you all do?  Feedback welcome (including the word 'muppet' as I 
 am sure I have missed something simple) :)

 (defn uniquify
   Return a sequence, in the same order as s containing every element
   of s. If s (which is presumed to be a string) occurs more than once
   then every subsequent occurrence will be made unique.

   Items will be updated to include an incrementing numeric count using
   the specified formatter function. The formatter function will be
   given the name and the number and should return a combination of the
   two.

   The set of unique s's in the returned sequence will be the count of
   s's in s.  
   ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
   ([s formatter]
  (let [occurrences (atom {})
register-occurrence (fn [item]
  (if (get @occurrences item)
(swap! (get @occurrences item) inc)
(swap! occurrences assoc item (atom 1)))
  @(get @occurrences item))
process (fn [item]
  (let [duplicates (dec (register-occurrence item))]
(if ( duplicates 0)
  (formatter item duplicates)
  item)))
unique-s (map process s)]
unique-s)))


-- 
-- 
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/groups/opt_out.


core.async builtin for concat ?

2014-01-10 Thread txrev319
Hi,

  Consider the following definition for concat-ing two channels.

(defn my-concat [chan1 chan2 buffer-size]
  (let [out (chan buffer-size)]
(go (loop [lst (list chan1 chan2)]
  (when (not (empty? lst))
(let [msg (! (first lst))]
  (if msg
(do (! out msg)
(recur lst))
(recur (rest lst

  Is there a core.async builtin for this? (It seems like a very trivial 
operation, but it's not clear to me how to create it by just putting 
together core.async primitives.)

Thanks!

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are 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/groups/opt_out.


RE: How can I improve this?

2014-01-10 Thread Colin Yates
The missing context is that distinct removes duplicates, I want duplicates to 
be made unique by changing them in some way: (uniquify [a b c a]) = 
[a b c a_1]) *not* (uniquify [a b c a]) = [a b c])
Not sure what else to put that isn't in the original post to be honest...

Date: Fri, 10 Jan 2014 07:10:22 -0800
Subject: Re: How can I improve this?
From: grd...@gmail.com
To: clojure@googlegroups.com

Hi Colin,
Clojure has a distinct function that does this. I may be missing some context 
on what you what out of your new method that 'distinct' does not provide. The 
distinct functions source code is a good reference.

Thanks

On Fri, Jan 10, 2014 at 6:59 AM, Colin Yates colin.ya...@gmail.com wrote:

I have a sequence of file names and I want to make them unique.  (uniquify [a 
b c a]) = [a b c a_1])

This is what I have come up with, but surely there is a better way?
What would you all do?  Feedback welcome (including the word 'muppet' as I am 
sure I have missed something simple) :)

(defn uniquify  Return a sequence, in the same order as s containing every 
element  of s. If s (which is presumed to be a string) occurs more than once  
then every subsequent occurrence will be made unique.

  Items will be updated to include an incrementing numeric count using  the 
specified formatter function. The formatter function will be  given the name 
and the number and should return a combination of the
  two.
  The set of unique s's in the returned sequence will be the count of  s's in 
s.([s] (uniquify s (fn [item duplicates] (str item _ duplicates
  ([s formatter] (let [occurrences (atom {})   register-occurrence 
(fn [item] (if (get @occurrences item)  
 (swap! (get @occurrences item) inc)
   (swap! occurrences assoc item (atom 1))) 
@(get @occurrences item))   process (fn 
[item] (let [duplicates (dec (register-occurrence item))]
   (if ( duplicates 0) (formatter 
item duplicates) item)))   unique-s (map 
process s)]   unique-s)))





-- 

-- 

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/groups/opt_out.







-- 

-- 

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 a topic in the Google 
Groups Clojure group.

To unsubscribe from this topic, visit 
https://groups.google.com/d/topic/clojure/rt-l_X3gK-I/unsubscribe.

To unsubscribe from this group and all its topics, send an email to 
clojure+unsubscr...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
  

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Colin Yates
Good call.  

I keep discounting reduce as I am not 'reducing' anything, only 
transforming (i.e. map) it - my mistake.

Thanks.

Col

On Friday, 10 January 2014 15:12:27 UTC, Alex Miller wrote:

 I would not use an atom. Think about it as doing a reduce while passing 
 along a set of the names you've seen so far. You might also look at the 
 implementation of distinct in clojure.core which is similar (you want to 
 detect duplicates in the same way, but emit new names instead of omitting 
 dupes).


 On Friday, January 10, 2014 8:59:10 AM UTC-6, Colin Yates wrote:

 I have a sequence of file names and I want to make them unique. 
  (uniquify [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?

 What would you all do?  Feedback welcome (including the word 'muppet' as 
 I am sure I have missed something simple) :)

 (defn uniquify
   Return a sequence, in the same order as s containing every element
   of s. If s (which is presumed to be a string) occurs more than once
   then every subsequent occurrence will be made unique.

   Items will be updated to include an incrementing numeric count using
   the specified formatter function. The formatter function will be
   given the name and the number and should return a combination of the
   two.

   The set of unique s's in the returned sequence will be the count of
   s's in s.  
   ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
   ([s formatter]
  (let [occurrences (atom {})
register-occurrence (fn [item]
  (if (get @occurrences item)
(swap! (get @occurrences item) inc)
(swap! occurrences assoc item (atom 
 1)))
  @(get @occurrences item))
process (fn [item]
  (let [duplicates (dec (register-occurrence item))]
(if ( duplicates 0)
  (formatter item duplicates)
  item)))
unique-s (map process s)]
unique-s)))



-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Ray Miller
On 10 January 2014 14:59, Colin Yates colin.ya...@gmail.com wrote:

 I have a sequence of file names and I want to make them unique.  (uniquify
 [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?


I would do something like:

 (defn uniquify
  ([xs]
 (uniquify xs (fn [x n] (str x _ n
  ([xs formatter]
 (letfn [(uniquify* [xs seen]
   (lazy-seq
(when (not-empty xs)
  (let [x (first xs)
n (seen x 0)]
(if ( n 0)
  (cons (formatter x n) (uniquify* (rest xs) (assoc
seen x (inc n
  (cons x (uniquify* (rest xs) (assoc seen x (inc
n)]
   (uniquify* xs {}

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Laurent PETIT
Hi,

Use frequencies to get a map of path = nb of occurrences, then for each
entry of the map, create unique names.
Cannot provide an impl on the uPhine, sorry

Le vendredi 10 janvier 2014, Colin Yates a écrit :

 I have a sequence of file names and I want to make them unique.  (uniquify
 [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?

 What would you all do?  Feedback welcome (including the word 'muppet' as I
 am sure I have missed something simple) :)

 (defn uniquify
   Return a sequence, in the same order as s containing every element
   of s. If s (which is presumed to be a string) occurs more than once
   then every subsequent occurrence will be made unique.

   Items will be updated to include an incrementing numeric count using
   the specified formatter function. The formatter function will be
   given the name and the number and should return a combination of the
   two.

   The set of unique s's in the returned sequence will be the count of
   s's in s.
   ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
   ([s formatter]
  (let [occurrences (atom {})
register-occurrence (fn [item]
  (if (get @occurrences item)
(swap! (get @occurrences item) inc)
(swap! occurrences assoc item (atom 1)))
  @(get @occurrences item))
process (fn [item]
  (let [duplicates (dec (register-occurrence item))]
(if ( duplicates 0)
  (formatter item duplicates)
  item)))
unique-s (map process s)]
unique-s)))

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to 
 clojure@googlegroups.comjavascript:_e({}, 'cvml', 
 '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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@googlegroups.com');.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Colin Yates
Love it.  Much more readable without any nasty persistent state.

On Friday, 10 January 2014 15:19:03 UTC, Ray Miller wrote:

 On 10 January 2014 14:59, Colin Yates colin...@gmail.com javascript:wrote:

 I have a sequence of file names and I want to make them unique. 
  (uniquify [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?


 I would do something like:

  (defn uniquify
   ([xs]
  (uniquify xs (fn [x n] (str x _ n
   ([xs formatter]
  (letfn [(uniquify* [xs seen]
(lazy-seq
 (when (not-empty xs)
   (let [x (first xs)
 n (seen x 0)]
 (if ( n 0)
   (cons (formatter x n) (uniquify* (rest xs) (assoc 
 seen x (inc n
   (cons x (uniquify* (rest xs) (assoc seen x (inc 
 n)]
(uniquify* xs {}


-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Colin Yates
I did consider that but I want to preserve the order of the incoming 
sequence.

On Friday, 10 January 2014 15:22:29 UTC, Laurent PETIT wrote:

 Hi,

 Use frequencies to get a map of path = nb of occurrences, then for each 
 entry of the map, create unique names.
 Cannot provide an impl on the uPhine, sorry

 Le vendredi 10 janvier 2014, Colin Yates a écrit :

 I have a sequence of file names and I want to make them unique. 
  (uniquify [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?

 What would you all do?  Feedback welcome (including the word 'muppet' as 
 I am sure I have missed something simple) :)

 (defn uniquify
   Return a sequence, in the same order as s containing every element
   of s. If s (which is presumed to be a string) occurs more than once
   then every subsequent occurrence will be made unique.

   Items will be updated to include an incrementing numeric count using
   the specified formatter function. The formatter function will be
   given the name and the number and should return a combination of the
   two.

   The set of unique s's in the returned sequence will be the count of
   s's in s.  
   ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
   ([s formatter]
  (let [occurrences (atom {})
register-occurrence (fn [item]
  (if (get @occurrences item)
(swap! (get @occurrences item) inc)
(swap! occurrences assoc item (atom 
 1)))
  @(get @occurrences item))
process (fn [item]
  (let [duplicates (dec (register-occurrence item))]
(if ( duplicates 0)
  (formatter item duplicates)
  item)))
unique-s (map process s)]
unique-s)))
  
 -- 
 -- 
 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/groups/opt_out.



-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Guru Devanla
Ok. My bad. Should not be reading and responding to such posts from the
phone. Somehow, I overlooked that part of the mail. I think as Alex stated,
a simple way of holding on to seen objects in the set and reducing the list
should be good.


On Fri, Jan 10, 2014 at 7:14 AM, Colin Yates colin.ya...@gmail.com wrote:

 The missing context is that distinct removes duplicates, I want duplicates
 to be made unique by changing them in some way: (uniquify [a b c
 a]) = [a b c a_1]) *not* (uniquify [a b c a]) = [a
 b c])

 Not sure what else to put that isn't in the original post to be honest...

 --
 Date: Fri, 10 Jan 2014 07:10:22 -0800
 Subject: Re: How can I improve this?
 From: grd...@gmail.com
 To: clojure@googlegroups.com


 Hi Colin,

 Clojure has a distinct function that does this. I may be missing some
 context on what you what out of your new method that 'distinct' does not
 provide. The distinct functions source code is a good reference.

 Thanks


 On Fri, Jan 10, 2014 at 6:59 AM, Colin Yates colin.ya...@gmail.comwrote:

 I have a sequence of file names and I want to make them unique.  (uniquify
 [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?

 What would you all do?  Feedback welcome (including the word 'muppet' as I
 am sure I have missed something simple) :)

 (defn uniquify
   Return a sequence, in the same order as s containing every element
   of s. If s (which is presumed to be a string) occurs more than once
   then every subsequent occurrence will be made unique.

   Items will be updated to include an incrementing numeric count using
   the specified formatter function. The formatter function will be
   given the name and the number and should return a combination of the
   two.

   The set of unique s's in the returned sequence will be the count of
   s's in s.
   ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
   ([s formatter]
  (let [occurrences (atom {})
register-occurrence (fn [item]
  (if (get @occurrences item)
(swap! (get @occurrences item) inc)
(swap! occurrences assoc item (atom 1)))
  @(get @occurrences item))
process (fn [item]
  (let [duplicates (dec (register-occurrence item))]
(if ( duplicates 0)
  (formatter item duplicates)
  item)))
unique-s (map process s)]
unique-s)))

 --
 --
 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/groups/opt_out.



 --
 --
 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 a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojure/rt-l_X3gK-I/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 clojure+unsubscr...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.

 --
 --
 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/groups/opt_out.


-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to 

Re: How can I improve this?

2014-01-10 Thread Jim - FooBar();
I quickly put together this which seems to preserver the orderof the 
original seq:


(defn uniquify [coll]
 (let [post-fn #(group-by first (- % meta :encountered))]
  (loop [unique (with-meta [] {:encountered []})
[f  more] coll]
   (if (nil? f) (flatten (concat unique (reduce #(conj % (map str 
(second %2) (range))) [] (post-fn unique
 (recur (if-not (some #{f} unique) (conj unique f) (vary-meta 
unique update-in [:encountered] conj f)) more)



HTH,
Jim


On 10/01/14 15:24, Colin Yates wrote:
I did consider that but I want to preserve the order of the incoming 
sequence.


On Friday, 10 January 2014 15:22:29 UTC, Laurent PETIT wrote:

Hi,

Use frequencies to get a map of path = nb of occurrences, then
for each entry of the map, create unique names.
Cannot provide an impl on the uPhine, sorry

Le vendredi 10 janvier 2014, Colin Yates a écrit :

I have a sequence of file names and I want to make them
unique.  (uniquify [a b c a]) = [a b c a_1])

This is what I have come up with, but surely there is a better
way?

What would you all do?  Feedback welcome (including the word
'muppet' as I am sure I have missed something simple) :)

(defn uniquify
  Return a sequence, in the same order as s containing every
element
  of s. If s (which is presumed to be a string) occurs more
than once
  then every subsequent occurrence will be made unique.

  Items will be updated to include an incrementing numeric
count using
  the specified formatter function. The formatter function will be
  given the name and the number and should return a
combination of the
  two.

  The set of unique s's in the returned sequence will be the
count of
  s's in s.
  ([s] (uniquify s (fn [item duplicates] (str item _
duplicates
  ([s formatter]
 (let [occurrences (atom {})
   register-occurrence (fn [item]
 (if (get @occurrences item)
   (swap! (get @occurrences
item) inc)
   (swap! occurrences assoc
item (atom 1)))
 @(get @occurrences item))
   process (fn [item]
 (let [duplicates (dec
(register-occurrence item))]
   (if ( duplicates 0)
 (formatter item duplicates)
 item)))
   unique-s (map process s)]
   unique-s)))
-- 
-- 
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
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/groups/opt_out
https://groups.google.com/groups/opt_out.

--
--
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/groups/opt_out.


--
--
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 

Re: How can I improve this?

2014-01-10 Thread Laurent PETIT
Le vendredi 10 janvier 2014, Colin Yates a écrit :

 I did consider that but I want to preserve the order of the incoming
 sequence.


 On Friday, 10 January 2014 15:22:29 UTC, Laurent PETIT wrote:

 Hi,

 Use frequencies to get a map of path = nb of occurrences, then for each
 entry of the map, create unique names.
 Cannot provide an impl on the uPhine, sorry

 Le vendredi 10 janvier 2014, Colin Yates a écrit :

 I have a sequence of file names and I want to make them unique.
  (uniquify [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?

 What would you all do?  Feedback welcome (including the word 'muppet' as
 I am sure I have missed something simple) :)

 (defn uniquify
   Return a sequence, in the same order as s containing every element
   of s. If s (which is presumed to be a string) occurs more than once
   then every subsequent occurrence will be made unique.

   Items will be updated to include an incrementing numeric count using
   the specified formatter function. The formatter function will be
   given the name and the number and should return a combination of the
   two.

   The set of unique s's in the returned sequence will be the count of
   s's in s.
   ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
   ([s formatter]
  (let [occurrences (atom {})
register-occurrence (fn [item]
  (if (get @occurrences item)
(swap! (get @occurrences item) inc)
(swap! occurrences assoc item (atom
 1)))
  @(get @occurrences item))
process (fn [item]
  (let [duplicates (dec (register-occurrence item))]
(if ( duplicates 0)
  (formatter item duplicates)
  item)))
unique-s (map process s)]
unique-s)))

 --
 --
 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/groups/opt_out.


Then call frequencies for the nbr of occurrences per entry, then
reduce over the initial sequence, including the map in the accumulator,
decrement info the nbr every time you find an occurrence ?

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to 
 clojure@googlegroups.comjavascript:_e({}, 'cvml', 
 '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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@googlegroups.com');.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Jim - FooBar();

actually `post-fn` should be #(group-by identity (- % meta :encountered))

Jim


On 10/01/14 15:28, Jim - FooBar(); wrote:
I quickly put together this which seems to preserver the orderof the 
original seq:


(defn uniquify [coll]
 (let [post-fn #(group-by first (- % meta :encountered))]
  (loop [unique (with-meta [] {:encountered []})
[f  more] coll]
   (if (nil? f) (flatten (concat unique (reduce #(conj % (map str 
(second %2) (range))) [] (post-fn unique
 (recur (if-not (some #{f} unique) (conj unique f) (vary-meta 
unique update-in [:encountered] conj f)) more)



HTH,
Jim


On 10/01/14 15:24, Colin Yates wrote:
I did consider that but I want to preserve the order of the incoming 
sequence.


On Friday, 10 January 2014 15:22:29 UTC, Laurent PETIT wrote:

Hi,

Use frequencies to get a map of path = nb of occurrences, then
for each entry of the map, create unique names.
Cannot provide an impl on the uPhine, sorry

Le vendredi 10 janvier 2014, Colin Yates a écrit :

I have a sequence of file names and I want to make them
unique.  (uniquify [a b c a]) = [a b c a_1])

This is what I have come up with, but surely there is a
better way?

What would you all do?  Feedback welcome (including the word
'muppet' as I am sure I have missed something simple) :)

(defn uniquify
  Return a sequence, in the same order as s containing every
element
  of s. If s (which is presumed to be a string) occurs more
than once
  then every subsequent occurrence will be made unique.

  Items will be updated to include an incrementing numeric
count using
  the specified formatter function. The formatter function
will be
  given the name and the number and should return a
combination of the
  two.

  The set of unique s's in the returned sequence will be the
count of
  s's in s.
  ([s] (uniquify s (fn [item duplicates] (str item _
duplicates
  ([s formatter]
 (let [occurrences (atom {})
   register-occurrence (fn [item]
 (if (get @occurrences item)
   (swap! (get @occurrences
item) inc)
   (swap! occurrences assoc
item (atom 1)))
 @(get @occurrences item))
   process (fn [item]
 (let [duplicates (dec
(register-occurrence item))]
   (if ( duplicates 0)
 (formatter item duplicates)
 item)))
   unique-s (map process s)]
   unique-s)))
-- 
-- 
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
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/groups/opt_out
https://groups.google.com/groups/opt_out.

--
--
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/groups/opt_out.




--
--
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: How can I improve this?

2014-01-10 Thread Jim - FooBar();

oops! my fn will not keep the original ordering...sorry Colin

Jim


On 10/01/14 15:34, Jim - FooBar(); wrote:

actually `post-fn` should be #(group-by identity (- % meta :encountered))

Jim


On 10/01/14 15:28, Jim - FooBar(); wrote:
I quickly put together this which seems to preserver the orderof the 
original seq:


(defn uniquify [coll]
 (let [post-fn #(group-by first (- % meta :encountered))]
  (loop [unique (with-meta [] {:encountered []})
[f  more] coll]
   (if (nil? f) (flatten (concat unique (reduce #(conj % (map str 
(second %2) (range))) [] (post-fn unique
 (recur (if-not (some #{f} unique) (conj unique f) (vary-meta 
unique update-in [:encountered] conj f)) more)



HTH,
Jim


On 10/01/14 15:24, Colin Yates wrote:
I did consider that but I want to preserve the order of the incoming 
sequence.


On Friday, 10 January 2014 15:22:29 UTC, Laurent PETIT wrote:

Hi,

Use frequencies to get a map of path = nb of occurrences, then
for each entry of the map, create unique names.
Cannot provide an impl on the uPhine, sorry

Le vendredi 10 janvier 2014, Colin Yates a écrit :

I have a sequence of file names and I want to make them
unique.  (uniquify [a b c a]) = [a b c a_1])

This is what I have come up with, but surely there is a
better way?

What would you all do?  Feedback welcome (including the word
'muppet' as I am sure I have missed something simple) :)

(defn uniquify
  Return a sequence, in the same order as s containing
every element
  of s. If s (which is presumed to be a string) occurs more
than once
  then every subsequent occurrence will be made unique.

  Items will be updated to include an incrementing numeric
count using
  the specified formatter function. The formatter function
will be
  given the name and the number and should return a
combination of the
  two.

  The set of unique s's in the returned sequence will be the
count of
  s's in s.
  ([s] (uniquify s (fn [item duplicates] (str item _
duplicates
  ([s formatter]
 (let [occurrences (atom {})
   register-occurrence (fn [item]
 (if (get @occurrences item)
   (swap! (get @occurrences
item) inc)
   (swap! occurrences assoc
item (atom 1)))
 @(get @occurrences item))
   process (fn [item]
 (let [duplicates (dec
(register-occurrence item))]
   (if ( duplicates 0)
 (formatter item duplicates)
 item)))
   unique-s (map process s)]
   unique-s)))
-- 
-- 
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
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/groups/opt_out
https://groups.google.com/groups/opt_out.

--
--
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/groups/opt_out.






--
--
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

Re: [ClojureScript] [ANN] Cloact 0.1.0 - Yet another React wrapper for ClojureScript

2014-01-10 Thread David Nolen
Looks very nice :)

On Friday, January 10, 2014, Dan Holmsand wrote:

 Cloact is a minimalistic interface between ClojureScript and React.js,
 that now has a proper introduction, some documentation and a few examples
 here:

 http://holmsand.github.io/cloact/

 Project page and installation instructions are here:

 https://github.com/holmsand/cloact

 Enjoy,

 /dan

 --
 Note that posts from new members are moderated - please be patient with
 your first post.
 ---
 You received this message because you are subscribed to the Google Groups
 ClojureScript group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to clojurescript+unsubscr...@googlegroups.com javascript:;.
 To post to this group, send email to 
 clojurescr...@googlegroups.comjavascript:;
 .
 Visit this group at http://groups.google.com/group/clojurescript.


-- 
-- 
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/groups/opt_out.


Re: [ClojureScript] [ANN] Cloact 0.1.0 - Yet another React wrapper for ClojureScript

2014-01-10 Thread Dan Holmsand
On Friday, January 10, 2014 5:23:19 PM UTC+1, David Nolen wrote:
 Looks very nice :)

Thanks!

/dan

-- 
-- 
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/groups/opt_out.


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread Stefan Kanev
On 10/01/14, christian jacobsen wrote:
 I have +10 years experience of OO programming (C++, C# and a little Java) 
 and a couple of years of FP programming (mainly F#, some Scala and a little 
 Haskell). 
 Are there any resources for learning Clojure that are particular good for 
 someone with the above background?

I strongly suggest you get a copy of the O'Reilly book (Clojure
Programming).  I have a somewhat similar background and it worked great
for me.  On one hand, it goes deep enough in the language (at least for
me) and on the other it is very well written.

I also like The Joy of Clojure.  The first edition covered an oldered
version and I have no idea about the second.

-- 
Stefan Kanev Ś @skanev Ś http://skanev.com/
Often it is the means that justify the ends: Goals advance technique and
technique survives even when goal structures crumble.

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Stefan Kanev
On 10/01/14, Colin Yates wrote:
 I have a sequence of file names and I want to make them unique.  (uniquify 
 [a b c a]) = [a b c a_1])
 
 This is what I have come up with, but surely there is a better way?
 
 What would you all do?  Feedback welcome (including the word 'muppet' as I 
 am sure I have missed something simple) :)
 
 (defn uniquify
   Return a sequence, in the same order as s containing every element
   of s. If s (which is presumed to be a string) occurs more than once
   then every subsequent occurrence will be made unique.
 
   Items will be updated to include an incrementing numeric count using
   the specified formatter function. The formatter function will be
   given the name and the number and should return a combination of the
   two.
 
   The set of unique s's in the returned sequence will be the count of
   s's in s.  
   ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
   ([s formatter]
  (let [occurrences (atom {})
register-occurrence (fn [item]
  (if (get @occurrences item)
(swap! (get @occurrences item) inc)
(swap! occurrences assoc item (atom 1)))
  @(get @occurrences item))
process (fn [item]
  (let [duplicates (dec (register-occurrence item))]
(if ( duplicates 0)
  (formatter item duplicates)
  item)))
unique-s (map process s)]
unique-s)))

I came up with the following version:

(defn uniquify [words]
  (loop [encountered {}
 result []
 remaining words]
(if (seq remaining)
  (let [word (first remaining)
occurences (get encountered word)
modified (if occurences
   (str word _ occurences)
   word)]
(recur (update-in encountered [word] (fnil inc 0))
   (conj result modified)
   (rest remaining)))
  result)))

It is a bit Scheme-ish.  It builds a map of number of occurences as it
builds a vector, containing the result.  It uses the map to figure out
whether to add a suffix or not.  It preserves the original order of the
names.  The variable names could use some love, but I don't have the
time for it now.

If you want a lazy version, some modification is needed.
-- 
Stefan Kanev Ś @skanev Ś http://skanev.com/
Giving up on assembly language was the apple in our Garden of Eden: Languages
whose use squanders machine cycles are sinful.  The LISP machine now permits
LISP programmers to abandon bra and fig-leaf.

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Laurent PETIT
2014/1/10 Stefan Kanev stefan.ka...@gmail.com

 On 10/01/14, Colin Yates wrote:
  I have a sequence of file names and I want to make them unique.
  (uniquify
  [a b c a]) = [a b c a_1])
 
  This is what I have come up with, but surely there is a better way?
 
  What would you all do?  Feedback welcome (including the word 'muppet' as
 I
  am sure I have missed something simple) :)
 
  (defn uniquify
Return a sequence, in the same order as s containing every element
of s. If s (which is presumed to be a string) occurs more than once
then every subsequent occurrence will be made unique.
 
Items will be updated to include an incrementing numeric count using
the specified formatter function. The formatter function will be
given the name and the number and should return a combination of the
two.
 
The set of unique s's in the returned sequence will be the count of
s's in s.
([s] (uniquify s (fn [item duplicates] (str item _ duplicates
([s formatter]
   (let [occurrences (atom {})
 register-occurrence (fn [item]
   (if (get @occurrences item)
 (swap! (get @occurrences item) inc)
 (swap! occurrences assoc item (atom
 1)))
   @(get @occurrences item))
 process (fn [item]
   (let [duplicates (dec (register-occurrence item))]
 (if ( duplicates 0)
   (formatter item duplicates)
   item)))
 unique-s (map process s)]
 unique-s)))

 I came up with the following version:

 (defn uniquify [words]
   (loop [encountered {}
  result []
  remaining words]
 (if (seq remaining)
   (let [word (first remaining)
 occurences (get encountered word)
 modified (if occurences
(str word _ occurences)
word)]
 (recur (update-in encountered [word] (fnil inc 0))
(conj result modified)
(rest remaining)))
   result)))

 It is a bit Scheme-ish.  It builds a map of number of occurences as it
 builds a vector, containing the result.  It uses the map to figure out
 whether to add a suffix or not.  It preserves the original order of the
 names.  The variable names could use some love, but I don't have the
 time for it now.

 If you want a lazy version, some modification is needed.


Note that the lazy version would preserve doing too much computation ahead
of time, but would not be any more space efficient than a non lazy version,
even if the consumer of the lazy sequence does not retain the head. That is
because at the same time that the remaining seq is consumed, the
encountered map is updated. In the worst case scenario where all coll items
are different, the map when then last lazy seq item is produced will be of
the same size as the initial sequence.



 --
 Stefan Kanev Ś @skanev Ś http://skanev.com/
 Giving up on assembly language was the apple in our Garden of Eden:
 Languages
 whose use squanders machine cycles are sinful.  The LISP machine now
 permits
 LISP programmers to abandon bra and fig-leaf.

 --
 --
 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/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Jonas
Here's a version using reduce:

  (defn uniquify [items]
(first
  (reduce (fn [[result count-map] item]
(let [n (inc (count-map item 0))]
  [(conj result (str item _ n))
   (assoc count-map item n)]))
  [[] {}]
  items)))

Replace (str item _ n) with (if (zero? n) item (str item _ n) if you 
don't want to append _0 the first time you encounter a new string

On Friday, January 10, 2014 5:12:27 PM UTC+2, Alex Miller wrote:

 I would not use an atom. Think about it as doing a reduce while passing 
 along a set of the names you've seen so far. You might also look at the 
 implementation of distinct in clojure.core which is similar (you want to 
 detect duplicates in the same way, but emit new names instead of omitting 
 dupes).


 On Friday, January 10, 2014 8:59:10 AM UTC-6, Colin Yates wrote:

 I have a sequence of file names and I want to make them unique. 
  (uniquify [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?

 What would you all do?  Feedback welcome (including the word 'muppet' as 
 I am sure I have missed something simple) :)

 (defn uniquify
   Return a sequence, in the same order as s containing every element
   of s. If s (which is presumed to be a string) occurs more than once
   then every subsequent occurrence will be made unique.

   Items will be updated to include an incrementing numeric count using
   the specified formatter function. The formatter function will be
   given the name and the number and should return a combination of the
   two.

   The set of unique s's in the returned sequence will be the count of
   s's in s.  
   ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
   ([s formatter]
  (let [occurrences (atom {})
register-occurrence (fn [item]
  (if (get @occurrences item)
(swap! (get @occurrences item) inc)
(swap! occurrences assoc item (atom 
 1)))
  @(get @occurrences item))
process (fn [item]
  (let [duplicates (dec (register-occurrence item))]
(if ( duplicates 0)
  (formatter item duplicates)
  item)))
unique-s (map process s)]
unique-s)))



-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Stefan Kanev
Somehow I totally forgot I could use destructuring.  Here's a slightly
shorter version:

(defn uniquify [words]
  (loop [encountered {}
 result []
 [word  remaining] words]
(if (seq remaining)
  (let [occurences (get encountered word)
modified (if occurences
   (str word _ occurences)
   word)]
(recur (update-in encountered [word] (fnil inc 0))
   (conj result modified)
   remaining))
  result)))

-- 
Stefan Kanev  ¦  @skanev  ¦  http://skanev.com/
You can measure a programmer's perspective by noting his attitude on the
continuing vitality of FORTRAN.

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Laurent PETIT
no you have a bug in this last version, it now skips the last result


2014/1/10 Stefan Kanev stefan.ka...@gmail.com

 Somehow I totally forgot I could use destructuring.  Here's a slightly
 shorter version:

 (defn uniquify [words]
   (loop [encountered {}
  result []
  [word  remaining] words]
 (if (seq remaining)
   (let [occurences (get encountered word)
 modified (if occurences
(str word _ occurences)
word)]
 (recur (update-in encountered [word] (fnil inc 0))
(conj result modified)
remaining))
   result)))

 --
 Stefan Kanev  ¦  @skanev  ¦  http://skanev.com/
 You can measure a programmer's perspective by noting his attitude on the
 continuing vitality of FORTRAN.

 --
 --
 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/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Laurent PETIT
What about this one?

Inspired by Stefan's, with more destructuring in loop, format-fn as a
function, initial call to (seq) then (next) instead of (rest), placing the
exit argument first so that it's not lost at the end of the function,
renamed word as item since this function does not depend on the type of
items.

(defn uniquify [in format-fn]
  (loop [[item :as in] (seq in)
 {n item :as item-nbrs} {}
 out []]
(if-not in
  out
  (let [format-fn (if n format-fn (constantly item))]
(recur (next in)
   (update-in item-nbrs [item] (fnil inc 0))
   (conj out (format-fn item n)))


2014/1/10 Laurent PETIT laurent.pe...@gmail.com

 no you have a bug in this last version, it now skips the last result


 2014/1/10 Stefan Kanev stefan.ka...@gmail.com

 Somehow I totally forgot I could use destructuring.  Here's a slightly
 shorter version:

 (defn uniquify [words]
   (loop [encountered {}
  result []
  [word  remaining] words]
 (if (seq remaining)
   (let [occurences (get encountered word)
 modified (if occurences
(str word _ occurences)
word)]
 (recur (update-in encountered [word] (fnil inc 0))
(conj result modified)
remaining))
   result)))

 --
 Stefan Kanev  ¦  @skanev  ¦  http://skanev.com/
 You can measure a programmer's perspective by noting his attitude on the
 continuing vitality of FORTRAN.

 --
 --
 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/groups/opt_out.




-- 
-- 
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/groups/opt_out.


Re: JAVA_OPTS not accessible in my Clojure project

2014-01-10 Thread juan.facorro
Hi Aidy,

What do mean when you say load the nRepl in the lein project?

Juan

On Friday, January 10, 2014 9:42:02 AM UTC-3, Aidy Lewis wrote:

 Clojurians,

 For some reason JAVA_OPTS are not accessible in my Clojure project.

 The command line seems to be OK, if I:

 $ lein repl

 project-ns =  (System/getProperty javax.net.ssl.keyStore)

 - /../certs/dev.bbc.co.uk.p12


 However, if I load the nRepl in the lein project:

 project-ns =  (System/getProperty javax.net.ssl.keyStore)

 - nil

 Not sure why this is the case?

 Thanks
 -- 
 @AidyLewis
  

-- 
-- 
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/groups/opt_out.


[ANN] Counterclockwise 0.22.0

2014-01-10 Thread Laurent PETIT
Hello,

Counterclockwise is an Eclipse Plugin for developing Clojure code.

A few hours after the launch of Counterclockwise 0.21.0, I've had enough
work done to be able to release an interesting upgrade as 0.22.0.

It builds on the foundations introduced by 0.21.0, and adds a more polished
integration of Leiningen:

- New Command for launching a nREPL headless server via Leiningen ( Alt+L H
)
- Patched version of Leiningen 2.3.4 showing nREPL URLs when started with
lein repl :headless
- When the nREPL URL is output to the Console view, a corresponding REPL
View is automatically opened

Plus some additional polishing concerning Leiningen in the documentation.

Install
=

Installation instructions are in the documentation:

http://doc.ccw-ide.org/documentation.html#_install_counterclockwise

Release Note
==
http://doc.ccw-ide.org/ChangeLog.html#_changes_between_counterclockwise_0_21_0_and_0_22_0

Cheers,

-- 
Laurent Petit

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Stefan Kanev
On 10/01/14, Laurent PETIT wrote:
 What about this one?
 
 Inspired by Stefan's, with more destructuring in loop, format-fn as a
 function, initial call to (seq) then (next) instead of (rest), placing the
 exit argument first so that it's not lost at the end of the function,
 renamed word as item since this function does not depend on the type of
 items.
 
 (defn uniquify [in format-fn]
   (loop [[item :as in] (seq in)
  {n item :as item-nbrs} {}
  out []]
 (if-not in
   out
   (let [format-fn (if n format-fn (constantly item))]
 (recur (next in)
(update-in item-nbrs [item] (fnil inc 0))
(conj out (format-fn item n)))

Yeah, that's better.  I like using `if-not` instead of `if` - it puts
the base case first, which I find preferable.  An adequate format
function can be given by defining a single-parameter version of
`uniquify`.
-- 
Stefan Kanev  ¦  @skanev  ¦  http://skanev.com/
Think of all the psychic energy expended in seeking a fundamental distinction
between algorithm and program.

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Mark Engelberg
If all you need is unqiueness, why not just number *all* the filenames in
sequential order, something like:

(defn uniqueify [filenames]
  (map (fn [filename number] (str filename \_ number)) filenames (iterate
inc 1)))

-- 
-- 
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/groups/opt_out.


Re: [ANN] DACOM: A skeleton app, Leiningen template for Datomic, Compojure, and Om

2014-01-10 Thread Manuel Paccagnella
Thank you for putting the time on building and documenting this template! 
I'm going to test some ideas with it.

Il giorno venerdì 10 gennaio 2014 06:06:34 UTC+1, Kevin Bell ha scritto:

 A Leiningen template featuring all of the most popular Clojure 
 technologies that all of the coolest kids are using:

 sample project repo https://github.com/bellkev/dacom

 or

 `lein new dacom my-project`


-- 
-- 
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/groups/opt_out.


attaching a status message to close on core.async

2014-01-10 Thread t x
Hi,

  When closing a core.async channel, as in
http://clojure.github.io/core.async/

  is it possible to attach a status/messaage to the close operation?

Thanks!

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are 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/groups/opt_out.


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread Gary Trakhman
I loved the 'Joy of Clojure' as my first clojure book, but it was a little
over my head at the time I started reading it, so it took subjectively
quite a while to internalize everything.  Since I didn't need to 'get stuff
done' immediately, I think, in the end, it's great to learn things with
such an insightful book. However, if I were in a hurry I might pick
something else.


On Fri, Jan 10, 2014 at 1:55 PM, Sean Corfield s...@corfield.org wrote:

 On Jan 10, 2014, at 7:18 AM, Stefan Kanev stefan.ka...@gmail.com wrote:
  I strongly suggest you get a copy of the O'Reilly book (Clojure
  Programming)

 I'll second that recommendation, and also suggest Brian Marick's
 Functional Programming for the Object-Oriented Programmer:

 https://leanpub.com/fp-oo

 But, yes, coming from a heavy OOP background can make it challenging to
 really internalize FP, especially if your OOP background is all Java.

 Sean Corfield -- (904) 302-SEAN
 An Architect's View -- http://corfield.org/

 Perfection is the enemy of the good.
 -- Gustave Flaubert, French realist novelist (1821-1880)





-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Sean Corfield
java.jdbc does this for column names (in joins):

https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc.clj#L257

Sean

On Jan 10, 2014, at 6:59 AM, Colin Yates colin.ya...@gmail.com wrote:

 I have a sequence of file names and I want to make them unique.  (uniquify 
 [a b c a]) = [a b c a_1])
 
 This is what I have come up with, but surely there is a better way?
 
 What would you all do?  Feedback welcome (including the word 'muppet' as I am 
 sure I have missed something simple) :)



signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread Sean Corfield
On Jan 10, 2014, at 11:02 AM, Gary Trakhman gary.trakh...@gmail.com wrote:
 I loved the 'Joy of Clojure' as my first clojure book, but it was a little 
 over my head at the time I started reading it, so it took subjectively quite 
 a while to internalize everything.

JoC was my first Clojure book - but I had plenty of background in FP (albeit a 
bit rusty).

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)





signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: How can I improve this?

2014-01-10 Thread Guru Devanla
But, for the given problem this may not be directly helpful. This method
only returns the next unique name for the given list. The logic would have
to traverse the list n times for n elements (and some factor of no of
duplicates) to get the desired result, correct?

Thanks
Guru


On Fri, Jan 10, 2014 at 11:03 AM, Sean Corfield s...@corfield.org wrote:

 java.jdbc does this for column names (in joins):


 https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc.clj#L257

 Sean

 On Jan 10, 2014, at 6:59 AM, Colin Yates colin.ya...@gmail.com wrote:

 I have a sequence of file names and I want to make them unique.  (uniquify
 [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?

 What would you all do?  Feedback welcome (including the word 'muppet' as I
 am sure I have missed something simple) :)




-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Colin Yates
This and Jonas' are my current favourites, for what that's worth.

Keep the suggestions coming! 

On Friday, 10 January 2014 17:29:20 UTC, Laurent PETIT wrote:

 What about this one?

 Inspired by Stefan's, with more destructuring in loop, format-fn as a 
 function, initial call to (seq) then (next) instead of (rest), placing the 
 exit argument first so that it's not lost at the end of the function, 
 renamed word as item since this function does not depend on the type of 
 items.

 (defn uniquify [in format-fn]
   (loop [[item :as in] (seq in)
  {n item :as item-nbrs} {}
  out []]
 (if-not in
   out
   (let [format-fn (if n format-fn (constantly item))]
 (recur (next in)
(update-in item-nbrs [item] (fnil inc 0))
(conj out (format-fn item n)))


 2014/1/10 Laurent PETIT lauren...@gmail.com javascript:

 no you have a bug in this last version, it now skips the last result


 2014/1/10 Stefan Kanev stefan...@gmail.com javascript:

 Somehow I totally forgot I could use destructuring.  Here's a slightly
 shorter version:

 (defn uniquify [words]
   (loop [encountered {}
  result []
  [word  remaining] words]
 (if (seq remaining)
   (let [occurences (get encountered word)
 modified (if occurences
(str word _ occurences)
word)]
 (recur (update-in encountered [word] (fnil inc 0))
(conj result modified)
remaining))
   result)))

 --
 Stefan Kanev  ¦  @skanev  ¦  http://skanev.com/
 You can measure a programmer's perspective by noting his attitude on the
 continuing vitality of FORTRAN.

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to clo...@googlegroups.comjavascript:
 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/groups/opt_out.





-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Guru Devanla
Actually, you might have meant line 267?


On Fri, Jan 10, 2014 at 11:03 AM, Sean Corfield s...@corfield.org wrote:

 java.jdbc does this for column names (in joins):


 https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc.clj#L257

 Sean

 On Jan 10, 2014, at 6:59 AM, Colin Yates colin.ya...@gmail.com wrote:

 I have a sequence of file names and I want to make them unique.  (uniquify
 [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?

 What would you all do?  Feedback welcome (including the word 'muppet' as I
 am sure I have missed something simple) :)




-- 
-- 
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/groups/opt_out.


Re: [ANN] DACOM: A skeleton app, Leiningen template for Datomic, Compojure, and Om

2014-01-10 Thread Curtis Gagliardi
That's my stack right now, I'll have to check this out and take notes, see 
what we're doing differently.  This is all pretty uncharted territory it 
seems.  Thanks for putting this out there.

On Thursday, January 9, 2014 9:06:34 PM UTC-8, Kevin Bell wrote:

 A Leiningen template featuring all of the most popular Clojure 
 technologies that all of the coolest kids are using:

 sample project repo https://github.com/bellkev/dacom

 or

 `lein new dacom my-project`


-- 
-- 
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/groups/opt_out.


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread Curtis Gagliardi
I really think Clojure Programming is the best Clojure book out there.  If 
you read that thing most (or all) of the way through, you'll have a very 
solid understanding of Clojure.  

On Friday, January 10, 2014 4:52:53 AM UTC-8, christian jacobsen wrote:

 I have +10 years experience of OO programming (C++, C# and a little Java) 
 and a couple of years of FP programming (mainly F#, some Scala and a little 
 Haskell). 
 Are there any resources for learning Clojure that are particular good for 
 someone with the above background?


-- 
-- 
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/groups/opt_out.


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread Curtis Gagliardi
I also want to second watching all of Rich Hickey's talks, especially are 
we there yet and simple made easy, they really help you get the 
philosophies behind the language.  For me, I found myself agreeing with all 
the principles of simplicity he talks about, and it increased both my 
motivation to the learn the language and my understanding of why it is the 
way it is.  

On Friday, January 10, 2014 11:20:47 AM UTC-8, Curtis Gagliardi wrote:

 I really think Clojure Programming is the best Clojure book out there.  If 
 you read that thing most (or all) of the way through, you'll have a very 
 solid understanding of Clojure.  

 On Friday, January 10, 2014 4:52:53 AM UTC-8, christian jacobsen wrote:

 I have +10 years experience of OO programming (C++, C# and a little Java) 
 and a couple of years of FP programming (mainly F#, some Scala and a little 
 Haskell). 
 Are there any resources for learning Clojure that are particular good for 
 someone with the above background?



-- 
-- 
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/groups/opt_out.


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread Andrey Antukh
+1 for Clojure Programming of Oreilly


2014/1/10 Curtis Gagliardi gagliardi.cur...@gmail.com

 I really think Clojure Programming is the best Clojure book out there.  If
 you read that thing most (or all) of the way through, you'll have a very
 solid understanding of Clojure.


 On Friday, January 10, 2014 4:52:53 AM UTC-8, christian jacobsen wrote:

 I have +10 years experience of OO programming (C++, C# and a little Java)
 and a couple of years of FP programming (mainly F#, some Scala and a little
 Haskell).
 Are there any resources for learning Clojure that are particular good for
 someone with the above background?

  --
 --
 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/groups/opt_out.




-- 
Andrey Antukh - Андрей Антух - andrei.anto...@kaleidos.net / n...@niwi.be

http://www.niwi.be http://www.niwi.be/page/about/
https://github.com/niwibe

-- 
-- 
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/groups/opt_out.


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread Guru Devanla
IMO there are 2 aspects of learning Clojure coming from an imperative
and/or OO background. One s the functional aspect of it and other the
idioms and the language itself.  To learn the language a book like 'Clojure
Programming' would be a good start as others have suggested. It will help
you quickly get into building some stuff right away. Another good book I
thought you could get through faster in 'Pragmatic Clojure'.I found this
book to be the next level to Clojure Programming.

But, it will take more time and practice (along with pure joy!) to
internalize the functional way of doing things.  For the functional
exercise, even one other book I thought is useful are smaller and simpler
books like Little Schemer etc, though you will have to spend time
understand the syntax of yet another FP language. But again, you could put
your experience of F# to good use here.

Thanks


On Fri, Jan 10, 2014 at 11:25 AM, Andrey Antukh n...@niwi.be wrote:

 +1 for Clojure Programming of Oreilly


 2014/1/10 Curtis Gagliardi gagliardi.cur...@gmail.com

 I really think Clojure Programming is the best Clojure book out there.
  If you read that thing most (or all) of the way through, you'll have a
 very solid understanding of Clojure.


 On Friday, January 10, 2014 4:52:53 AM UTC-8, christian jacobsen wrote:

 I have +10 years experience of OO programming (C++, C# and a little
 Java) and a couple of years of FP programming (mainly F#, some Scala and a
 little Haskell).
 Are there any resources for learning Clojure that are particular good
 for someone with the above background?

  --
 --
 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/groups/opt_out.




 --
 Andrey Antukh - Андрей Антух - andrei.anto...@kaleidos.net / 
 n...@niwi.be
 http://www.niwi.be http://www.niwi.be/page/about/
 https://github.com/niwibe

 --
 --
 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/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread Colin Yates
At the risk of self promotion*, have a read 
of https://groups.google.com/d/msg/clojure/rt-l_X3gK-I/K80axT77XzwJ - it is 
an excellent example of iterative compared to functional.  You can see at 
least 4 distinct approaches to solving a fairly straight forward problem. 
 It is a startlingly clear example of how elegant Clojure can become.

* it isn't self promotion at all!  It is self deprecation - my solution is 
clearly lame, hence the original post :).

On Friday, 10 January 2014 12:52:53 UTC, christian jacobsen wrote:

 I have +10 years experience of OO programming (C++, C# and a little Java) 
 and a couple of years of FP programming (mainly F#, some Scala and a little 
 Haskell). 
 Are there any resources for learning Clojure that are particular good for 
 someone with the above background?


-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Mark Engelberg
Technically, all these solutions are flawed.

With the input
[a a a_1]
you'll get back
[a a_1 a_1]

To truly address this, you need to also add the newly formatted filename
into the seen map, which none of the suggested solutions do.

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Jonas Enlund
On Fri, Jan 10, 2014 at 9:39 PM, Mark Engelberg mark.engelb...@gmail.comwrote:

 Technically, all these solutions are flawed.

 With the input
 [a a a_1]
 you'll get back
 [a a_1 a_1]

 To truly address this, you need to also add the newly formatted filename
 into the seen map, which none of the suggested solutions do.


That's why I wrote my solution like I did, i.e., concatenate _1 when a
new string is found. This would result in the vector [a_1 a_2 a_1_1]


  --
 --
 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 a topic in the
 Google Groups Clojure group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/clojure/rt-l_X3gK-I/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to
 clojure+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: JAVA_OPTS not accessible in my Clojure project

2014-01-10 Thread aidy lewis
Hi Juan,

Maybe I should rephrase my issue.

If I create a new leiningen project

$ lein new foo

And type

$ lein repl

user=  (System/getProperty javax.net.ssl.keyStore)

 /Users/lewisa29/certs/dev.bbc.co.uk.p12

Now if I enter this into core.clj of the foo project

(ns foo.core)

(System/getProperty javax.net.ssl.keyStore) ;; C-x C-e

And execute this function through the Emacs CIDER REPL, I receive 'nil'.

Why can I not access the keystore in $JAVA_OPTS in my project?

Thanks

Aidy





On 10 January 2014 17:47, juan.facorro juan.faco...@gmail.com wrote:

 Hi Aidy,

 What do mean when you say load the nRepl in the lein project?

 Juan

 On Friday, January 10, 2014 9:42:02 AM UTC-3, Aidy Lewis wrote:

 Clojurians,

 For some reason JAVA_OPTS are not accessible in my Clojure project.

 The command line seems to be OK, if I:

 $ lein repl

 project-ns =  (System/getProperty javax.net.ssl.keyStore)

 - /../certs/dev.bbc.co.uk.p12


 However, if I load the nRepl in the lein project:

 project-ns =  (System/getProperty javax.net.ssl.keyStore)

 - nil

 Not sure why this is the case?

 Thanks
 --
 @AidyLewis

  --
 --
 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/groups/opt_out.




-- 
@AidyLewis

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Mark Engelberg
On Fri, Jan 10, 2014 at 11:43 AM, Jonas Enlund jonas.enl...@gmail.comwrote:

 That's why I wrote my solution like I did, i.e., concatenate _1 when a
 new string is found. This would result in the vector [a_1 a_2 a_1_1]


Right, I agree that works, as does my tack unique numbers onto the end of
everything solution.  That doesn't appear to be what the OP wants, though,
so I'm just saying that if he really insists on having naked names as
much as possible, then it's important to also compare the names not only
against previous filenames, but against the modified filenames that have
come before.

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Colin Yates
way to take the wind out of our sails!  Well spotted :).

On Friday, 10 January 2014 19:39:45 UTC, puzzler wrote:

 Technically, all these solutions are flawed.

 With the input 
 [a a a_1]
 you'll get back
 [a a_1 a_1]

 To truly address this, you need to also add the newly formatted filename 
 into the seen map, which none of the suggested solutions do.


-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Cedric Greevey
On Fri, Jan 10, 2014 at 10:22 AM, Laurent PETIT laurent.pe...@gmail.comwrote:

 Hi,

 Use frequencies to get a map of path = nb of occurrences, then for each
 entry of the map, create unique names.
 Cannot provide an impl on the uPhine, sorry


uPhine? :)

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Mark Engelberg
On Fri, Jan 10, 2014 at 11:52 AM, Colin Yates colin.ya...@gmail.com wrote:
 way to take the wind out of our sails!  Well spotted :).


It's not too hard to fix.   Here's an adapted version of Jonas' solution
that should do the trick:

(defn uniqueify [items]
  (first
(reduce (fn [[results count-map] item]
  (let [n (count-map item 0)]
(if (zero? n)
  [(conj results item) (assoc count-map item (inc n))]
  (recur [results (assoc count-map item (inc n))]
 (str item \_ n)
[[] {}]
items)))

= (uniqueify [a a a a b a_2 a_3 a_3_1 a_3_1 a])
[a a_1 a_2 a_3 b a_2_1 a_3_1 a_3_1_1 a_3_1_2 a_4]

-- 
-- 
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/groups/opt_out.


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread christian jacobsen
Great tips, thank you all! :)

On Friday, January 10, 2014 8:34:47 PM UTC+1, Colin Yates wrote:

 At the risk of self promotion*, have a read of 
 https://groups.google.com/d/msg/clojure/rt-l_X3gK-I/K80axT77XzwJ - it is 
 an excellent example of iterative compared to functional.  You can see at 
 least 4 distinct approaches to solving a fairly straight forward problem. 
  It is a startlingly clear example of how elegant Clojure can become.

 * it isn't self promotion at all!  It is self deprecation - my solution is 
 clearly lame, hence the original post :).

 On Friday, 10 January 2014 12:52:53 UTC, christian jacobsen wrote:

 I have +10 years experience of OO programming (C++, C# and a little Java) 
 and a couple of years of FP programming (mainly F#, some Scala and a little 
 Haskell). 
 Are there any resources for learning Clojure that are particular good for 
 someone with the above background?



-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Colin Yates
I thought I would have a go myself without copying (although having read 
them earlier) the other functions and this is what I came up with:

(first (reduce (fn [[results seen] item]
  (let [occurrences ((fnil identity 0) (get seen item))
seen (assoc seen item (inc occurrences))
item (if ( occurrences 0) (format-fn item 
occurrences) item)]
[(conj results item) seen])) [[] {}] (seq items)))

This doesn't solve the problem you mention, but baby steps.

Being really anal I could claim the original a_2 should remain a_2 and the 
third instance of a jump to being a_3.  I thought about this and couldn't 
see how to do this with reduce because I really want to say oh, I have a 
new name, recurse into the function again with the new proposed name, i.e. 
loop the generation of the proposed name until it is unique, but I haven't 
got that far yet (without potentially blowing the stack!)

Then I saw your 'recur' used outside of a loop which points the way...

Thanks!

On Friday, 10 January 2014 20:16:28 UTC, puzzler wrote:


 On Fri, Jan 10, 2014 at 11:52 AM, Colin Yates colin...@gmail.comjavascript:
  wrote:
  way to take the wind out of our sails!  Well spotted :).


 It's not too hard to fix.   Here's an adapted version of Jonas' solution 
 that should do the trick:

 (defn uniqueify [items]
   (first
 (reduce (fn [[results count-map] item]
   (let [n (count-map item 0)]
 (if (zero? n)
   [(conj results item) (assoc count-map item (inc n))]
   (recur [results (assoc count-map item (inc n))]
  (str item \_ n)
 [[] {}]
 items)))

 = (uniqueify [a a a a b a_2 a_3 a_3_1 a_3_1 a])
 [a a_1 a_2 a_3 b a_2_1 a_3_1 a_3_1_1 a_3_1_2 a_4]


-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Mark Engelberg
On Fri, Jan 10, 2014 at 12:55 PM, Colin Yates colin.ya...@gmail.com wrote:

 Being really anal I could claim the original a_2 should remain a_2 and the
 third instance of a jump to being a_3.


 Sure, but that would require two passes.  Otherwise, there's no way when
you encounter the third a to know there's an a_2 somewhere later in the
stream.

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Colin Yates
Gosh - my public humiliation continues.  Here is one that actually works:

(first (reduce (fn [[results seen] item]
  (let [cnt (get seen item 0)]
[(conj results (if ( cnt 0) (format-fn item cnt) 
item))
 (assoc seen item (inc cnt))]))
[[] {}]
items))
(fact strings can be made unique
  (s/uniquify [a b c]) = [a b c]
  (s/uniquify [a b a c b b b b a]) = [a b a_1 c 
b_1 b_2 b_3 b_4 a_2])

On Friday, 10 January 2014 20:59:00 UTC, Colin Yates wrote:

 Sorry - wrong c/p:

 (first (reduce (fn [[results seen] item]
   (let [cnt (get seen item 0)
 item (if ( cnt 0) (format-fn item cnt) item)]
 [(conj results item) (assoc seen item (inc cnt))]))
 [[] {}]
 items))

 On Friday, 10 January 2014 20:55:04 UTC, Colin Yates wrote:

 I thought I would have a go myself without copying (although having read 
 them earlier) the other functions and this is what I came up with:

 (first (reduce (fn [[results seen] item]
   (let [occurrences ((fnil identity 0) (get seen 
 item))
 seen (assoc seen item (inc occurrences))
 item (if ( occurrences 0) (format-fn item 
 occurrences) item)]
 [(conj results item) seen])) [[] {}] (seq items)))

 This doesn't solve the problem you mention, but baby steps.

 Being really anal I could claim the original a_2 should remain a_2 and 
 the third instance of a jump to being a_3.  I thought about this and 
 couldn't see how to do this with reduce because I really want to say oh, I 
 have a new name, recurse into the function again with the new proposed 
 name, i.e. loop the generation of the proposed name until it is unique, 
 but I haven't got that far yet (without potentially blowing the stack!)

 Then I saw your 'recur' used outside of a loop which points the way...

 Thanks!

 On Friday, 10 January 2014 20:16:28 UTC, puzzler wrote:


 On Fri, Jan 10, 2014 at 11:52 AM, Colin Yates colin...@gmail.comwrote:
  way to take the wind out of our sails!  Well spotted :).


 It's not too hard to fix.   Here's an adapted version of Jonas' solution 
 that should do the trick:

 (defn uniqueify [items]
   (first
 (reduce (fn [[results count-map] item]
   (let [n (count-map item 0)]
 (if (zero? n)
   [(conj results item) (assoc count-map item (inc n))]
   (recur [results (assoc count-map item (inc n))]
  (str item \_ n)
 [[] {}]
 items)))

 = (uniqueify [a a a a b a_2 a_3 a_3_1 a_3_1 a])
 [a a_1 a_2 a_3 b a_2_1 a_3_1 a_3_1_1 a_3_1_2 a_4]



-- 
-- 
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/groups/opt_out.


ANN: [org.clojure/data.json 0.2.4]

2014-01-10 Thread Stuart Sierra
*data.json: JSON parser and writer*

https://github.com/clojure/data.json

Version 0.2.4

Leiningen dependency info:

[org.clojure/data.json 0.2.4]

Changes in this release:

  * Small change in behavior: `clojure.data.json/pprint` now adds a
newline after its output just like `clojure.core/pprint`

  * Fix [DJSON-13]: flush output after pprint

  * Fix [DJSON-14]: handle EOF inside character escape

  * Fix [DJSON-15]: bad syntax in test


[DJSON-15]: http://dev.clojure.org/jira/browse/DJSON-15
[DJSON-14]: http://dev.clojure.org/jira/browse/DJSON-14
[DJSON-13]: http://dev.clojure.org/jira/browse/DJSON-13

data.json is a clojure-contrib project:
http://dev.clojure.org/display/community/Contributing

-- 
-- 
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/groups/opt_out.


ANN: [org.clojure/java.classpath 0.2.2]

2014-01-10 Thread Stuart Sierra
*java.classpath: examine the Java classpath from Clojure*

https://github.com/clojure/java.classpath

Version 0.2.2

Leiningen dependency info:

[org.clojure/java.classpath 0.2.2]

Changes in this release:

  * Enhancement [CLASSPATH-5]: extensible protocol to other classloaders


[CLASSPATH-5]: http://dev.clojure.org/jira/browse/CLASSPATH-5

java.classpath is a clojure-contrib project:
http://dev.clojure.org/display/community/Contributing

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Laurent PETIT
okay, new take solving the issue raised by Mark:

(defn uniquify [in format-fn]
  (loop [[item :as in] (seq in)
 {n item :as item-nbrs} {}
 out []]
(if-not in
  out
  (let [format-fn (if n format-fn (constantly item))
new-item (format-fn item n)]
(recur (next in)
   (merge-with (fnil + 0)
   item-nbrs
   (hash-map item 1 new-item 1))
   (conj out new-item))

= (uniquify [a b c a a_1 a_1 a] #(str %1 _ %2))
[a b c a_1 a_1_1 a_1_2 a_2]



2014/1/10 Colin Yates colin.ya...@gmail.com

 Gosh - my public humiliation continues.  Here is one that actually works:

 (first (reduce (fn [[results seen] item]
   (let [cnt (get seen item 0)]
 [(conj results (if ( cnt 0) (format-fn item cnt)
 item))
  (assoc seen item (inc cnt))]))
 [[] {}]
 items))
 (fact strings can be made unique
   (s/uniquify [a b c]) = [a b c]
   (s/uniquify [a b a c b b b b a]) = [a b a_1 c
 b_1 b_2 b_3 b_4 a_2])

 On Friday, 10 January 2014 20:59:00 UTC, Colin Yates wrote:

 Sorry - wrong c/p:

 (first (reduce (fn [[results seen] item]
   (let [cnt (get seen item 0)
 item (if ( cnt 0) (format-fn item cnt) item)]
 [(conj results item) (assoc seen item (inc
 cnt))]))
 [[] {}]
 items))

 On Friday, 10 January 2014 20:55:04 UTC, Colin Yates wrote:

 I thought I would have a go myself without copying (although having read
 them earlier) the other functions and this is what I came up with:

 (first (reduce (fn [[results seen] item]
   (let [occurrences ((fnil identity 0) (get seen
 item))
 seen (assoc seen item (inc occurrences))
 item (if ( occurrences 0) (format-fn item
 occurrences) item)]
 [(conj results item) seen])) [[] {}] (seq
 items)))

 This doesn't solve the problem you mention, but baby steps.

 Being really anal I could claim the original a_2 should remain a_2 and
 the third instance of a jump to being a_3.  I thought about this and
 couldn't see how to do this with reduce because I really want to say oh, I
 have a new name, recurse into the function again with the new proposed
 name, i.e. loop the generation of the proposed name until it is unique,
 but I haven't got that far yet (without potentially blowing the stack!)

 Then I saw your 'recur' used outside of a loop which points the way...

 Thanks!

 On Friday, 10 January 2014 20:16:28 UTC, puzzler wrote:


 On Fri, Jan 10, 2014 at 11:52 AM, Colin Yates colin...@gmail.comwrote:
  way to take the wind out of our sails!  Well spotted :).


 It's not too hard to fix.   Here's an adapted version of Jonas'
 solution that should do the trick:

 (defn uniqueify [items]
   (first
 (reduce (fn [[results count-map] item]
   (let [n (count-map item 0)]
 (if (zero? n)
   [(conj results item) (assoc count-map item (inc n))]
   (recur [results (assoc count-map item (inc n))]
  (str item \_ n)
 [[] {}]
 items)))

 = (uniqueify [a a a a b a_2 a_3 a_3_1 a_3_1 a])
 [a a_1 a_2 a_3 b a_2_1 a_3_1 a_3_1_1 a_3_1_2 a_4]

  --
 --
 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/groups/opt_out.


-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Mark Engelberg
Laurent, your approach doesn't quite work:
= (uniquify [a_1 a a] (fn [s n] (str s \_ n)))
[a_1 a a_1]



On Fri, Jan 10, 2014 at 1:34 PM, Laurent PETIT laurent.pe...@gmail.comwrote:

 okay, new take solving the issue raised by Mark:

 (defn uniquify [in format-fn]
   (loop [[item :as in] (seq in)
  {n item :as item-nbrs} {}
  out []]
 (if-not in
   out
   (let [format-fn (if n format-fn (constantly item))
 new-item (format-fn item n)]
 (recur (next in)
(merge-with (fnil + 0)
item-nbrs
(hash-map item 1 new-item 1))
(conj out new-item))

 = (uniquify [a b c a a_1 a_1 a] #(str %1 _ %2))
 [a b c a_1 a_1_1 a_1_2 a_2]



 2014/1/10 Colin Yates colin.ya...@gmail.com

 Gosh - my public humiliation continues.  Here is one that actually works:

 (first (reduce (fn [[results seen] item]
   (let [cnt (get seen item 0)]
 [(conj results (if ( cnt 0) (format-fn item cnt)
 item))
  (assoc seen item (inc cnt))]))
 [[] {}]
 items))
 (fact strings can be made unique
   (s/uniquify [a b c]) = [a b c]
   (s/uniquify [a b a c b b b b a]) = [a b a_1
 c b_1 b_2 b_3 b_4 a_2])

 On Friday, 10 January 2014 20:59:00 UTC, Colin Yates wrote:

 Sorry - wrong c/p:

 (first (reduce (fn [[results seen] item]
   (let [cnt (get seen item 0)
 item (if ( cnt 0) (format-fn item cnt)
 item)]
 [(conj results item) (assoc seen item (inc
 cnt))]))
 [[] {}]
 items))

 On Friday, 10 January 2014 20:55:04 UTC, Colin Yates wrote:

 I thought I would have a go myself without copying (although having
 read them earlier) the other functions and this is what I came up with:

 (first (reduce (fn [[results seen] item]
   (let [occurrences ((fnil identity 0) (get seen
 item))
 seen (assoc seen item (inc occurrences))
 item (if ( occurrences 0) (format-fn item
 occurrences) item)]
 [(conj results item) seen])) [[] {}] (seq
 items)))

 This doesn't solve the problem you mention, but baby steps.

 Being really anal I could claim the original a_2 should remain a_2 and
 the third instance of a jump to being a_3.  I thought about this and
 couldn't see how to do this with reduce because I really want to say oh, I
 have a new name, recurse into the function again with the new proposed
 name, i.e. loop the generation of the proposed name until it is unique,
 but I haven't got that far yet (without potentially blowing the stack!)

 Then I saw your 'recur' used outside of a loop which points the way...

 Thanks!

 On Friday, 10 January 2014 20:16:28 UTC, puzzler wrote:


 On Fri, Jan 10, 2014 at 11:52 AM, Colin Yates colin...@gmail.comwrote:
  way to take the wind out of our sails!  Well spotted :).


 It's not too hard to fix.   Here's an adapted version of Jonas'
 solution that should do the trick:

 (defn uniqueify [items]
   (first
 (reduce (fn [[results count-map] item]
   (let [n (count-map item 0)]
 (if (zero? n)
   [(conj results item) (assoc count-map item (inc n))]
   (recur [results (assoc count-map item (inc n))]
  (str item \_ n)
 [[] {}]
 items)))

 = (uniqueify [a a a a b a_2 a_3 a_3_1 a_3_1 a])
 [a a_1 a_2 a_3 b a_2_1 a_3_1 a_3_1_1 a_3_1_2 a_4]

  --
 --
 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/groups/opt_out.


  --
 --
 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 

Re: Nginx-Clojure Let You Deploy Clojure Web App on Nginx Without Any Java Web Server

2014-01-10 Thread Xfeep Zhang
Thank you! I think it's useful.


I have done some simple tests. But I think general performance test may be 
meaningless regardless of real world requirements.

os : ubuntu 13.10 64bit
memory: 16G
cpu: intel i7 4700MQ (4 cores 2.4GHz)


1. static file test

file: 29.7k (real contents from https://groups.drupal.org/node/167984)
ring handler :

(def test-handler [req] 
 {:status 200 
:headers {content-type text/html}
:body (java.io.File. resources/index.html) })


warmed by ab -n  40 -c 1 http://localhost:${port}/;


test command:

ab -n  10 -c 1 http://localhost:${port}/


(1) nginx-clojure-0.1.0 

===

Document Path:  /
Document Length:29686 bytes

Concurrency Level:  1
Time taken for tests:   3.464 seconds
Complete requests:  10
Failed requests:0
Write errors:   0
Total transferred:  299120 bytes
HTML transferred:   296860 bytes
Requests per second:28867.39 [#/sec] (mean)
Time per request:   346.412 [ms] (mean)
Time per request:   0.035 [ms] (mean, across all concurrent requests)
Transfer rate:  843243.63 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:   18  113 208.6 743082
Processing:82  219  51.6225 748
Waiting:   13   78  37.6 70 604
Total:102  332 216.93103190

Percentage of the requests served within a certain time (ms)
  50%310
  66%329
  75%337
  80%341
  90%348
  95%423
  98%   1295
  99%   1309
 100%   3190 (longest request)


(2) http-kit 2.1.16
===

Document Path:  /
Document Length:29686 bytes

Concurrency Level:  1
Time taken for tests:   4.104 seconds
Complete requests:  10
Failed requests:0
Write errors:   0
Total transferred:  298080 bytes
HTML transferred:   296860 bytes
Requests per second:24363.92 [#/sec] (mean)
Time per request:   410.443 [ms] (mean)
Time per request:   0.041 [ms] (mean, across all concurrent requests)
Transfer rate:  709218.63 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:   49  130 229.3 983062
Processing:   124  269  38.6267 603
Waiting:   39   87  24.0 88 353
Total:243  398 233.73693665

Percentage of the requests served within a certain time (ms)
  50%369
  66%379
  75%387
  80%395
  90%415
  95%443
  98%   1310
  99%   1396
 100%   3665 (longest request)


(3) ring-jetty
===

Document Path:  /
Document Length:29686 bytes

Concurrency Level:  10
Time taken for tests:   4.991 seconds
Complete requests:  10
Failed requests:0
Write errors:   0
Total transferred:  298220 bytes
HTML transferred:   296860 bytes
Requests per second:20037.89 [#/sec] (mean)
Time per request:   0.499 [ms] (mean)
Time per request:   0.050 [ms] (mean, across all concurrent requests)
Transfer rate:  583564.46 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.0  0   1
Processing: 00   0.8  0  75
Waiting:00   0.8  0  75
Total:  00   0.8  0  75

Percentage of the requests served within a certain time (ms)
  50%  0
  66%  1
  75%  1
  80%  1
  90%  1
  95%  1
  98%  1
  99%  1
 100% 75 (longest request)



2. simple string

warmed by ab -n  40 -c 1  http://localhost:${port}/;

ring handler :

(def test-handler [req] 
 {:status 200 
:headers {content-type text/html}
:body Hello, Clojure! })


test command:

ab -n  10 -c 1  http://localhost:${port}/


(1) nginx-clojure-0.1.0 
==
Document Path:  /
Document Length:15 bytes

Concurrency Level:  10
Time taken for tests:   1.952 seconds
Complete requests:  10
Failed requests:0
Write errors:   0
Total transferred:  1700 bytes
HTML transferred:   150 bytes
Requests per second:51241.03 [#/sec] (mean)
Time per request:   0.195 [ms] (mean)
Time per request:   0.020 [ms] (mean, across all concurrent requests)
Transfer rate:  8506.81 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.0  0   1
Processing: 00   0.1  0   3
Waiting:00   0.1  0   3
Total:  00   0.1  0   4

Percentage of the requests served within a certain time (ms)
  50%  0
  66%  0
  75%  0
  80%  0
  90%  0
  

Re: How can I improve this?

2014-01-10 Thread Laurent PETIT
Indeed, I should definitely recur as you do

Le vendredi 10 janvier 2014, Mark Engelberg a écrit :

 Laurent, your approach doesn't quite work:
 = (uniquify [a_1 a a] (fn [s n] (str s \_ n)))
 [a_1 a a_1]



 On Fri, Jan 10, 2014 at 1:34 PM, Laurent PETIT laurent.pe...@gmail.comwrote:

 okay, new take solving the issue raised by Mark:

 (defn uniquify [in format-fn]
   (loop [[item :as in] (seq in)
  {n item :as item-nbrs} {}
  out []]
 (if-not in
   out
   (let [format-fn (if n format-fn (constantly item))
 new-item (format-fn item n)]
 (recur (next in)
(merge-with (fnil + 0)
item-nbrs
(hash-map item 1 new-item 1))
(conj out new-item))

 = (uniquify [a b c a a_1 a_1 a] #(str %1 _ %2))
 [a b c a_1 a_1_1 a_1_2 a_2]



 2014/1/10 Colin Yates colin.ya...@gmail.com

 Gosh - my public humiliation continues.  Here is one that actually works:

 (first (reduce (fn [[results seen] item]
   (let [cnt (get seen item 0)]
 [(conj results (if ( cnt 0) (format-fn item cnt)
 item))
  (assoc seen item (inc cnt))]))
 [[] {}]
 items))
 (fact strings can be made unique
   (s/uniquify [a b c]) = [a b c]
   (s/uniquify [a b a c b b b b a]) = [a b a_1 c
 b_1 b_2 b_3 b_4 a_2])

 On Friday, 10 January 2014 20:59:00 UTC, Colin Yates wrote:

 Sorry - wrong c/p:

 (first (reduce (fn [[results seen] item]
   (let [cnt (get seen item 0)
 item (if ( cnt 0) (format-fn item cnt) item)]
 [(conj results item) (assoc seen item (inc cnt))]))
 [[] {}]
 items))

 On Friday, 10 January 2014 20:55:04 UTC, Colin Yates wrote:

 I thought I would have a go myself without copying (although having read
 them earlier) the other functions and this is what I came up with:

 (first (reduce (fn [[results seen] item]
   (let [occurrences ((fnil identity 0) (get seen item))
 seen (assoc seen item (inc occurrences))
 item (if ( occurrences 0) (format-fn item
 occurrences) item)]
 [(conj results item) seen])) [[] {}] (seq items)))

 This doesn't solve the problem you mention, but baby steps.

 Being really anal I could claim the original a_2 should remain a_2 and the
 third instance of a jump to being a_3.  I thought about this and couldn't
 see how to do this with reduce because I really want to say oh, I have a
 new name, recurse into the function again with the new proposed name, i.e.
 loop the generation of the proposed name until it is unique, but I haven't
 got that far yet (without potentially blowing the stack!)

 Then I saw your 'recur' used outside of a loop which points the way...

 Thanks!

 On Friday, 10 January 2014 20:16:28 UTC, puzzler wrote:


 On Fri, Jan 10, 2014 at 11:52 AM, Colin Yates colin...@gmail.com wrote:
  way to take the wind out of our sails!  W



-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Ralf Schmitt
Colin Yates colin.ya...@gmail.com writes:

 This and Jonas' are my current favourites, for what that's worth.

 Keep the suggestions coming! 

here's another one that uses reductions. formatter would need to be
adapted a bit, since it currently also adds _0 for the first name
seen:


(defn count-name
  [name-count name]
  (assoc name-count name (inc (get name-count name 0

(defn uniquify
  ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
  ([s formatter]
 (map (fn [name name-count]
(formatter name (get name-count name 0)))
  s
  (reductions count-name {} s

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Sean Corfield
I meant the code that starts at line 257 (and continues to line 274): two 
functions, the second one calls the first one.

Luckily, java.jdbc's code seems to pass all the test cases posted to this 
thread so far (arguably more intuitively, the second occurrence gets _2 
appended, the third _3 etc):

https://www.dropbox.com/s/sxccqvy9qgipzo8/Screenshot%202014-01-10%2016.18.55.png

Sean

On Jan 10, 2014, at 11:16 AM, Guru Devanla grd...@gmail.com wrote:

 Actually, you might have meant line 267?
 
 
 On Fri, Jan 10, 2014 at 11:03 AM, Sean Corfield s...@corfield.org wrote:
 java.jdbc does this for column names (in joins):
 
 https://github.com/clojure/java.jdbc/blob/master/src/main/clojure/clojure/java/jdbc.clj#L257
 
 Sean




signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: Good learning resources for Clojure novice but with a long background i programming, both OO and some Fp?

2014-01-10 Thread Sean Corfield
On Jan 10, 2014, at 11:26 AM, Guru Devanla grd...@gmail.com wrote:
 Another good book I thought you could get through faster in 'Pragmatic 
 Clojure'.I found this book to be the next level to Clojure Programming.

Do you mean Programming Clojure (2nd Ed) by Stuart Halloway?

http://pragprog.com/book/shcloj2/programming-clojure

Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/

Perfection is the enemy of the good.
-- Gustave Flaubert, French realist novelist (1821-1880)





signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: How can I improve this?

2014-01-10 Thread Alan Forrester
On 10 January 2014 21:06, Colin Yates colin.ya...@gmail.com wrote:
 Gosh - my public humiliation continues.  Here is one that actually works:

 (first (reduce (fn [[results seen] item]
   (let [cnt (get seen item 0)]
 [(conj results (if ( cnt 0) (format-fn item cnt)
 item))
  (assoc seen item (inc cnt))]))
 [[] {}]
 items))
 (fact strings can be made unique
   (s/uniquify [a b c]) = [a b c]
   (s/uniquify [a b a c b b b b a]) = [a b a_1 c
 b_1 b_2 b_3 b_4 a_2])

My first two suggestions produce unique titles. They don't do what you
want but they are brief:
(defn uniquify [a] (map #(str (gensym %)) a))
(defn uniquify [a] (map-indexed (fn [ind el] (str el _ ind)) a))

My last suggestion does what you want
(defn uniquify [a]
  (loop [res [(first a)] leftover (rest a)]
(if-not (empty? leftover)
  (let [freqy (frequencies res)
fl (first leftover)
ffl (freqy fl)]
(if ffl
  (recur (concat res [(str fl _ ffl)]) (rest leftover))
  (recur (concat res [fl]) (rest leftover
  res)))

Alan

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Alan Forrester
On 11 January 2014 01:03, Alan Forrester
alanmichaelforres...@googlemail.com wrote:
 On 10 January 2014 21:06, Colin Yates colin.ya...@gmail.com wrote:
 Gosh - my public humiliation continues.  Here is one that actually works:

 (first (reduce (fn [[results seen] item]
   (let [cnt (get seen item 0)]
 [(conj results (if ( cnt 0) (format-fn item cnt)
 item))
  (assoc seen item (inc cnt))]))
 [[] {}]
 items))
 (fact strings can be made unique
   (s/uniquify [a b c]) = [a b c]
   (s/uniquify [a b a c b b b b a]) = [a b a_1 c
 b_1 b_2 b_3 b_4 a_2])

 My first two suggestions produce unique titles. They don't do what you
 want but they are brief:
 (defn uniquify [a] (map #(str (gensym %)) a))
 (defn uniquify [a] (map-indexed (fn [ind el] (str el _ ind)) a))

 My last suggestion does what you want
 (defn uniquify [a]
   (loop [res [(first a)] leftover (rest a)]
 (if-not (empty? leftover)
   (let [freqy (frequencies res)
 fl (first leftover)
 ffl (freqy fl)]
 (if ffl
   (recur (concat res [(str fl _ ffl)]) (rest leftover))
   (recur (concat res [fl]) (rest leftover
   res)))

Actually, it doesn't work.

Alan

-- 
-- 
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/groups/opt_out.


Re: [ANN]: Clojure/West 2014 - San Francisco - March 24-26

2014-01-10 Thread Logan Linn
This was great news to hear. Looking forward to it.

Talks will be presented in two tracks


Does this mean there will be two stages/presentations at a time?

On Thursday, January 9, 2014 8:01:13 PM UTC-8, Alex Miller wrote:

 At long last, we have finalized the plans for Clojure/West 2014!  

 Site: http://clojurewest.org
 Date: March 24-25 conference, March 26 hackfest!
 Venue: Palace Hotel, San Francisco 
 http://www.sfpalace.com/
 https://goo.gl/maps/pBXav

 Call for Presentations:
 - 
 https://cognitect.wufoo.com/forms/clojurewest-2014-call-for-presentations/
 - Open from now till Jan 24th (yes, that's soon!)
 - Speakers receive: free admission, up to 3 nights hotel, US airfare or 
 $450 stipend if international
 - Tracks (sessions are 40 minutes): 
 1) Core Clojure - Talks that focus on core usage of Clojure or 
 ClojureScript, focused mostly (but not exclusively) on the less experienced 
 Clojure developer. Examples: language features, techniques, libraries, 
 tools.
 2) Production Clojure - Talks from and for those doing Clojure or 
 ClojureScript in production systems or products. Examples: integrating with 
 existing code bases, creating and communicating designs, structuring your 
 code, performance, management and organization.
 3) Crazy Clojure - Talks from those probing the boundaries of Clojure or 
 bringing Clojure into amazing new areas. Examples: music, art, alternate 
 hosts, space stations, donuts, etc.

 Talks will be presented in two tracks on March 24-25th. On the 26th, we 
 will have space available for people to get together and do what we all 
 love: write some Clojure! More info to come.

 We expect early bird registration and the sponsorship prospectus to be 
 available soon.

 Please let us know if you have any questions!

 Alex Miller and Lynn Grogan
 Questions: clojur...@cognitect.com javascript:






-- 
-- 
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/groups/opt_out.


[ANN] tools.analyzer(.jvm) 0.1.0-alpha1

2014-01-10 Thread Nicola Mometto

Today I released the first version of the tools.analyzer[1] and
tools.analyzer.jvm[2] contrib libraries, here are the leiningen coordinates:

[org.clojure/tools.analyzer 0.1.0-alpha1]
[org.clojure/tools.analyzer.jvm 0.1.0-alpha1]

Right now the only documentation for both those libraries is in the form
of docstrings and can be found at
http://clojure.github.io/tools.analyzer/ and
http://clojure.github.io/tools.analyzer.jvm/ more extended documentation
will be available before the first non-alpha release, hopefully very soon.

While this is an alpha release, during the last months a big amount of
bugs have been fixed thanks to the work of Andy Fingerhut who moved the
Eastwood[3] linter from Ambrose's analyzer to tools.analyzer.jvm; thanks
to this, the analyzer has been run with success on a large number of
popular clojure libraries including almost all clojure contrib libraries
and clojure's own namespaces, thus proving that it's effectively working.

Please, try it out and if you find any bug report them in the Bug
Tracker[4] (tools.analyzer and tools.analyzer.jvm share the same JIRA
project) or if you have any questions, feel free to ask them and I'll do
my best to answer them.

Thanks,
Nicola


[1] https://github.com/clojure/tools.analyzer
[2] https://github.com/clojure/tools.analyzer.jvm
[3] https://github.com/jonase/eastwood
[4] http://dev.clojure.org/jira/browse/TANAL

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Alan Forrester
On 11 January 2014 01:14, Alan Forrester
alanmichaelforres...@googlemail.com wrote:
 On 11 January 2014 01:03, Alan Forrester
 alanmichaelforres...@googlemail.com wrote:
 On 10 January 2014 21:06, Colin Yates colin.ya...@gmail.com wrote:
 Gosh - my public humiliation continues.  Here is one that actually works:

 (first (reduce (fn [[results seen] item]
   (let [cnt (get seen item 0)]
 [(conj results (if ( cnt 0) (format-fn item cnt)
 item))
  (assoc seen item (inc cnt))]))
 [[] {}]
 items))
 (fact strings can be made unique
   (s/uniquify [a b c]) = [a b c]
   (s/uniquify [a b a c b b b b a]) = [a b a_1 c
 b_1 b_2 b_3 b_4 a_2])

 My first two suggestions produce unique titles. They don't do what you
 want but they are brief:
 (defn uniquify [a] (map #(str (gensym %)) a))
 (defn uniquify [a] (map-indexed (fn [ind el] (str el _ ind)) a))

 My last suggestion does what you want
 (defn uniquify [a]
   (loop [res [(first a)] leftover (rest a)]
 (if-not (empty? leftover)
   (let [freqy (frequencies res)
 fl (first leftover)
 ffl (freqy fl)]
 (if ffl
   (recur (concat res [(str fl _ ffl)]) (rest leftover))
   (recur (concat res [fl]) (rest leftover
   res)))

 Actually, it doesn't work.

This version works:

(defn uniquify [a]
  (loop [res [(first a)] intermed [(first a)] leftover (rest a)]
(if-not (empty? leftover)
  (let [freqy (frequencies intermed)
fl (first leftover)
ffl (freqy fl)]
(if ffl
  (recur (concat res [(str fl _ ffl)]) (concat intermed
[fl]) (rest leftover))
  (recur (concat res [fl])  (concat intermed [fl]) (rest leftover
  res)))

Alan

-- 
-- 
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/groups/opt_out.


how to check if something is a channel ?

2014-01-10 Thread t x
Hi,

  In clojure/cljs, what is the simplest way to check if a given object is a
async/chan ?

Thanks!

-- 
-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are 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/groups/opt_out.


cljs: determining if an object is a string, a async/chan, or an atom ?

2014-01-10 Thread t x
Consider this snipplet of code:

  (. js/console log (type (str abc)))
  (. js/console log (type (atom nil)))
  (. js/console log (type (cljs.core/async 100)))


it outputs for me:

function String() { [native code] } app.cljs:13
function (state,meta,validator,watches){ this.state = state; this.meta =
meta; this.validator = validator; this.watches = watches;
this.cljs$lang$protocol_mask$partition0$ = 2153938944;
this.cljs$lang$protocol_mask$partition1$ = 2; }

This, unfortunately, is not very useful. Thus, my question:

in javascript, is there a way to get the type of an object? (the Java ones
are a bit more useful, returning things like:

clojure.core.async.impl.channels.ManyToManyChannel
and java.lang.String

Question:

How do I extract a readable/comparable type from cljs objects?

-- 
-- 
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/groups/opt_out.


Re: How can I improve this?

2014-01-10 Thread Håkan Råberg
Another style, using channels for local state, but could been plain old 
iterators, slight golf warning:

(require '[clojure.core.async :refer [to-chan !!]])

(defn uniquify [s formatter]
  (let [g (memoize #(to-chan (cons % (map (partial formatter %) (next 
(range))]
(map (fn f [x] ((some-fn #{x} f) (!! (g x s)))

(uniquify [a a a a b a_2 a_3 a_3_1 a_3_1 a] #(str %1 
_ %2))
;= [a a_1 a_2 a_3 b a_2_1 a_3_1 a_3_1_1 a_3_1_2 a_4]


On Friday, 10 January 2014 14:59:10 UTC, Colin Yates wrote:

 I have a sequence of file names and I want to make them unique.  (uniquify 
 [a b c a]) = [a b c a_1])

 This is what I have come up with, but surely there is a better way?

 What would you all do?  Feedback welcome (including the word 'muppet' as I 
 am sure I have missed something simple) :)

 (defn uniquify
   Return a sequence, in the same order as s containing every element
   of s. If s (which is presumed to be a string) occurs more than once
   then every subsequent occurrence will be made unique.

   Items will be updated to include an incrementing numeric count using
   the specified formatter function. The formatter function will be
   given the name and the number and should return a combination of the
   two.

   The set of unique s's in the returned sequence will be the count of
   s's in s.  
   ([s] (uniquify s (fn [item duplicates] (str item _ duplicates
   ([s formatter]
  (let [occurrences (atom {})
register-occurrence (fn [item]
  (if (get @occurrences item)
(swap! (get @occurrences item) inc)
(swap! occurrences assoc item (atom 1)))
  @(get @occurrences item))
process (fn [item]
  (let [duplicates (dec (register-occurrence item))]
(if ( duplicates 0)
  (formatter item duplicates)
  item)))
unique-s (map process s)]
unique-s)))


-- 
-- 
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/groups/opt_out.


Re: cljs: determining if an object is a string, a async/chan, or an atom ?

2014-01-10 Thread David Nolen
Try println, prn, pr-str. The only sensible thing is to compare
constructors.

On Friday, January 10, 2014, t x wrote:

 Consider this snipplet of code:

   (. js/console log (type (str abc)))
   (. js/console log (type (atom nil)))
   (. js/console log (type (cljs.core/async 100)))


 it outputs for me:

 function String() { [native code] } app.cljs:13
 function (state,meta,validator,watches){ this.state = state; this.meta =
 meta; this.validator = validator; this.watches = watches;
 this.cljs$lang$protocol_mask$partition0$ = 2153938944;
 this.cljs$lang$protocol_mask$partition1$ = 2; }

 This, unfortunately, is not very useful. Thus, my question:

 in javascript, is there a way to get the type of an object? (the Java ones
 are a bit more useful, returning things like:

 clojure.core.async.impl.channels.ManyToManyChannel
 and java.lang.String

 Question:

 How do I extract a readable/comparable type from cljs objects?

 --
 --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to 
 clojure@googlegroups.comjavascript:_e({}, 'cvml', 
 '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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@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 javascript:_e({}, 'cvml',
 'clojure%2bunsubscr...@googlegroups.com');.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
-- 
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/groups/opt_out.


[ANN] Eastwood 0.1.0 Clojure lint tool

2014-01-10 Thread Andy Fingerhut
Eastwood is a Clojure lint tool.  It analyzes Clojure source code in
Leiningen projects, reporting things that may be errors.

Installation instructions are in the documentation here:

https://github.com/jonase/eastwood

For example, did you know that if you use clojure.test to write tests, and
have multiple deftest definitions in the same namespace with the same name,
then the tests in all but the last deftest will never be run, whether those
tests would pass or fail?  Eastwood can find those duplicate names, as well
as other occurrences of the same Var name defined more than once.

Eastwood can also warn about misplaced doc strings, calling deprecated
functions or Java methods, expressions that are suspicious because they
always return the same value (e.g. (= expr) is always true), expressions
whose return value is not used and appear to have no side effects, and a
few others.  See the documentation linked above for a complete list.

Jonas Enlund wrote the original version of Eastwood with the help of
several other contributors.  Version 0.1.0 is an update by Jonas, Nicola
Mometto, and myself.  It uses the new Clojure contrib libraries
tools.reader for reading the code, and tools.analyzer and
tools.analyzer.jvm for parsing the source into abstract syntax trees,
making it straightforward to write many of the linters.  Thanks especially
to Nicola Mometto for tireless enhancements and bug fixes to those
libraries.

You can file issues on the Github issue tracker if you encounter problems,
but please read the Known Issues section of the documentation before
filing problems.  Several issues have already been discovered, and their
causes documented, while testing Eastwood on most of the Clojure contrib
libraries, Clojure itself, and over 35 other open source libraries.

Go squash some bugs!

Andy Fingerhut

-- 
-- 
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/groups/opt_out.