unknown recursion

2014-10-04 Thread emptya45
Hi,

I am trying to write a function to return a boolean as to whether 
parenthesis are balanced or not? 

(defn bal-parens? [parens]
  (let [replaced (clojure.string/replace parens "()" "")
checked (re-seq #"\(\)" replaced)]
   (println checked)
  (if-not (nil? checked) (bal-parens? replaced))
   (println (str "replaced is " replaced))
   (if (empty? replaced) true false)))

(bal-parens? "(()())")

I'd expect to see true here.

But my output is:

(())   
   
nil 
  
replaced is
replaced is () 


false

I can't for the life of me think why, that when checked is nil and replaced 
is empty the function doesn't terminate!

Many Thanks

Aidy

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


count occurrences of a char in a string or a collection

2014-10-03 Thread emptya45
Hi, 

Is there a higher-order function(s) that count occurrences of characters in 
either a string or a collection?

Thanks

Paul

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


destructure command line arguments

2014-07-25 Thread emptya45
Hi, 

I have a main function:

(defn -main [& args]
  (let [{:keys [graph filepath title]} args]
(cond 
 (= graph "response") (graph-response filepath title)
 (= graph "requests") (graph-request filepath)
 (= graph "throughput") (graph-throughput filepath

Which I can invoke with this call:

(-main :graph "throughput" :filepath "./aggregate-report.csv")

However, when I create an uberjar and do this:

java -jar jmeter-graphs-0.1.0-standalone.jar :graph "throughput" :filepath 
"./aggregate-report.csv"

There arguments are not destructured. Is it possible to use key value pairs 
through the command line?

Many Thanks

Aidy

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


create vectors for each key/value pair

2014-07-22 Thread emptya45
Hi, 

I have an unsorted map:

(def my-map 
{1405961887 20, 
 1405960895 20, 
 1405961919 20, 
 1405960927 20, 
 1405960959 21,
 1405960991 20, 
 1405961023 20, 
 1405961055 18,
 1405961087 23, 
 1405961119 17, 
 1405961151 23, 
 1405961183 19,
 1405961215 20}

I'd like to be able to sort the map by key and then place each value pair 
into a vector. 

An attempt at (sorted-map my-map) returns 'No value supplied for key: 
{1405961887 20 ' }

When I attempt to create a vector from the key/pairs 

(map #(vector %) my-map)

I receive each key/value in a vector within a vector

([[1405961887 20]]
 [[1405960895 20]]
 [[1405961919 20]]
 [[1405960927 20]]
 [[1405960959 21]]
 [[1405960991 20]]
 [[1405961023 20]]
 [[1405961055 18]]
 [[1405961087 23]]
 [[1405961119 17]]
 [[1405961151 23]]
 [[1405961183 19]]
 [[1405961215 20]])

My goal is to create a collection of vectors to place in an Incanter 
dataset:

incanter/dataset ["time" "requests"]
   [[1405961887 20]
[1405960895 20]
[[1405961919 20]])

Many Thanks

Adrian





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


reload dependencies

2014-07-21 Thread emptya45
Hi, 

Is there a better way to reload dependencies in Cider than by shutting down 
the nrepl and running 'lein deps'?

Many Thanks

Aidy

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


Calculating the number of timestamps logged within a specific time period

2014-07-17 Thread emptya45
Hi, 

I have a list of epoch times which map to HTTP requests. 

'(1405060202611
1405060201157
1405060201361
1405060201261
1405060200391
1405060201458
1405060201705
1405060201058
1405060205062
1405060201558
1405060201761
)

I am trying to find out how many HTTP requests I have in a specified time 
period, so I can graph requests per second.

I was thinking of using reverse and subtracting the first from the list 
from the second and recurring, which would give me the time period between 
every two requests - which is a start.

Any help appreciated here. 

Many Thanks

Aidy

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


Measure HTTP response times

2014-05-06 Thread emptya45
Hi,

I am developing a primitive web load test tool using a HTTP client and STM. 

I wondered if there was a Clojure library I could use that would give me 
individual HTTP response times?

Many Thanks

Paul


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


split maps contained in a file

2014-03-27 Thread emptya45
Hi, 

I have a Clojure file that contains two maps.

{:a 1 :b 2}
{:c 3 :d 4} 

I would like to read both maps as Clojure data structures, but if I:

(read-string (slurp maps.clj)) 

Only the first map is returned. 

I would like to read the file and split or partition the maps and hold onto 
them as two separate map data structures. 

Many Thanks

Mr Empty

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