Re: (eval `(def ~(symbol varname) lineseq)

2014-04-08 Thread Peter West
Carlo,

See below.

On Tuesday, 8 April 2014 12:20:16 UTC+10, Carlo wrote:

 On Mon, Apr 07, 2014 at 04:08:03AM -0700, Peter West wrote: 
  I'm trying to understand the difference between two alternatives in the 
  following code that reads from a resource file. 
  
  (defn vcf-res-reader 
[res] 
(- res 
 io/resource 
 io/reader)) 
  
  (defn lines-only 
[varname prom resource] 
(with-open [r (vcf-res-reader resource) 
; alternative 1 
;lineseq (line-seq r) 
] 
  ; alternative 2 
  (def lineseq (line-seq r)) 
  (eval `(def ~(symbol varname) lineseq)) 
  @prom)) 
  
  (defn lazy-lines 
[varname prom resource] 
(future 
  (lines-only varname prom resource) 
  )) 
  
  
  As the code stands, with alternative 2 enabled, the eval setting a named 
  var to the value of linseq works as intended. However, if I disable 
  alternative 2 and enable alternative 1, and I attempt to access the 
 named 
  var (cards in this case), I get 
  #Unbound Unbound: #'vcf.core/cards 

 You have a few problems with your code as it stands. I'll look at each 
 of the two alternatives separately. 

 First, alternative 1: 

  (defn lines-only 
[varname prom resource] 
(with-open [r (vcf-res-reader resource) 
lineseq (line-seq r)] 
  (eval `(def ~(symbol varname) lineseq)) 
  @prom)) 

 Your issue here is that the symbol lineseq in the eval form doesn't 
 have a name to refer to. You do have a local binding for lineseq, but 
 it's not visible to the eval: 

   (let [x 10] (eval 'x)) ;= Unable to resolve symbol: x 

 The lineseq binding should really be made in a let, too, rather than a 
 with-open. The result of a line-seq can't be closed, so it's not really 
 sensible to put it in a with-open. 


If that were the case, then the reference to r in alternative 2 (def 
lineseq (line-seq r)) would not work; but it does, so r is in scope. 
Therefore, linseed from alternative 1 must also be in scope, mustn't it? 
 It was my understanding that the scope of with-open was equivalent to that 
of let in  that bindings were visible within the entire scope of the 
with-open.


 Now, on to alternative 2: 

  (defn lines-only 
[varname prom resource] 
(with-open [r (vcf-res-reader resource)} 
  (def lineseq (line-seq r)) 
  (eval `(def ~(symbol varname) lineseq)) 
  @prom)) 

 This time, you do have something for lineseq to refer to! The def 
 special form has created a global binding for lineseq. Now, at the top 
 level of your application you can lookup lineseq and get a value, but 
 this isn't good, because your function now modifies the global scope, 
 just to hold a temporary value. 


I agree entirely.  That's why i was trying to keep the lineseq var local 
to the with-open. I still don't know what's happening there. Unfortunately, 
I have another global (within the current namespace, at least) at the 
moment, and that is the named variable. The only other way I have seen to 
secrete the line-seq out without prematurely terminating it, is to define a 
read function within the body of the with-open, but that's even nastier, 
and it has timing problems.





 There are two ways for you to resolve this. What you're writing sounds a 
 little bit like it should be a macro, so you could write it as such: 

   (defmacro lines-only [varname prom resource] 
 `(with-open [r# (vcf-res-reader ~resource)] 
(let [lineseq# (line-seq r#)] 
  (def ~(symbol varname) lineseq#) 
  @~prom))) 

 (I think that's right, but I've not actually tested it.) 


I think this will run into the same problem, for reasons mentioned above. 


 Alternatively, you could write it as a function and use intern: 

   (defn lines-only [varname prom resource] 
 (with-open [r (vcf-res-reader resource)] 
   (let [lineseq (line-seq r)] 
 (intern *ns* (symbol varname) lineseq) 
 @prom))) 

 I'm less confident about this approach, but it should work. 

 All this being said: it's generally a bad idea to have a macro/function 
 modify the global scope without it being very clear that it's doing so. 
 I usually try to have my macro names start with def if they're 
 modifying the global scope (because they're defining something is my 
 logic). 


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

Re: Lazy sequence - how they work internally

2014-04-08 Thread sorin cristea
Hi James,

  I'm new to clojure and maybe for this reason it's possible to put some 
'stupid' questions,  I came for Java so for me it's normal when I call a 
fc/method to execute the body of that fc/method and return a result; this 
is the reason for why I expect a result when I call (test-fc (range 
210432423543654675765876879)), I'm totally agree with you that this will 
take a long time to complete. I try to understand exactly how work 
internally lazy seq and for that I start to wrote this function to know how 
recursive call of function from inside of his body is replaced with plain 
recursion and in this way is avoided Stackoverflow ex..  

It's something wrong on my logic ?
Thanks
Sorin
 

On Monday, April 7, 2014 11:13:51 PM UTC+3, James Reeves wrote:

 Why do you expect (test-fc (range 210432423543654675765876879)) to return 
 a result?

 Even if each iteration of the loop takes only 1 nanosecond, your function 
 would take 6 billion years to complete.

 - James


 On 7 April 2014 21:01, sorin cristea srncr...@gmail.com javascript:wrote:


 Hi Gianluca, 

  I have a question ; why when a run/execute command/code line (test-fc 
 (range 210432423543654675765876879)) it's not executed the function 
 test-fc and return the sum for all 210432423543654675765876879 elements? 
 why should I put the test-fc reference to a variable, x, like you present 
 below. ( this is related to your phrase - your function computes a 
 sequence of just one element (the sum of the collection members - why ?)


  In this case (def x (test-fc (range 210432423543654675765876879)) I see 
 here a problem, I keep a reference to the head of sequence and this will 
 imply that the GC will can't garbage the unused items, if is wrong what I'm 
 say please correct me. 

  thanks a lot
  Sorin.

 -- 
 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/d/optout.




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


Re: [ANN] dag-runner -- automatically aggregate and execute functions that depend upon each other

2014-04-08 Thread Hesen Peng
Hey Leif, 

Thanks a lot for pointing this out! I did some rudimentary search before 
writing dag-runner and missed this one [shy] 

Prismatic Graph looks like a very comprehensive implementation. I'll play 
with the code and try to learn the way they implement the idea. Thanks a 
lot. 

Hesen

On Monday, April 7, 2014 4:49:55 PM UTC-7, Leif wrote:


 Hi, Hesen.  Your library sounds like a good idea.  And because it is, I 
 believe it has already been implemented as Prismatic's Graph (
 https://github.com/prismatic/plumbing).

 You may want to use/extend that instead of writing your own library.  But 
 if you continue with your own library, one good design decision that you 
 may want to borrow is separating the graph construction, compilation, and 
 execution phases.

 Cheers,
 Leif

 On Monday, April 7, 2014 7:03:48 PM UTC-4, Hesen Peng wrote:


 Hi everybody, 

 You might have experienced writing up multiple functions which depend upon 
 the result of each other to execute. To make things more complicated you 
 might even wanna split the result from one function and feed them 
 separately into two other functions, while potentially combining inputs 
 from other functions.

 To make everybody's (include my own) life easier, I made the package 
 (DAG-runner, 
 https://github.com/hesenp/dag-runner) to automatically join functions 
 with dependency specified in a directed acyclic graph (DAG).  

 For example illustrated below, if we have three functions funA, funB, funC 
 that depends upon each other, dag-run will generate a new function 
 aggregated-fun that takes all necessary input and generate all desired 
 non-intermediate output. 


 (use 'dag-runner.core)
 (dag-run aggregated-fun
  [{:function funA :input [:x :y] :output [:z :w]}
   {:function funB :input [:w :a] :output [:b]}
   {:function funC :input [:b :z] :output [:u :v]}])
 (aggregated-fun :x 1 :y 2 :a 3)


 This is my first package contributed to the Clojure community. Please feel 
 free to point out my mistakes etc so that I can improve on future projects. 
 Thanks a lot.  

 Hesen Peng



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


Re: (eval `(def ~(symbol varname) lineseq)

2014-04-08 Thread Carlo Zancanaro
On Mon, Apr 07, 2014 at 11:23:31PM -0700, Peter West wrote:
 On Tuesday, 8 April 2014 12:20:16 UTC+10, Carlo wrote:
  Your issue here is that the symbol lineseq in the eval form doesn't 
  have a name to refer to. You do have a local binding for lineseq, but 
  it's not visible to the eval: 
 
(let [x 10] (eval 'x)) ;= Unable to resolve symbol: x 
 
 If that were the case, then the reference to r in alternative 2 (def 
 lineseq (line-seq r)) would not work; but it does, so r is in scope. 
 Therefore, linseed from alternative 1 must also be in scope, mustn't it? 
  It was my understanding that the scope of with-open was equivalent to that 
 of let in  that bindings were visible within the entire scope of the 
 with-open.

No, you misunderstand me. The issue is that eval compiles and runs the
code at run-time, whereas the def compiles at compile time and runs at
run-time.

In the case of the def form, it's compiled and run in the environment
of the with-open, so the r resolves correctly to the one in the
with-open form.

The eval, however, runs in a separate environment. You've quoted your
lineseq (so it's not looked up in the current environment), then eval
can't find it in the (new) eval environment. It would have to be looking
in the existing environment. (These terms are poorly used, but
essentially: the eval loses the lexical context of where it is placed
and lineseq can't be located.)

This is why Marc recommended unquoting lineseq (using ~). An unquoted
form will be evaluated, which for a symbol means looking it up in its
current lexical scope.

  There are two ways for you to resolve this. What you're writing sounds a 
  little bit like it should be a macro, so you could write it as such: 
 
(defmacro lines-only [varname prom resource] 
  `(with-open [r# (vcf-res-reader ~resource)] 
 (let [lineseq# (line-seq r#)] 
   (def ~(symbol varname) lineseq#) 
   @~prom))) 
 
  (I think that's right, but I've not actually tested it.) 
 
 
 I think this will run into the same problem, for reasons mentioned above. 

Have you tried actually running it? I'm confident that this will not
have the issues that you had with your eval approach. The difference is
that it is a macro, so it is returning code to be run, rather than
attempting to compile and run code at run-time (as eval does).

  Alternatively, you could write it as a function and use intern: 
 
(defn lines-only [varname prom resource] 
  (with-open [r (vcf-res-reader resource)] 
(let [lineseq (line-seq r)] 
  (intern *ns* (symbol varname) lineseq) 
  @prom))) 
 
  I'm less confident about this approach, but it should work. 

This form of lines-only is a function, but it uses the function
intern instead of the special form def. This lets us maintain our
lexical context while also re-binding a name in the top-level namespace.


signature.asc
Description: Digital signature


every? expected behavior

2014-04-08 Thread Jeff Mad
Hi, 
I am new to Clojure, so please forgive me if this does not make sense. 

I was surprised to find out in the REPL that every? returns true if you 
pass in an empty or nil collection. 

user= (every? #(= 77 %) nil)

true

user= (every? #(= 77 %) '())

true


I looked at the source for every?  and it made sense to me why this happens 
given that every? is recursive and the termination condition is when coll 
runs out of items to process. 

Would it make more sense to define every?  with a loop, or is the caller 
expected to know better than to call it with nil? 

Thanks,

--jeff


(defn every2?

  Returns true if (pred x) is logical true for every x in coll, else

  false.

  {:tag Boolean

   :added 1.0

   :static true}

  [pred coll]

  (if (empty? coll)

false

  (loop [c coll]

  (cond

   (nil? (seq c)) true

   (pred (first c)) (recur (next c))

   :else false


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


Re: every? expected behavior

2014-04-08 Thread Ambrose Bonnaire-Sergeant
It's very common for a sequence argument to also work with nil, with the
same semantics as an empty sequence. They are completely different things
but
Clojure is sloppy in this regard.

I believe this is intended.

Thanks,
Ambrose


On Tue, Apr 8, 2014 at 2:08 PM, Jeff Mad jeff...@gmail.com wrote:

 Hi,
 I am new to Clojure, so please forgive me if this does not make sense.

 I was surprised to find out in the REPL that every? returns true if you
 pass in an empty or nil collection.

 user= (every? #(= 77 %) nil)

 true

 user= (every? #(= 77 %) '())

 true


 I looked at the source for every?  and it made sense to me why this
 happens given that every? is recursive and the termination condition is
 when coll runs out of items to process.

 Would it make more sense to define every?  with a loop, or is the caller
 expected to know better than to call it with nil?

 Thanks,

 --jeff


 (defn every2?

   Returns true if (pred x) is logical true for every x in coll, else

   false.

   {:tag Boolean

:added 1.0

:static true}

   [pred coll]

   (if (empty? coll)

 false

   (loop [c coll]

   (cond

(nil? (seq c)) true

(pred (first c)) (recur (next c))

:else false


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


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


Re: every? expected behavior

2014-04-08 Thread Jozef Wagner
Regardles of the underlying implementation, why do you think false would be
a better result for nil or empty collections? Can you give an example where
current every? behavior causes problems?

Jozef


On Tue, Apr 8, 2014 at 8:08 AM, Jeff Mad jeff...@gmail.com wrote:

 Hi,
 I am new to Clojure, so please forgive me if this does not make sense.

 I was surprised to find out in the REPL that every? returns true if you
 pass in an empty or nil collection.

 user= (every? #(= 77 %) nil)

 true

 user= (every? #(= 77 %) '())

 true


 I looked at the source for every?  and it made sense to me why this
 happens given that every? is recursive and the termination condition is
 when coll runs out of items to process.

 Would it make more sense to define every?  with a loop, or is the caller
 expected to know better than to call it with nil?

 Thanks,

 --jeff


 (defn every2?

   Returns true if (pred x) is logical true for every x in coll, else

   false.

   {:tag Boolean

:added 1.0

:static true}

   [pred coll]

   (if (empty? coll)

 false

   (loop [c coll]

   (cond

(nil? (seq c)) true

(pred (first c)) (recur (next c))

:else false


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


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


Re: every? expected behavior

2014-04-08 Thread Tassilo Horn
Jeff Mad jeff...@gmail.com writes:

Hi Jeff,

 I was surprised to find out in the REPL that every? returns true if
 you pass in an empty or nil collection.

 user= (every? #(= 77 %) nil)
 true

 user= (every? #(= 77 %) '())
 true

That's correct.  Every item in an empty collection satisfies the
predicate or can you name a counter-example?

Basically,

  (every? pred? coll)

is equivalent to

  (and (pred? (nth coll 0))
   (pred? (nth coll 1))
   (pred? (nth coll 2))
   ...)

The special case of coll being empty is then equivalent to (and) which
is also true.

Bye,
Tassilo

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


Re: every? expected behavior

2014-04-08 Thread Colin Yates
Depends who is doing the expecting as to whether that behaviour is correct. 
 Formal logicians, mathematicians, computer scientists etc. would respond 
sure, it is vacously true.  For almost everybody else it feels wrong 
but is then true when you think about it a bit.

I would suggest the question you are trying to ask is (and (not (empty? 
nil)) (every? #(= 77 %) nil)).

For more info check out http://en.wikipedia.org/wiki/Vacuous_truth.

On Tuesday, 8 April 2014 07:08:56 UTC+1, Jeff Mad wrote:

 Hi, 
 I am new to Clojure, so please forgive me if this does not make sense. 

 I was surprised to find out in the REPL that every? returns true if you 
 pass in an empty or nil collection. 

 user= (every? #(= 77 %) nil)

 true

 user= (every? #(= 77 %) '())

 true


 I looked at the source for every?  and it made sense to me why this 
 happens given that every? is recursive and the termination condition is 
 when coll runs out of items to process. 

 Would it make more sense to define every?  with a loop, or is the caller 
 expected to know better than to call it with nil? 

 Thanks,

 --jeff


 (defn every2?

   Returns true if (pred x) is logical true for every x in coll, else

   false.

   {:tag Boolean

:added 1.0

:static true}

   [pred coll]

   (if (empty? coll)

 false

   (loop [c coll]

   (cond

(nil? (seq c)) true

(pred (first c)) (recur (next c))

:else false




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


[ANN] Protean - a tiny project for simulating / testing RESTful API's

2014-04-08 Thread rossputin
Hi.

We've just open sourced Protean (https://github.com/passivsystems/protean), 
a little Clojure/edn project which enables simulation of RESTful API's.  

Configuring projects with edn is compact and efficient and does not require 
polluting actual project code in anyway.

API project behaviour can be hotswapped at runtime via curl posts or a cli. 
 This gives flexibility in simulating error response status codes and 
configuring the probability of errors.

A map of API surface area can be generated in the form of curl commands or 
project documentation (required headers etc).

The idea for the project originated in the office at Passiv Systems, and it 
has been used to speed development, testing and deployment of complex 
distributed systems successfully.

It is early days (0.6.0), so we are still throwing some ideas around 
(notably we want to standardise on Ring style request and response keys), 
but any contributions are welcome.

We hope this might be useful.

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


Re: Integration with Mutable Object-Oriented Eventing Hell

2014-04-08 Thread Christian Eitner
Hi Luca and Phil,

Thanks for your insights.

Especially your example, Phil, is very revealing.

I think I now have a direction for further thought. And of course I did not 
expect there to be a 'magic silver bullet' answer to the question.

Cheers,

Christian

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


REPL

2014-04-08 Thread Cecil Westerhof
Just downloaded and started with Clojure.

Is there a reason that cursor movement does not work in the REPL? I am used
that I can use up-cursor to execute an old commands again.

-- 
Cecil Westerhof

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


Re: REPL

2014-04-08 Thread Gary Trakhman
Leiningen is really the place to start, it bundles REPL-y, which includes
these features.

Follow the instructions to install: http://leiningen.org/

Then you can simply 'lein repl' in a project root (with the project's
dependencies) or it'll just open up a basic repl.


On Tue, Apr 8, 2014 at 8:01 AM, Cecil Westerhof cldwester...@gmail.comwrote:

 Just downloaded and started with Clojure.

 Is there a reason that cursor movement does not work in the REPL? I am
 used that I can use up-cursor to execute an old commands again.

 --
 Cecil Westerhof

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


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


Re: REPL

2014-04-08 Thread Di Xu
cursor movement requires readline
library 
support, I assume you start clojure by
 using


java -cp bin/clojure-
*
.jar clojure.main

you can add readline library via

rlwrap java -cp bin/clojure-*.jar clojure.main

or you can do this using lein https://github.com/technomancy/leiningen,
and start REPL via

lein repl

Thanks,
Di Xu


2014-04-08 20:01 GMT+08:00 Cecil Westerhof cldwester...@gmail.com:

 Just downloaded and started with Clojure.

 Is there a reason that cursor movement does not work in the REPL? I am
 used that I can use up-cursor to execute an old commands again.

 --
 Cecil Westerhof

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


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


Re: Lazy sequence - how they work internally

2014-04-08 Thread sorin cristea
  
  Hi Webb, 
What exactly you mean by '*The point was you aren't using lazy-seq as 
intended here since you are always creating a singleton sequence*' ? In my 
sum function: 

(
  defn test-fc
  sum of all collection elements using recursion and laziness
  [coll]
  (letfn [(sum-fc [sum coll]
(if (empty? coll)
  (cons sum nil)
  (lazy-seq(sum-fc (+ sum (first coll)) (rest coll

  )
 ]
(sum-fc 0 coll)
  )
)

I intend to compute sum of '*210432423543654675765876879*' elements of a 
collection, by calling (test-fc (range 210432423543654675765876879)), if I 
Do this 
*(def x **(test-fc (range 210432423543654675765876879)))*, and then *x,*this is 
not the same thing with *(test-fc 
(range 210432423543654675765876879))* ?, I understand the issue related to 
time to compute this sum, but the same time is taken when I call x, right ?

Thanks for the hint with trampoline function, really interested .

Sorin.

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


Re: REPL

2014-04-08 Thread Cecil Westerhof
2014-04-08 14:34 GMT+02:00 Di Xu xudi...@gmail.com:

 cursor movement requires readline
 library
 support, I assume you start clojure by
 using


 java -cp bin/clojure-
 *
 .jar clojure.main

 you can add readline library via

 rlwrap java -cp bin/clojure-*.jar clojure.main


Works like a charm.




 or you can do this using lein https://github.com/technomancy/leiningen,
 and start REPL via

 lein repl


I will look into that also.

-- 
Cecil Westerhof

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


Re: Lazy sequence - how they work internally

2014-04-08 Thread A. Webb


On Tuesday, April 8, 2014 7:57:10 AM UTC-5, sorin cristea wrote:

   
 What exactly you mean by '*The point was you aren't using lazy-seq as 
 intended here since you are always creating a singleton sequence*' ? In 
 my sum function...I intend to compute sum of elements of a collection.


Lazy-seq is intended to build sequences. Generally you'd have each 
invocation of lazy-seq produce one or more elements of a sequence. You are 
only nominally building a sequence. It is always just one element. You are 
reducing a collection to a sum. That is the job of reduce. If you want to 
delay evaluation for a given argument, use a thunk or a delay.

(defn my-sum [n] (reduce + (range n)))

(def my-result 10) ; my-result is 45 (eagerly evaluated)

(def my-thunked-result (fn [] (my-sum 10))) ; the sum is not 
calculated until evaluating (my-thunked-result), answer is not cached

(def my-delayed-result (delay (my-sum 10))) ; the sum is not 
calculated until forcing @my-delayed-result, answer is cached for 
subsequent use


 

 [I]f I [d]o this *(def x **(test-fc ...))*, and then *x,* this is not the 
 same thing with *(test-fc ...)* ?, I understand the issue related to time 
 to compute this sum, but the same time is taken when I call x, right ?

 Yes, that's what I said. Only in the first case evaluation is delayed 
until you request the value of `x` and in the second it is requested 
immediately to print at the REPL. You might find it instructive to put some 
`println`s in your code to see how and when your calculation is progressing 
and to use a large but still reasonable size collection, say 1 million 
elements.
 

 Thanks for the hint with trampoline function, really interested .

 Sorin.



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


[ANN] Immutant 1.1.1 released

2014-04-08 Thread Jim Crossley
Hi all,

We released version 1.1.1 
today: http://immutant.org/news/2014/04/08/announcing-1-1-1/

We also released version 1.2.1 of the lein-immutant 
plugin: http://immutant.org/news/2014/04/08/lein-immutant-1-2-1/

Unless any bugs are reported against 1.1.1, we don't expect to release 
another in the 1.x series. We're now focusing our efforts on The Deuce:  
http://immutant.org/news/2014/04/02/the-deuce/

For those unfamiliar, Immutant is an application server for Clojure. It's 
an integrated platform built on JBoss AS7 that aims to reduce the 
incidental complexity in real-world applications. It provides support for 
Ring handlers, asynchronous messaging, caching, scheduled jobs, XA 
transactions, clustering, and daemons.

Immutant 2.x will be comprised of just libraries, one for each of the above 
services, embeddable within your standalone apps or deployable to a stock 
WildFly 8 (or EAP) app server.

Feel free to help or lurk: http://immutant.org/community/

Love,
Jim 

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


Name for this pattern: side-effect from swap!

2014-04-08 Thread John D. Hume
I sometimes find that after mutating an atom, I want to create some
side-effect that depends on the old and new state as well as the context in
which the change was made. Because of the dependence on context, a watch
doesn't work (unless there's something I'm not thinking of). So I add
things to the new atom state (returned by swap!) purely to tell the calling
code what side-effect to have (or give it the data it needs to decide what
side-effect to have). That additional state isn't used anywhere other than
the fn that called swap!.

One gotcha to this approach is that one must be careful not to leave some
old side-effect causing state in place to cause another side-effect based
on stale data.

Is there a name for this pattern? A standard way of implementing it? A
better alternative?

One alternative I'm aware of is using mutable locals (provided by
https://github.com/ztellman/proteus) as a side-channel of communication
from swap!. Both approaches strike me as messy, though a let-mutable
probably makes it more obvious that something funny is going on, and it
doesn't pollute the atom.

Thanks.
-hume.

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


Re: Name for this pattern: side-effect from swap!

2014-04-08 Thread A. Webb
See https://groups.google.com/d/topic/clojure/2dHvX7bf7nA/discussion, 
http://stackoverflow.com/a/22409846/1756702, where the old and new state of 
an atom is returned using the lower-level compare-and-set! operation.

On Tuesday, April 8, 2014 10:41:50 AM UTC-5, John Hume wrote:

 I sometimes find that after mutating an atom, I want to create some 
 side-effect that depends on the old and new state as well as the context in 
 which the change was made. Because of the dependence on context, a watch 
 doesn't work (unless there's something I'm not thinking of). So I add 
 things to the new atom state (returned by swap!) purely to tell the calling 
 code what side-effect to have (or give it the data it needs to decide what 
 side-effect to have). That additional state isn't used anywhere other than 
 the fn that called swap!.

 One gotcha to this approach is that one must be careful not to leave some 
 old side-effect causing state in place to cause another side-effect based 
 on stale data.

 Is there a name for this pattern? A standard way of implementing it? A 
 better alternative?

 One alternative I'm aware of is using mutable locals (provided by 
 https://github.com/ztellman/proteus) as a side-channel of communication 
 from swap!. Both approaches strike me as messy, though a let-mutable 
 probably makes it more obvious that something funny is going on, and it 
 doesn't pollute the atom.

 Thanks.
 -hume.


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


Re: every? expected behavior

2014-04-08 Thread Jeff Mad
Thanks to all for the nice explanations.  I understand the reasoning. 

On Tuesday, April 8, 2014 1:53:44 AM UTC-7, Colin Yates wrote:

 Depends who is doing the expecting as to whether that behaviour is 
 correct.  Formal logicians, mathematicians, computer scientists etc. would 
 respond sure, it is vacously true.  For almost everybody else it feels 
 wrong but is then true when you think about it a bit.

 I would suggest the question you are trying to ask is (and (not (empty? 
 nil)) (every? #(= 77 %) nil)).

 For more info check out http://en.wikipedia.org/wiki/Vacuous_truth.

 On Tuesday, 8 April 2014 07:08:56 UTC+1, Jeff Mad wrote:

 Hi, 
 I am new to Clojure, so please forgive me if this does not make sense. 

 I was surprised to find out in the REPL that every? returns true if you 
 pass in an empty or nil collection. 

 user= (every? #(= 77 %) nil)

 true

 user= (every? #(= 77 %) '())

 true


 I looked at the source for every?  and it made sense to me why this 
 happens given that every? is recursive and the termination condition is 
 when coll runs out of items to process. 

 Would it make more sense to define every?  with a loop, or is the caller 
 expected to know better than to call it with nil? 

 Thanks,

 --jeff


 (defn every2?

   Returns true if (pred x) is logical true for every x in coll, else

   false.

   {:tag Boolean

:added 1.0

:static true}

   [pred coll]

   (if (empty? coll)

 false

   (loop [c coll]

   (cond

(nil? (seq c)) true

(pred (first c)) (recur (next c))

:else false




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


Re: Name for this pattern: side-effect from swap!

2014-04-08 Thread Alex Miller
+1 that answer

Also if it served your needs, watches give you the old and new 
values 
http://clojure.github.io/clojure/clojure.core-api.html#clojure.core/add-watch

On Tuesday, April 8, 2014 11:00:20 AM UTC-5, A. Webb wrote:

 See https://groups.google.com/d/topic/clojure/2dHvX7bf7nA/discussion, 
 http://stackoverflow.com/a/22409846/1756702, where the old and new state 
 of an atom is returned using the lower-level compare-and-set! operation.

 On Tuesday, April 8, 2014 10:41:50 AM UTC-5, John Hume wrote:

 I sometimes find that after mutating an atom, I want to create some 
 side-effect that depends on the old and new state as well as the context in 
 which the change was made. Because of the dependence on context, a watch 
 doesn't work (unless there's something I'm not thinking of). So I add 
 things to the new atom state (returned by swap!) purely to tell the calling 
 code what side-effect to have (or give it the data it needs to decide what 
 side-effect to have). That additional state isn't used anywhere other than 
 the fn that called swap!.

 One gotcha to this approach is that one must be careful not to leave some 
 old side-effect causing state in place to cause another side-effect based 
 on stale data.

 Is there a name for this pattern? A standard way of implementing it? A 
 better alternative?

 One alternative I'm aware of is using mutable locals (provided by 
 https://github.com/ztellman/proteus) as a side-channel of communication 
 from swap!. Both approaches strike me as messy, though a let-mutable 
 probably makes it more obvious that something funny is going on, and it 
 doesn't pollute the atom.

 Thanks.
 -hume.



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


Re: Core.async nil on unclosed channels

2014-04-08 Thread Alejandro Ciniglio
So should I open a bug on this map behavior? This also breaks 
composability with things like filter because they assume that nil being 
returned implies a closed channel, and proceed to close their output 
channel...

e.g.  

(filter identity (map seq c))

will close the output channel after something like (!! c [])

On Monday, April 7, 2014 1:50:18 PM UTC-4, tbc++ wrote:

 (async/into []) is probably the closest thing to doall


 On Mon, Apr 7, 2014 at 11:46 AM, Alejandro Ciniglio 
 skia...@gmail.comjavascript:
  wrote:

  Sure, except you can use doall to realize the sequence from map, but 
 there's no equivalent for core.async.map. I guess you could wrap it in 
 something that constantly tries to read from the output channel?
  
 On Apr 7, 2014, 1:39 PM, Timothy Baldridge wrote: 

   That's the case with clojure.core.map as well, don't consume the lazy 
 seq the side effects aren't run...in short, map is not for side effects.  

  

 On Mon, Apr 7, 2014 at 11:32 AM, Alejandro Ciniglio 
 skia...@gmail.comjavascript:
  wrote:

 Yeah, that seems to be the best practice that's promoted as well. 
 Another gotcha with this implementation is that since it's done via 
 extending the channel protocol (specifically take!), it doesn't actually 
 apply the functions effects unless someone is reading from the channel. 
 This could be an issue if you want side-effects only from the map call. 


 On Monday, April 7, 2014 11:36:21 AM UTC-4, James Reeves wrote:

  This looks like a bug to me. A lot of the internal core.async 
 functions rely on nil values indicating the channel is closed. 

 - James
  

  On 7 April 2014 16:26, Alejandro Ciniglio skia...@gmail.com wrote:

  Using core.async, I've understood the convention to be that if you 
 take nil from a channel, that channel is closed. This seems to hold for 
 most cases, but I've found a corner case when using map that lets you 
 pull 
 nil from a channel that is not closed.  

 (def a (chan))
 (def c (map seq a))
 (go (prn (! c)))
 (!! a [])
 ; = nil nil ;; [one nil is printed, one is returned]
 (go (prn (! c)))
 (!! a [1])
 ; = nil (1)

 This can be chained as well (e.g. (map identity (map  seq a)) ), 
 and nils just flow through. 

 From looking at the implementation, it's apparent that this happens 
 because the function application of map happens when taking from the 
 output 
 channel so nil is not technically on the channel, (unless it flows 
 through 
 to another map).

 Is this a bug or is my mental model of nil = closed incorrect?

 Thanks,
 Alejandro
  --
 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 

 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 

 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. 

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

  
   --
 You received this message because you are subscribed to the Google
 Groups Clojure group.
 To post to this group, send email to 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/d/optout.
  
  


 --
 “One of the main causes of the fall of the Roman Empire was that–lacking 
 zero–they had no way to indicate successful termination of their C 
 programs.”
 (Robert Firth)
 --
 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 a topic in the 
 Google Groups Clojure group.
 To unsubscribe from this topic, visit 
 https://groups.google.com/d/topic/clojure/Hnjg9ovh0uA/unsubscribe.
 To unsubscribe from this group and all its topics, send an email to 
 clojure+u...@googlegroups.com javascript:.

 For more options, visit https://groups.google.com/d/optout.
  
  -- 
 You 

Any experience with Cognitect?

2014-04-08 Thread Mike Haney
Cognitect (and previously Relevance) always seem to have openings for 
contract Clojure developers.  I was wondering if anyone here has applied 
for and/or actually been hired for one of these positions, and was willing 
to share their experience?

I have thought about the possibility of being a contractor for Cognitect 
for awhile, and it's been pretty much my target goal as I've been learning 
Clojure/Datomic over the last 8-9 months.  The bar seems pretty high - I 
mean, do you have to be a Mike Fogus or Tim Baldridge to work there?

My current contract is winding up soon, and my Clojure skills are at the 
point where I think I am almost productive enough to use it professionally 
(IMO you have to actually USE something professionally to reach that last 
level of productivity, which is why I said almost).  This would be an ideal 
time to make the switch, but I don't want to apply too soon and ruin my 
chances.

One other question - for anyone who has worked as a contractor for them, 
was there usually/always enough work to keep you busy full time, or would I 
need to plan on doing other freelance work to fill in the gaps between 
assignments for them?

TIA for any advice.  

 

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


Re: Any experience with Cognitect?

2014-04-08 Thread Tim Visher
On Tue, Apr 8, 2014 at 12:56 PM, Mike Haney txmikes...@gmail.com wrote:
 Cognitect (and previously Relevance) always seem to have openings for
 contract Clojure developers.  I was wondering if anyone here has applied for
 and/or actually been hired for one of these positions, and was willing to
 share their experience?

 I have thought about the possibility of being a contractor for Cognitect for
 awhile, and it's been pretty much my target goal as I've been learning
 Clojure/Datomic over the last 8-9 months.  The bar seems pretty high - I
 mean, do you have to be a Mike Fogus or Tim Baldridge to work there?

 My current contract is winding up soon, and my Clojure skills are at the
 point where I think I am almost productive enough to use it professionally
 (IMO you have to actually USE something professionally to reach that last
 level of productivity, which is why I said almost).  This would be an ideal
 time to make the switch, but I don't want to apply too soon and ruin my
 chances.

 One other question - for anyone who has worked as a contractor for them, was
 there usually/always enough work to keep you busy full time, or would I need
 to plan on doing other freelance work to fill in the gaps between
 assignments for them?

Fortune favors the brave, the worst they can do is say no. :)

I did apply, feeling woefully under-prepared, and had some really nice
conversations with them. I'd still love to work with them some day,
but it turned out that the uncertainty of contracting was just too
much for me to stomach.

Do it!

:)

--

In Christ,

Timmy V.

http://blog.twonegatives.com/
http://five.sentenc.es/ -- Spend less time on mail

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


Re: Any experience with Cognitect?

2014-04-08 Thread Stuart Halloway
Applying too early will never hurt you, so long as you are candid about
where you are and where you want to be.  It took me three rounds of
rejection+feedback to land my first high-profile tech job.

The contracting relationship is designed to handle high variability.  You
might get lucky and see exactly the stream of work on the schedule you
want, or pretty much the opposite can happen.

Stu
President, Cognitect


On Tue, Apr 8, 2014 at 12:56 PM, Mike Haney txmikes...@gmail.com wrote:

 Cognitect (and previously Relevance) always seem to have openings for
 contract Clojure developers.  I was wondering if anyone here has applied
 for and/or actually been hired for one of these positions, and was willing
 to share their experience?

 I have thought about the possibility of being a contractor for Cognitect
 for awhile, and it's been pretty much my target goal as I've been learning
 Clojure/Datomic over the last 8-9 months.  The bar seems pretty high - I
 mean, do you have to be a Mike Fogus or Tim Baldridge to work there?

 My current contract is winding up soon, and my Clojure skills are at the
 point where I think I am almost productive enough to use it professionally
 (IMO you have to actually USE something professionally to reach that last
 level of productivity, which is why I said almost).  This would be an ideal
 time to make the switch, but I don't want to apply too soon and ruin my
 chances.

 One other question - for anyone who has worked as a contractor for them,
 was there usually/always enough work to keep you busy full time, or would I
 need to plan on doing other freelance work to fill in the gaps between
 assignments for them?

 TIA for any advice.



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


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


Re: Name for this pattern: side-effect from swap!

2014-04-08 Thread Bruno Kim Medeiros Cesar
Why aren't watches adequate? You could test inside them if you really wish 
to create the side-effect based on your context.

On Tuesday, April 8, 2014 12:41:50 PM UTC-3, John Hume wrote:

 I sometimes find that after mutating an atom, I want to create some 
 side-effect that depends on the old and new state as well as the context in 
 which the change was made. Because of the dependence on context, a watch 
 doesn't work (unless there's something I'm not thinking of). So I add 
 things to the new atom state (returned by swap!) purely to tell the calling 
 code what side-effect to have (or give it the data it needs to decide what 
 side-effect to have). That additional state isn't used anywhere other than 
 the fn that called swap!.

 One gotcha to this approach is that one must be careful not to leave some 
 old side-effect causing state in place to cause another side-effect based 
 on stale data.

 Is there a name for this pattern? A standard way of implementing it? A 
 better alternative?

 One alternative I'm aware of is using mutable locals (provided by 
 https://github.com/ztellman/proteus) as a side-channel of communication 
 from swap!. Both approaches strike me as messy, though a let-mutable 
 probably makes it more obvious that something funny is going on, and it 
 doesn't pollute the atom.

 Thanks.
 -hume.


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


How to do this correct in Clojure

2014-04-08 Thread Cecil Westerhof
In common lisp I had the following code:
(let (
  (difference)
  (i)
  (val)
  )
  (loop for i from 1 to 1000 do
   (setq val (sqrt i))
   (setq difference (abs (- (expt val 2) (* val val
   (unless ( difference 1.1755025E-38)
 (print (format nil Different for ~D (~F). i difference))
 )))

Clojure works a little bit different. Until now I have the following with
comes near the above:
  (for [i (range 1 1000)]
   (do
   (def ^:dynamic val (Math/sqrt i))
   (def ^:dynamic difference (Math/abs (- (Math/pow val 2) (* val
val
   (when ( difference 1.1755025E-38)
 (println (format Different for %d (%e) i difference))
 )))

But beside that this defines the two variables val and difference, it also
generates a lot of nil values.

What would be a better way to do this in Clojure?


-- 
Cecil Westerhof

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


Re: How to do this correct in Clojure

2014-04-08 Thread Toby Crawley
Does this give you the results you are looking for?

(doall
  (for [i (range 1 1000)
:let [val (Math/sqrt i)
  diff (Math/abs (- (Math/pow val 2) (* val val)))]
:when ( diff 1.1755025E-38)]
(println (format Different for %d (%e) i diff

cldwester...@gmail.com writes:

 In common lisp I had the following code:
 (let (
   (difference)
   (i)
   (val)
   )
   (loop for i from 1 to 1000 do
(setq val (sqrt i))
(setq difference (abs (- (expt val 2) (* val val
(unless ( difference 1.1755025E-38)
  (print (format nil Different for ~D (~F). i difference))
  )))

 Clojure works a little bit different. Until now I have the following with
 comes near the above:
   (for [i (range 1 1000)]
(do
(def ^:dynamic val (Math/sqrt i))
(def ^:dynamic difference (Math/abs (- (Math/pow val 2) (* val
 val
(when ( difference 1.1755025E-38)
  (println (format Different for %d (%e) i difference))
  )))

 But beside that this defines the two variables val and difference, it also
 generates a lot of nil values.

 What would be a better way to do this in Clojure?


 --
 Cecil Westerhof

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


where as clojure-fill-docstring gone?

2014-04-08 Thread Colin Yates
I upgraded my emacs and clojure-fill-docstring seems to have disappeared. 
 clojure-mode is still there and activated but no clojure-fill-docstring.  

Before I spend time hunting through changelogs has anybody else noticed? 
 Is this expected?


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


Re: How to do this correct in Clojure

2014-04-08 Thread Cecil Westerhof
2014-04-08 20:49 GMT+02:00 Toby Crawley t...@tcrawley.org:

 Does this give you the results you are looking for?

 (doall
   (for [i (range 1 1000)
 :let [val (Math/sqrt i)
   diff (Math/abs (- (Math/pow val 2) (* val val)))]
 :when ( diff 1.1755025E-38)]
 (println (format Different for %d (%e) i diff


It is a lot better. But for every result I get a nil value:
(doall
  (for [i (range 1 1)
:let [val (Math/sqrt i)
  diff (Math/abs (- (Math/pow val 2) (* val val)))]
:when ( diff 1.1755025E-38)]
(println (format Different for %d (%e) i diff

Gives:
Different for 838 (1.136868e-13)
Different for 3352 (4.547474e-13)
Different for 3674 (4.547474e-13)
Different for 5343 (9.094947e-13)
Different for 7667 (9.094947e-13)
Different for 7863 (9.094947e-13)
Different for 9470 (1.818989e-12)
(nil nil nil nil nil nil nil)


Is it possible to get rid of the last line:
(nil nil nil nil nil nil nil)



 cldwester...@gmail.com writes:

  In common lisp I had the following code:
  (let (
(difference)
(i)
(val)
)
(loop for i from 1 to 1000 do
 (setq val (sqrt i))
 (setq difference (abs (- (expt val 2) (* val val
 (unless ( difference 1.1755025E-38)
   (print (format nil Different for ~D (~F). i difference))
   )))
 
  Clojure works a little bit different. Until now I have the following with
  comes near the above:
(for [i (range 1 1000)]
 (do
 (def ^:dynamic val (Math/sqrt i))
 (def ^:dynamic difference (Math/abs (- (Math/pow val 2) (* val
  val
 (when ( difference 1.1755025E-38)
   (println (format Different for %d (%e) i difference))
   )))
 
  But beside that this defines the two variables val and difference, it
 also
  generates a lot of nil values.
 
  What would be a better way to do this in Clojure?
 
 
  --
  Cecil Westerhof

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




-- 
Cecil Westerhof

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


Re: where as clojure-fill-docstring gone?

2014-04-08 Thread Bastien
Hi Colin,

Colin Yates colin.ya...@gmail.com writes:

 Before I spend time hunting through changelogs has anybody else
 noticed?  Is this expected?

`clojure-fill-docstring' behavior was somewhat wrong and the
whole function not necessary, I removed it recently.

That said, there are some quirks.  I'm sick now and cannot
fix those problems, but please report them as github issues
if any.

-- 
 Bastien

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


Re: where as clojure-fill-docstring gone?

2014-04-08 Thread Colin Yates
Hi Bastian, sucks being sick.  You mention it was unnecessary - can you let 
me know the thing that made it redundant?  I tried fill-paragraph but that 
doesn't quite work...

On Tuesday, 8 April 2014 20:28:52 UTC+1, Bastien Guerry wrote:

 Hi Colin, 

 Colin Yates colin...@gmail.com javascript: writes: 

  Before I spend time hunting through changelogs has anybody else 
  noticed?  Is this expected? 

 `clojure-fill-docstring' behavior was somewhat wrong and the 
 whole function not necessary, I removed it recently. 

 That said, there are some quirks.  I'm sick now and cannot 
 fix those problems, but please report them as github issues 
 if any. 

 -- 
  Bastien 


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


Re: where as clojure-fill-docstring gone?

2014-04-08 Thread Tassilo Horn
Colin Yates colin.ya...@gmail.com writes:

Hi Colin,

 I upgraded my emacs and clojure-fill-docstring seems to have
 disappeared.  clojure-mode is still there and activated but no
 clojure-fill-docstring.

 Before I spend time hunting through changelogs has anybody else
 noticed?  Is this expected?

I has been removed caused it garbled my docstrings.

  https://github.com/clojure-emacs/clojure-mode/issues/224

Bye,
Tassilo

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


Re: where as clojure-fill-docstring gone?

2014-04-08 Thread Bastien
Colin Yates colin.ya...@gmail.com writes:

 Hi Bastian, sucks being sick.  You mention it was unnecessary - can
 you let me know the thing that made it redundant?

It was less redundant than weird.

 I tried fill-paragraph but that doesn't quite work...

Can you explicit what does not work?

There is this issue:
https://github.com/clojure-emacs/clojure-mode/issues/228

If there are others, please add an issue on github.

Thanks!

-- 
 Bastien

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


RE: where as clojure-fill-docstring gone?

2014-04-08 Thread Colin Yates
Yep - that issue covers the issue.  I don't have any other problems other than 
that issue.
I shall watch that issue closely :)

 From: bastiengue...@gmail.com
 To: colin.ya...@gmail.com
 CC: clojure@googlegroups.com
 Subject: Re: where as clojure-fill-docstring gone?
 Date: Tue, 8 Apr 2014 21:37:33 +0200
 
 Colin Yates colin.ya...@gmail.com writes:
 
  Hi Bastian, sucks being sick.  You mention it was unnecessary - can
  you let me know the thing that made it redundant?
 
 It was less redundant than weird.
 
  I tried fill-paragraph but that doesn't quite work...
 
 Can you explicit what does not work?
 
 There is this issue:
 https://github.com/clojure-emacs/clojure-mode/issues/228
 
 If there are others, please add an issue on github.
 
 Thanks!
 
 -- 
  Bastien
  

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


[ANN] ccm-clj - test Cassandra clusters via Clojure

2014-04-08 Thread coltnz
ccm the Cassandra Cluster Manager, https://github.com/pcmanus/ccm, allows the 
running up of arbitrary Cassandra clusters from specific version source.

ccm-clj (https://github.com/SMX-LTD/ccm-clj) is a Clojure interface designed 
specifically for the ease of use of ccm in Clojure integration tests.

(if (not (ccm/cluster? testcluster))
  (do
(ccm/new! testcluster cass-version num-nodes cql-port)
(ccm/cql! (io/file ./test/resources/test-keyspace.cql))
(ccm/cql! (io/resource schema/test-schema.cql) testkeyspace)
(ccm/cql! (io/file ./test/resources/test-data.cql) testkeyspace))
  (do
(ccm/switch! testcluster)
(ccm/start! testcluster)))

(ccm/remove! testcluster)

cheers
Colin

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


Re: How to do this correct in Clojure

2014-04-08 Thread Walter van der Laan
This will only give you one nil:
(doseq [i (range 1 1)]
  (let [val (Math/sqrt i)
diff (Math/abs (- (Math/pow val 2) (* val val)))]
(when ( diff 1.1755025E-38)
  (println (format Different for %d (%e) i diff)

On Tuesday, April 8, 2014 9:28:44 PM UTC+2, Cecil Westerhof wrote:

 2014-04-08 20:49 GMT+02:00 Toby Crawley to...@tcrawley.org javascript:
 :

 Does this give you the results you are looking for?

 (doall
   (for [i (range 1 1000)
 :let [val (Math/sqrt i)
   diff (Math/abs (- (Math/pow val 2) (* val val)))]
 :when ( diff 1.1755025E-38)]
 (println (format Different for %d (%e) i diff


 It is a lot better. But for every result I get a nil value:
 (doall
   (for [i (range 1 1)
 :let [val (Math/sqrt i)
   diff (Math/abs (- (Math/pow val 2) (* val val)))]
 :when ( diff 1.1755025E-38)]
 (println (format Different for %d (%e) i diff

 Gives:
 Different for 838 (1.136868e-13)
 Different for 3352 (4.547474e-13)
 Different for 3674 (4.547474e-13)
 Different for 5343 (9.094947e-13)
 Different for 7667 (9.094947e-13)
 Different for 7863 (9.094947e-13)
 Different for 9470 (1.818989e-12)
 (nil nil nil nil nil nil nil)
  
 Is it possible to get rid of the last line:
 (nil nil nil nil nil nil nil)


 cldwes...@gmail.com javascript: writes:

  In common lisp I had the following code:
  (let (
(difference)
(i)
(val)
)
(loop for i from 1 to 1000 do
 (setq val (sqrt i))
 (setq difference (abs (- (expt val 2) (* val val
 (unless ( difference 1.1755025E-38)
   (print (format nil Different for ~D (~F). i difference))
   )))
 
  Clojure works a little bit different. Until now I have the following 
 with
  comes near the above:
(for [i (range 1 1000)]
 (do
 (def ^:dynamic val (Math/sqrt i))
 (def ^:dynamic difference (Math/abs (- (Math/pow val 2) (* val
  val
 (when ( difference 1.1755025E-38)
   (println (format Different for %d (%e) i difference))
   )))
 
  But beside that this defines the two variables val and difference, it 
 also
  generates a lot of nil values.
 
  What would be a better way to do this in Clojure?
 
 
  --
  Cecil Westerhof

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




 -- 
 Cecil Westerhof 


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


Re: How to do this correct in Clojure

2014-04-08 Thread Toby Crawley
That last line is the repl printing out the result of the for, which
returns a seq of the return values from the for body (in this case, the
return value of println). If you run this code as part of an
application, you would not see the seq of nils printed. To suppress
printing them in the repl, and instead have it print a single nil,
replace 'doall' with 'dorun'. That will do the same thing, but retain
none of the results.

- Toby

cldwester...@gmail.com writes:

 2014-04-08 20:49 GMT+02:00 Toby Crawley t...@tcrawley.org:

 Does this give you the results you are looking for?

 (doall
   (for [i (range 1 1000)
 :let [val (Math/sqrt i)
   diff (Math/abs (- (Math/pow val 2) (* val val)))]
 :when ( diff 1.1755025E-38)]
 (println (format Different for %d (%e) i diff


 It is a lot better. But for every result I get a nil value:
 (doall
   (for [i (range 1 1)
 :let [val (Math/sqrt i)
   diff (Math/abs (- (Math/pow val 2) (* val val)))]
 :when ( diff 1.1755025E-38)]
 (println (format Different for %d (%e) i diff

 Gives:
 Different for 838 (1.136868e-13)
 Different for 3352 (4.547474e-13)
 Different for 3674 (4.547474e-13)
 Different for 5343 (9.094947e-13)
 Different for 7667 (9.094947e-13)
 Different for 7863 (9.094947e-13)
 Different for 9470 (1.818989e-12)
 (nil nil nil nil nil nil nil)


 Is it possible to get rid of the last line:
 (nil nil nil nil nil nil nil)



 cldwester...@gmail.com writes:

  In common lisp I had the following code:
  (let (
(difference)
(i)
(val)
)
(loop for i from 1 to 1000 do
 (setq val (sqrt i))
 (setq difference (abs (- (expt val 2) (* val val
 (unless ( difference 1.1755025E-38)
   (print (format nil Different for ~D (~F). i difference))
   )))
 
  Clojure works a little bit different. Until now I have the following with
  comes near the above:
(for [i (range 1 1000)]
 (do
 (def ^:dynamic val (Math/sqrt i))
 (def ^:dynamic difference (Math/abs (- (Math/pow val 2) (* val
  val
 (when ( difference 1.1755025E-38)
   (println (format Different for %d (%e) i difference))
   )))
 
  But beside that this defines the two variables val and difference, it
 also
  generates a lot of nil values.
 
  What would be a better way to do this in Clojure?
 
 
  --
  Cecil Westerhof

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




 --
 Cecil Westerhof

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


Re: OT: Wiki Use Survey

2014-04-08 Thread John Gabriele
On the first question, Other needs its own checkbox.

-- John

On Monday, April 7, 2014 7:26:08 PM UTC-4, Rich Morin wrote:

 My spouse (Vicki Brown) has put together a very short survey on wiki 
 use.  If this is of possible interest to you, read on... 

 -r 


 The SurveyMonkey page for the Wiki Use Survey is located at: 

https://www.surveymonkey.com/s.aspx?sm=17tHn4bsQ98%2fV6zkaM3gAw%3d%3d 

 Quoting from the survey's preamble: 

   As a wiki consultant, specializing in enterprise wikis, 
   I've noticed that: 

- many companies use wikis 
- there are multiple options to choose from 
- features and functionality vary 
- opinions vary widely 
- understanding of what features are available varies even more 

I thought it would be interesting to ask people in different areas 
(tech writers, developers, etc) about their wiki use, collect the 
data, and publish the results (in a blog post). 

If you use a wiki at your job, I would appreciate it if you would 
respond to the following survey.  All questions are optional except 
the first one. 

(If you use a wiki for personal projects, I would be interested in 
hearing about that as well.) 

- Vicki, v...@cfcl.com javascript: 

 N.B. I shouldn't need to say this, but: Published results will 
 not include any names or contact information of people or companies! 

  -- 
 http://www.cfcl.com/rdm   Rich Morin   
 r...@cfcl.comjavascript: 
 http://www.cfcl.com/rdm/resumeSan Bruno, CA, USA   +1 650-873-7841 

 Software system design, development, and documentation 




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


Re: How to do this correct in Clojure

2014-04-08 Thread Cecil Westerhof
2014-04-08 22:01 GMT+02:00 Walter van der Laan waltervanderl...@fincite.nl
:

 This will only give you one nil:
 (doseq [i (range 1 1)]
   (let [val (Math/sqrt i)
 diff (Math/abs (- (Math/pow val 2) (* val val)))]
 (when ( diff 1.1755025E-38)
   (println (format Different for %d (%e) i diff)


That works. Thanks.




 On Tuesday, April 8, 2014 9:28:44 PM UTC+2, Cecil Westerhof wrote:

 2014-04-08 20:49 GMT+02:00 Toby Crawley to...@tcrawley.org:

 Does this give you the results you are looking for?

 (doall
   (for [i (range 1 1000)
 :let [val (Math/sqrt i)
   diff (Math/abs (- (Math/pow val 2) (* val val)))]
 :when ( diff 1.1755025E-38)]
 (println (format Different for %d (%e) i diff


 It is a lot better. But for every result I get a nil value:
 (doall
   (for [i (range 1 1)
 :let [val (Math/sqrt i)
   diff (Math/abs (- (Math/pow val 2) (* val val)))]
 :when ( diff 1.1755025E-38)]
 (println (format Different for %d (%e) i diff

 Gives:
 Different for 838 (1.136868e-13)
 Different for 3352 (4.547474e-13)
 Different for 3674 (4.547474e-13)
 Different for 5343 (9.094947e-13)
 Different for 7667 (9.094947e-13)
 Different for 7863 (9.094947e-13)
 Different for 9470 (1.818989e-12)
 (nil nil nil nil nil nil nil)

 Is it possible to get rid of the last line:
 (nil nil nil nil nil nil nil)


 cldwes...@gmail.com writes:

  In common lisp I had the following code:
  (let (
(difference)
(i)
(val)
)
(loop for i from 1 to 1000 do
 (setq val (sqrt i))
 (setq difference (abs (- (expt val 2) (* val val
 (unless ( difference 1.1755025E-38)
   (print (format nil Different for ~D (~F). i difference))
   )))
 
  Clojure works a little bit different. Until now I have the following
 with
  comes near the above:
(for [i (range 1 1000)]
 (do
 (def ^:dynamic val (Math/sqrt i))
 (def ^:dynamic difference (Math/abs (- (Math/pow val 2) (* val
  val
 (when ( difference 1.1755025E-38)
   (println (format Different for %d (%e) i difference))
   )))
 
  But beside that this defines the two variables val and difference, it
 also
  generates a lot of nil values.
 
  What would be a better way to do this in Clojure?
 
 
  --
  Cecil Westerhof

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

 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

 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.

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




 --
 Cecil Westerhof

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




-- 
Cecil Westerhof

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


true lightweight threads on clojurescript?

2014-04-08 Thread t x
Hi,


  * I am aware of core.async. However, I don't like the fact that (go
... ) is a macro, thus forcing the ! and ! to appear in the body,
and I can't do nested things like:

  (defn foo [chan]
 (let [x (! chan)] ... ))

  (go ... (foo ... ))


  * For the following, I only need it to work in ClojureScript. I
don't need it to work in Clojure. Furthermore, we can assume browser =
latest Firefox, or browser = latest Chrome.


  Now, my question: is there a library which provides true
lightweight Clojurescript threads?


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/d/optout.


Re: true lightweight threads on clojurescript?

2014-04-08 Thread Gary Trakhman
I think you might be able to use put! with a callback, or (go (! ..))
within foo for a transient go process.  Not sure if there's any ill effects.


On Tue, Apr 8, 2014 at 4:51 PM, t x txrev...@gmail.com wrote:

 Hi,


   * I am aware of core.async. However, I don't like the fact that (go
 ... ) is a macro, thus forcing the ! and ! to appear in the body,
 and I can't do nested things like:

   (defn foo [chan]
  (let [x (! chan)] ... ))

   (go ... (foo ... ))


   * For the following, I only need it to work in ClojureScript. I
 don't need it to work in Clojure. Furthermore, we can assume browser =
 latest Firefox, or browser = latest Chrome.


   Now, my question: is there a library which provides true
 lightweight Clojurescript threads?


 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/d/optout.


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


Re: true lightweight threads on clojurescript?

2014-04-08 Thread t x
I'd really like to avoid callbacks. :-)

If cljs had promises, it would suffice. :-)

On Tue, Apr 8, 2014 at 2:00 PM, Gary Trakhman gary.trakh...@gmail.com wrote:
 I think you might be able to use put! with a callback, or (go (! ..))
 within foo for a transient go process.  Not sure if there's any ill effects.


 On Tue, Apr 8, 2014 at 4:51 PM, t x txrev...@gmail.com wrote:

 Hi,


   * I am aware of core.async. However, I don't like the fact that (go
 ... ) is a macro, thus forcing the ! and ! to appear in the body,
 and I can't do nested things like:

   (defn foo [chan]
  (let [x (! chan)] ... ))

   (go ... (foo ... ))


   * For the following, I only need it to work in ClojureScript. I
 don't need it to work in Clojure. Furthermore, we can assume browser =
 latest Firefox, or browser = latest Chrome.


   Now, my question: is there a library which provides true
 lightweight Clojurescript threads?


 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/d/optout.


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

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


Re: true lightweight threads on clojurescript?

2014-04-08 Thread James Reeves
What exactly are you trying to do? Could you describe the problem you're
trying to solve in more detail?

- James


On 8 April 2014 22:02, t x txrev...@gmail.com wrote:

 I'd really like to avoid callbacks. :-)

 If cljs had promises, it would suffice. :-)

 On Tue, Apr 8, 2014 at 2:00 PM, Gary Trakhman gary.trakh...@gmail.com
 wrote:
  I think you might be able to use put! with a callback, or (go (! ..))
  within foo for a transient go process.  Not sure if there's any ill
 effects.
 
 
  On Tue, Apr 8, 2014 at 4:51 PM, t x txrev...@gmail.com wrote:
 
  Hi,
 
 
* I am aware of core.async. However, I don't like the fact that (go
  ... ) is a macro, thus forcing the ! and ! to appear in the body,
  and I can't do nested things like:
 
(defn foo [chan]
   (let [x (! chan)] ... ))
 
(go ... (foo ... ))
 
 
* For the following, I only need it to work in ClojureScript. I
  don't need it to work in Clojure. Furthermore, we can assume browser =
  latest Firefox, or browser = latest Chrome.
 
 
Now, my question: is there a library which provides true
  lightweight Clojurescript threads?
 
 
  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/d/optout.
 
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
 your
  first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google Groups
  Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send an
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/d/optout.

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


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


Re: clojure.core/Format Bug?

2014-04-08 Thread Sean Corfield
Here's what I see in LT:

https://www.dropbox.com/s/nd1xf00sbdwjpgc/Screenshot%202014-04-08%2014.05.06.png

i.e., the correct, expected behavior - exactly the same as in a regular REPL.

Maybe you have some customization in LT that is causing it? Or perhaps one of 
your plugins?

Sean

On Apr 7, 2014, at 12:47 PM, Paul Umbers paul.umb...@gmail.com wrote:
 I have the same version of LightTable and the binary, using Clojure 1.6.0 and 
 Java 1.7.0_51 under Ubuntu 13.04. I've attached a screenshot of the output I 
 get.
 
 
 
 
 
 On Monday, 7 April 2014 13:08:42 UTC-6, Thomas Hicks wrote:
 If I copy and paste your format s-exp into LT, I see the correct result, 
 displayed correctly. Same for a plain lein repl using Clojure 1.6.0.
 I'm using LightTable 0.6.5, binary 0.8.4. (On OSX 10.8.5 using Java 
 1.7.0_60-ea-b12).
HTH,
   -tom
 
 
 On Sunday, April 6, 2014 2:00:55 PM UTC-7, Paul Umbers wrote:
 Andy, thanks for your help.
 
 I've checked and the displayed result is different only in LightTable. When I 
 execute the format functions from a CLI REPL I get the correct number of 
 characters displayed. I've checked the LT issues and can't see anything that 
 matches, so I'll probably raise it as a Clojure plugin bug.




signature.asc
Description: Message signed with OpenPGP using GPGMail


Re: true lightweight threads on clojurescript?

2014-04-08 Thread t x
I'm guilty of the X-Y problem.


I'm trying to, inside of CLJS, write a simple WebOS.


So I want to simultaneously be able to run things like:
  * a notepad app
  * an IRC app
  * a webRTC video chat app


I have built each of these individual pieces in CLJS, -- but combining
them / having them work well together in a clean, non-spaghetti way is
harder than I thought.



### The main problems here I have are:

  * multi-threading (run all three apps at once) and
  * have is inter-process (in this case app) communication


I'd also prefer to do this in a way where I write each app as if it's
the only app running (i.e. no callback hell.)


One possible approach is to make each app a go-thread, but then I
run into the issue of:

  (go ... (! ... ) (! ... )) all forced into the same lexical function.



I'm looking for alternatives to this. By using:

  settimeout(func, 0); I should be able to fire off 3 threads

  now, if I had something like promises, I can do inter-process communication



I'm still working this through -- so if my thinking is sloppy /
unclear, please point it out so I can make it clearer.


Thanks!

On Tue, Apr 8, 2014 at 2:05 PM, James Reeves ja...@booleanknot.com wrote:
 What exactly are you trying to do? Could you describe the problem you're
 trying to solve in more detail?

 - James


 On 8 April 2014 22:02, t x txrev...@gmail.com wrote:

 I'd really like to avoid callbacks. :-)

 If cljs had promises, it would suffice. :-)

 On Tue, Apr 8, 2014 at 2:00 PM, Gary Trakhman gary.trakh...@gmail.com
 wrote:
  I think you might be able to use put! with a callback, or (go (! ..))
  within foo for a transient go process.  Not sure if there's any ill
  effects.
 
 
  On Tue, Apr 8, 2014 at 4:51 PM, t x txrev...@gmail.com wrote:
 
  Hi,
 
 
* I am aware of core.async. However, I don't like the fact that (go
  ... ) is a macro, thus forcing the ! and ! to appear in the body,
  and I can't do nested things like:
 
(defn foo [chan]
   (let [x (! chan)] ... ))
 
(go ... (foo ... ))
 
 
* For the following, I only need it to work in ClojureScript. I
  don't need it to work in Clojure. Furthermore, we can assume browser =
  latest Firefox, or browser = latest Chrome.
 
 
Now, my question: is there a library which provides true
  lightweight Clojurescript threads?
 
 
  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/d/optout.
 
 
  --
  You received this message because you are subscribed to the Google
  Groups Clojure group.
  To post to this group, send email to clojure@googlegroups.com
  Note that posts from new members are moderated - please be patient with
  your
  first post.
  To unsubscribe from this group, send email to
  clojure+unsubscr...@googlegroups.com
  For more options, visit this group at
  http://groups.google.com/group/clojure?hl=en
  ---
  You received this message because you are subscribed to the Google
  Groups
  Clojure group.
  To unsubscribe from this group and stop receiving emails from it, send
  an
  email to clojure+unsubscr...@googlegroups.com.
  For more options, visit https://groups.google.com/d/optout.

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


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

Real World Example

2014-04-08 Thread Anthony Ortiz
Hello world!

I'm a C# developer who recently went to an interview at a major bank here 
in NYC and found that they've been using Clojure for their business logic 
for over a year already and that got me curious, so I find myself on 
unfamiliar territory learning how to program in a functional language. So 
far so good, Moxley Stratton's online tutorial combined with Try Clojure 
(the online interpreter) has been very helpful (kudos to you guys!) and I'm 
now going through the book 'Programming Clojure'. So far I've seen a lot of 
utility/academic examples such as fibonacci but little in the way of an 
actual real-world example of a top-to-bottom desktop application built 
using Clojure on either the JVM or CLR, something simple that would 
demonstrate how Clojure fits into the event-driven model on the client-side 
behind, let's say, WPF, and how it would interact with more Clojure on the 
service-side via, let's say, WCF. Does anyone know of an example they can 
direct me to?

Many thanks!

Anthony

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


Re: Real World Example

2014-04-08 Thread Sean Corfield
On Apr 8, 2014, at 12:23 PM, Anthony Ortiz anthonypa...@gmail.com wrote:
 I'm now going through the book 'Programming Clojure'. So far I've seen a lot 
 of utility/academic examples such as fibonacci but little in the way of an 
 actual real-world example of a top-to-bottom desktop application built using 
 Clojure on either the JVM or CLR

It's been a while since I read Programming Clojure but my sense is that Clojure 
Programming from O'Reilly (Emerick, Casper, Grand) would give you more of what 
you're looking for, and possibly the 2nd Ed of Clojure in Action from Manning 
(don't buy the 1st Ed - it's very out of date and a lot of the examples won't 
run).

Welcome to Clojure!

We're using Clojure for a lot of our application model at World Singles - an 
Internet dating platform - so we're using it to interact with MySQL, MongoDB, 
third party web services, to do data transformation (mostly to/from XML, JSON), 
and so on. We're also using it for the back end of a chat server (built around 
Netty and a Socket.IO server library).

Happy to answer any questions about real world usage either on or off-list!

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


How do I update a record in a vector, matching certain criteria?

2014-04-08 Thread Ivan Schuetz
I'm trying to update records in a vector, which match certain criteria. 
Record:

(defrecord Item [id name description])


How can I say e.g. set name of element to foo where id is equal 1?

The vector is mutable (ref). I would do

(dosync (commute myVectorRef  ))


Can't figure the 

I found e.g. function 
update-inhttp://clojuredocs.org/clojure_core/clojure.core/update-in

But 1. Can't find examples with records, 2. Not sure if I can use it to 
update a different field than the one I'm using to do the query. In the 
examples fields seem to be the same.


The complete use case: I have a webservice which update operation, where I 
get a map with the id of the item and optional fields which have to be 
updated.

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


Re: How do I update a record in a vector, matching certain criteria?

2014-04-08 Thread Gary Trakhman


 But 1. Can't find examples with records, 2. Not sure if I can use it to
 update a different field than the one I'm using to do the query. In the
 examples fields seem to be the same.



Leave off the last path segment and return the full updated record, not
just the new field's value.

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


Re: How do I update a record in a vector, matching certain criteria?

2014-04-08 Thread Ivan Schuetz
Hi,

sorry I don't get it. I just started learning Clojure.

I did this to remove element with id 1

 (commute items #(remove (fn [x](= (:id x) id)) %))

From your statement I understand update-in would work for the update, but I 
don't know the syntax. Something like

(commute dataprovider/products #(update-in % {:id id}  (-Item ???) ))




Am Mittwoch, 9. April 2014 00:01:00 UTC+2 schrieb Gary Trakhman:


 But 1. Can't find examples with records, 2. Not sure if I can use it to 
 update a different field than the one I'm using to do the query. In the 
 examples fields seem to be the same.



 Leave off the last path segment and return the full updated record, not 
 just the new field's value.


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


Re: How do I update a record in a vector, matching certain criteria?

2014-04-08 Thread Ivan Schuetz
Ahh dataprovider/products should be items. Forgot to simplify.


Am Mittwoch, 9. April 2014 00:12:48 UTC+2 schrieb Ivan Schuetz:

 Hi,

 sorry I don't get it. I just started learning Clojure.

 I did this to remove element with id 1

  (commute items #(remove (fn [x](= (:id x) id)) %))

 From your statement I understand update-in would work for the update, but 
 I don't know the syntax. Something like

 (commute dataprovider/products #(update-in % {:id id}  (-Item ???) ))




 Am Mittwoch, 9. April 2014 00:01:00 UTC+2 schrieb Gary Trakhman:


 But 1. Can't find examples with records, 2. Not sure if I can use it to 
 update a different field than the one I'm using to do the query. In the 
 examples fields seem to be the same.



 Leave off the last path segment and return the full updated record, not 
 just the new field's value.



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


Re: How do I update a record in a vector, matching certain criteria?

2014-04-08 Thread Gary Trakhman
hrm, update-in isn't meant to be used that way.


Here's an example from clojuredocs:

user= (def p {:name James :age 26})
#'user/p

user= (update-in p [:age] inc)
{:name James, :age 27}

;; remember, the value of p hasn't changed!
user= (update-in p [:age] + 10)
{:name James, :age 36}


The second arg is like a 'path' to the value to update.

In your code, here:  (commute items #(remove (fn [x](= (:id x) id)) %))

Seems like % might have started out as a vector, but it gets returned as a
seq.  That's the first thing to fix, seqs don't have keys.

Vectors have integer keys, but my intuition says you probably want to be
storing a map of ids to records, in which case, something like:

(commute items #(update-in % [:id] (fn [my-record]
(do-something-that-returns-a-new-record my-record

and your use of 'remove' could simply be a dissoc by id.




On Tue, Apr 8, 2014 at 6:14 PM, Ivan Schuetz ivanschu...@gmail.com wrote:

 Ahh dataprovider/products should be items. Forgot to simplify.


 Am Mittwoch, 9. April 2014 00:12:48 UTC+2 schrieb Ivan Schuetz:

 Hi,

 sorry I don't get it. I just started learning Clojure.

 I did this to remove element with id 1

  (commute items #(remove (fn [x](= (:id x) id)) %))

 From your statement I understand update-in would work for the update, but
 I don't know the syntax. Something like

 (commute dataprovider/products #(update-in % {:id id}  (-Item ???) ))




 Am Mittwoch, 9. April 2014 00:01:00 UTC+2 schrieb Gary Trakhman:


 But 1. Can't find examples with records, 2. Not sure if I can use it to
 update a different field than the one I'm using to do the query. In the
 examples fields seem to be the same.



 Leave off the last path segment and return the full updated record, not
 just the new field's value.

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


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


Re: How do I update a record in a vector, matching certain criteria?

2014-04-08 Thread Ivan Schuetz
I would use merge to update the record with the map... but I don't know how 
to get it from filter operation. Maybe I should not solve this with 1-liner.

Am Mittwoch, 9. April 2014 00:14:09 UTC+2 schrieb Ivan Schuetz:

 Ahh dataprovider/products should be items. Forgot to simplify.


 Am Mittwoch, 9. April 2014 00:12:48 UTC+2 schrieb Ivan Schuetz:

 Hi,

 sorry I don't get it. I just started learning Clojure.

 I did this to remove element with id 1

  (commute items #(remove (fn [x](= (:id x) id)) %))

 From your statement I understand update-in would work for the update, but 
 I don't know the syntax. Something like

 (commute dataprovider/products #(update-in % {:id id}  (-Item ???) ))




 Am Mittwoch, 9. April 2014 00:01:00 UTC+2 schrieb Gary Trakhman:


 But 1. Can't find examples with records, 2. Not sure if I can use it to 
 update a different field than the one I'm using to do the query. In the 
 examples fields seem to be the same.



 Leave off the last path segment and return the full updated record, not 
 just the new field's value.



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


Re: How do I update a record in a vector, matching certain criteria?

2014-04-08 Thread Gary Trakhman
Maybe this will help:

 (update-in [[] 2 3 4] [0] (constantly 1))
[1 2 3 4]

 (update-in [[] 2 3 4] [2] (constantly 1))
[ [ ] 2 1 4]

 (update-in [[] 2 3 4] [1] (constantly 1))
[ [ ] 1 3 4]

 (update-in [[] 2 3 4] [0 :a] (constantly :b))
java.lang.IllegalArgumentException: Key must be integer

 (update-in [[] 2 3 4] [0 0 :a] (constantly :b))
[ [{:a :b}] 2 3 4]


On Tue, Apr 8, 2014 at 6:22 PM, Ivan Schuetz ivanschu...@gmail.com wrote:

 I would use merge to update the record with the map... but I don't know
 how to get it from filter operation. Maybe I should not solve this with
 1-liner.

 Am Mittwoch, 9. April 2014 00:14:09 UTC+2 schrieb Ivan Schuetz:

 Ahh dataprovider/products should be items. Forgot to simplify.


 Am Mittwoch, 9. April 2014 00:12:48 UTC+2 schrieb Ivan Schuetz:

 Hi,

 sorry I don't get it. I just started learning Clojure.

 I did this to remove element with id 1

  (commute items #(remove (fn [x](= (:id x) id)) %))

 From your statement I understand update-in would work for the update,
 but I don't know the syntax. Something like

 (commute dataprovider/products #(update-in % {:id id}  (-Item ???)
 ))




 Am Mittwoch, 9. April 2014 00:01:00 UTC+2 schrieb Gary Trakhman:


 But 1. Can't find examples with records, 2. Not sure if I can use it
 to update a different field than the one I'm using to do the query. In the
 examples fields seem to be the same.



 Leave off the last path segment and return the full updated record, not
 just the new field's value.

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


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


Re: clojure.core/Format Bug?

2014-04-08 Thread Paul Umbers
Interesting. I just removed my LT installation and any config files I could 
find, then downloaded a new version and used that - no plugins, no changes 
to the configuration - and I still see the truncated string.

On Tuesday, 8 April 2014 15:06:56 UTC-6, Sean Corfield wrote:

 Here's what I see in LT:


 https://www.dropbox.com/s/nd1xf00sbdwjpgc/Screenshot%202014-04-08%2014.05.06.png

 i.e., the correct, expected behavior - exactly the same as in a regular 
 REPL.

 Maybe you have some customization in LT that is causing it? Or perhaps one 
 of your plugins?

 Sean

 On Apr 7, 2014, at 12:47 PM, Paul Umbers paul@gmail.com javascript: 
 wrote:

 I have the same version of LightTable and the binary, using Clojure 1.6.0 
 and Java 1.7.0_51 under Ubuntu 13.04. I've attached a screenshot of the 
 output I get.


 https://lh3.googleusercontent.com/-mgB1TlVMuFo/U0MAd4QY5zI/AYs/rdoFevrnSe4/s1600/Screenshot+from+2014-04-07+13%3A43%3A59.png


 On Monday, 7 April 2014 13:08:42 UTC-6, Thomas Hicks wrote:

 If I copy and paste your format s-exp into LT, I see the correct result, 
 displayed correctly. Same for a plain lein repl using Clojure 1.6.0.
 I'm using LightTable 0.6.5, binary 0.8.4. (On OSX 10.8.5 using 
 Java 1.7.0_60-ea-b12).
HTH,
   -tom


 On Sunday, April 6, 2014 2:00:55 PM UTC-7, Paul Umbers wrote:

 Andy, thanks for your help.

 I've checked and the displayed result is different only in LightTable. 
 When I execute the format functions from a CLI REPL I get the correct 
 number of characters displayed. I've checked the LT issues and can't see 
 anything that matches, so I'll probably raise it as a Clojure plugin bug.





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


Re: How do I update a record in a vector, matching certain criteria?

2014-04-08 Thread Gary Trakhman
My response had the assumption that this is an example of an X-Y problem
:-).

If you want to literally do what you said, then you can't use update-in
because the value at that point is a seq.

If you have to continue in this way, for some reason, what you probably
want is map-indexed, which provides the index of the element as one of the
parameters to the mapping function.

You could use a helper to build a function that only operates on that
particular element.

I caution that you might run into a stackoverflow due to laziness if you do
this enough without realizing the seq.

This just feels unidiomatic to me, though.





On Tue, Apr 8, 2014 at 7:10 PM, Ivan Schuetz ivanschu...@gmail.com wrote:

 As I said I already looked in the docs, and know these basic examples, but
 I don't know how to do:

 *How can I say in a vector of records e.g. set name of element to foo
 where id is equal 1?*


 The remove by Id works, I posted it only to show something which might be
 similar to the update I'm looking for.

 I also wrote filter:

 (nth (filtered (filter #(= (:id %) id) @dataprovider/products)) 0)

 This gives me the element I need to update, but I still don't know how I
 update this element in the vector.



 Am Mittwoch, 9. April 2014 00:27:41 UTC+2 schrieb Gary Trakhman:

 Maybe this will help:

  (update-in [[] 2 3 4] [0] (constantly 1))
 [1 2 3 4]

  (update-in [[] 2 3 4] [2] (constantly 1))
 [ [ ] 2 1 4]

  (update-in [[] 2 3 4] [1] (constantly 1))
 [ [ ] 1 3 4]

  (update-in [[] 2 3 4] [0 :a] (constantly :b))
 java.lang.IllegalArgumentException: Key must be integer

  (update-in [[] 2 3 4] [0 0 :a] (constantly :b))
 [ [{:a :b}] 2 3 4]


 On Tue, Apr 8, 2014 at 6:22 PM, Ivan Schuetz ivans...@gmail.com wrote:

 I would use merge to update the record with the map... but I don't know
 how to get it from filter operation. Maybe I should not solve this with
 1-liner.

 Am Mittwoch, 9. April 2014 00:14:09 UTC+2 schrieb Ivan Schuetz:

 Ahh dataprovider/products should be items. Forgot to simplify.


 Am Mittwoch, 9. April 2014 00:12:48 UTC+2 schrieb Ivan Schuetz:

 Hi,

 sorry I don't get it. I just started learning Clojure.

 I did this to remove element with id 1

  (commute items #(remove (fn [x](= (:id x) id)) %))

 From your statement I understand update-in would work for the update,
 but I don't know the syntax. Something like

 (commute dataprovider/products #(update-in % {:id id}  (-Item
 ???) ))




 Am Mittwoch, 9. April 2014 00:01:00 UTC+2 schrieb Gary Trakhman:


 But 1. Can't find examples with records, 2. Not sure if I can use it
 to update a different field than the one I'm using to do the query. In 
 the
 examples fields seem to be the same.



 Leave off the last path segment and return the full updated record,
 not just the new field's value.

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

 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

 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.

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


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


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


Re: How do I update a record in a vector, matching certain criteria?

2014-04-08 Thread Gary Trakhman
Alternatively, you could sprinkle (into [] ..) to feed the result of
remove/filter back into a vector.


On Tue, Apr 8, 2014 at 7:16 PM, Gary Trakhman gary.trakh...@gmail.comwrote:

 My response had the assumption that this is an example of an X-Y problem
 :-).

 If you want to literally do what you said, then you can't use update-in
 because the value at that point is a seq.

 If you have to continue in this way, for some reason, what you probably
 want is map-indexed, which provides the index of the element as one of the
 parameters to the mapping function.

 You could use a helper to build a function that only operates on that
 particular element.

 I caution that you might run into a stackoverflow due to laziness if you
 do this enough without realizing the seq.

 This just feels unidiomatic to me, though.





 On Tue, Apr 8, 2014 at 7:10 PM, Ivan Schuetz ivanschu...@gmail.comwrote:

 As I said I already looked in the docs, and know these basic examples,
 but I don't know how to do:

 *How can I say in a vector of records e.g. set name of element to foo
 where id is equal 1?*


 The remove by Id works, I posted it only to show something which might be
 similar to the update I'm looking for.

 I also wrote filter:

 (nth (filtered (filter #(= (:id %) id) @dataprovider/products)) 0)

 This gives me the element I need to update, but I still don't know how I
 update this element in the vector.



 Am Mittwoch, 9. April 2014 00:27:41 UTC+2 schrieb Gary Trakhman:

 Maybe this will help:

  (update-in [[] 2 3 4] [0] (constantly 1))
 [1 2 3 4]

  (update-in [[] 2 3 4] [2] (constantly 1))
 [ [ ] 2 1 4]

  (update-in [[] 2 3 4] [1] (constantly 1))
 [ [ ] 1 3 4]

  (update-in [[] 2 3 4] [0 :a] (constantly :b))
 java.lang.IllegalArgumentException: Key must be integer

  (update-in [[] 2 3 4] [0 0 :a] (constantly :b))
 [ [{:a :b}] 2 3 4]


 On Tue, Apr 8, 2014 at 6:22 PM, Ivan Schuetz ivans...@gmail.com wrote:

 I would use merge to update the record with the map... but I don't know
 how to get it from filter operation. Maybe I should not solve this with
 1-liner.

 Am Mittwoch, 9. April 2014 00:14:09 UTC+2 schrieb Ivan Schuetz:

 Ahh dataprovider/products should be items. Forgot to simplify.


 Am Mittwoch, 9. April 2014 00:12:48 UTC+2 schrieb Ivan Schuetz:

 Hi,

 sorry I don't get it. I just started learning Clojure.

 I did this to remove element with id 1

  (commute items #(remove (fn [x](= (:id x) id)) %))

 From your statement I understand update-in would work for the update,
 but I don't know the syntax. Something like

 (commute dataprovider/products #(update-in % {:id id}  (-Item
 ???) ))




 Am Mittwoch, 9. April 2014 00:01:00 UTC+2 schrieb Gary Trakhman:


 But 1. Can't find examples with records, 2. Not sure if I can use
 it to update a different field than the one I'm using to do the query. 
 In
 the examples fields seem to be the same.



 Leave off the last path segment and return the full updated record,
 not just the new field's value.

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

 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

 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.

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


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




-- 
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 do I update a record in a vector, matching certain criteria?

2014-04-08 Thread Gary Trakhman
Ah, actually, there's one mistake in my responses, you want to change out
the element based on id, not index, in which case I'd simply recommend map
or mapv.  Just remember anytime you change one thing you have to iterate
over the whole vector, worst-case, O(n).

If you use a map of :id to record, updates are O(log32 n), which is much
better.


On Tue, Apr 8, 2014 at 7:18 PM, Gary Trakhman gary.trakh...@gmail.comwrote:

 Alternatively, you could sprinkle (into [] ..) to feed the result of
 remove/filter back into a vector.


 On Tue, Apr 8, 2014 at 7:16 PM, Gary Trakhman gary.trakh...@gmail.comwrote:

 My response had the assumption that this is an example of an X-Y problem
 :-).

 If you want to literally do what you said, then you can't use update-in
 because the value at that point is a seq.

 If you have to continue in this way, for some reason, what you probably
 want is map-indexed, which provides the index of the element as one of the
 parameters to the mapping function.

 You could use a helper to build a function that only operates on that
 particular element.

 I caution that you might run into a stackoverflow due to laziness if you
 do this enough without realizing the seq.

 This just feels unidiomatic to me, though.





 On Tue, Apr 8, 2014 at 7:10 PM, Ivan Schuetz ivanschu...@gmail.comwrote:

 As I said I already looked in the docs, and know these basic examples,
 but I don't know how to do:

 *How can I say in a vector of records e.g. set name of element to
 foo where id is equal 1?*


 The remove by Id works, I posted it only to show something which might
 be similar to the update I'm looking for.

 I also wrote filter:

 (nth (filtered (filter #(= (:id %) id) @dataprovider/products)) 0)

 This gives me the element I need to update, but I still don't know how I
 update this element in the vector.



 Am Mittwoch, 9. April 2014 00:27:41 UTC+2 schrieb Gary Trakhman:

 Maybe this will help:

  (update-in [[] 2 3 4] [0] (constantly 1))
 [1 2 3 4]

  (update-in [[] 2 3 4] [2] (constantly 1))
 [ [ ] 2 1 4]

  (update-in [[] 2 3 4] [1] (constantly 1))
 [ [ ] 1 3 4]

  (update-in [[] 2 3 4] [0 :a] (constantly :b))
 java.lang.IllegalArgumentException: Key must be integer

  (update-in [[] 2 3 4] [0 0 :a] (constantly :b))
 [ [{:a :b}] 2 3 4]


 On Tue, Apr 8, 2014 at 6:22 PM, Ivan Schuetz ivans...@gmail.comwrote:

 I would use merge to update the record with the map... but I don't
 know how to get it from filter operation. Maybe I should not solve this
 with 1-liner.

 Am Mittwoch, 9. April 2014 00:14:09 UTC+2 schrieb Ivan Schuetz:

 Ahh dataprovider/products should be items. Forgot to simplify.


 Am Mittwoch, 9. April 2014 00:12:48 UTC+2 schrieb Ivan Schuetz:

 Hi,

 sorry I don't get it. I just started learning Clojure.

 I did this to remove element with id 1

  (commute items #(remove (fn [x](= (:id x) id)) %))

 From your statement I understand update-in would work for the
 update, but I don't know the syntax. Something like

 (commute dataprovider/products #(update-in % {:id id}  (-Item
 ???) ))




 Am Mittwoch, 9. April 2014 00:01:00 UTC+2 schrieb Gary Trakhman:


 But 1. Can't find examples with records, 2. Not sure if I can use
 it to update a different field than the one I'm using to do the 
 query. In
 the examples fields seem to be the same.



 Leave off the last path segment and return the full updated record,
 not just the new field's value.

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

 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

 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.

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


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





-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that 

Re: How do I update a record in a vector, matching certain criteria?

2014-04-08 Thread Leif
Hi, Ivan.

(defn set-item-name [data id newname]
  (mapv #(if (not= (:id %) id)  ; - NB mapv keeps it a vector 
% ; no-op
 (assoc % :name newname))
data))

(dosync (commute items set-item-name 1 foo))

This really only makes sense if :id is *not* actually a primary key in your 
data, 

If, however, :id *is* a primary key, and most of the operations on the data 
are only updating one element, you will want to follow Gary's advice and 
change your data to

{1 {:id 1 :name ...}
 2 {:id 2 :name ...}
 ...}

I would also like to validate your feeling that this shouldn't be a 
one-liner; you can generalize 'set-item-name', and then if you do want to 
change the data structure later, you only have to change the general 
function.

--Leif

On Tuesday, April 8, 2014 7:10:13 PM UTC-4, Ivan Schuetz wrote:

 As I said I already looked in the docs, and know these basic examples, but 
 I don't know how to do:

 *How can I say in a vector of records e.g. set name of element to foo 
 where id is equal 1?*


 The remove by Id works, I posted it only to show something which might be 
 similar to the update I'm looking for.

 I also wrote filter:

 (nth (filtered (filter #(= (:id %) id) @dataprovider/products)) 0)

 This gives me the element I need to update, but I still don't know how I 
 update this element in the vector.



 Am Mittwoch, 9. April 2014 00:27:41 UTC+2 schrieb Gary Trakhman:

 Maybe this will help:

  (update-in [[] 2 3 4] [0] (constantly 1))
 [1 2 3 4]

  (update-in [[] 2 3 4] [2] (constantly 1))
 [ [ ] 2 1 4]

  (update-in [[] 2 3 4] [1] (constantly 1))
 [ [ ] 1 3 4]

  (update-in [[] 2 3 4] [0 :a] (constantly :b))
 java.lang.IllegalArgumentException: Key must be integer

  (update-in [[] 2 3 4] [0 0 :a] (constantly :b))
 [ [{:a :b}] 2 3 4]


 On Tue, Apr 8, 2014 at 6:22 PM, Ivan Schuetz ivans...@gmail.com wrote:

 I would use merge to update the record with the map... but I don't know 
 how to get it from filter operation. Maybe I should not solve this with 
 1-liner.

 Am Mittwoch, 9. April 2014 00:14:09 UTC+2 schrieb Ivan Schuetz:

 Ahh dataprovider/products should be items. Forgot to simplify.


 Am Mittwoch, 9. April 2014 00:12:48 UTC+2 schrieb Ivan Schuetz:

 Hi,

 sorry I don't get it. I just started learning Clojure.

 I did this to remove element with id 1

  (commute items #(remove (fn [x](= (:id x) id)) %))

 From your statement I understand update-in would work for the update, 
 but I don't know the syntax. Something like

 (commute dataprovider/products #(update-in % {:id id}  (-Item 
 ???) ))




 Am Mittwoch, 9. April 2014 00:01:00 UTC+2 schrieb Gary Trakhman:


 But 1. Can't find examples with records, 2. Not sure if I can use it 
 to update a different field than the one I'm using to do the query. In 
 the 
 examples fields seem to be the same.



 Leave off the last path segment and return the full updated record, 
 not just the new field's value.

  -- 
 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
 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
 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.
 For more options, visit https://groups.google.com/d/optout.




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


[ANN] CongoMongo 0.4.3 released!

2014-04-08 Thread Sean Corfield
Clojure wrapper for the mongo-db java api

https://github.com/aboekhoff/congomongo

New in this release:

• change default Clojure version from 1.5.1 to 1.6.0 (we still support 
back to 1.3.0)
• update Java driver to 2.12.0 to support MongoDB 2.6.0
• support :write-concern on mass-insert!

One side effect of these updates is that mass-insert! should now be much faster 
than multiple individual insert! calls, due to performance improvements in the 
Java driver when used with the latest MongoDB.

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: true lightweight threads on clojurescript?

2014-04-08 Thread Timothy Baldridge
What is going to fulfill a promise? How will you know when a promise is
fulfilled. In a single threaded VM like JS you're stuck with callbacks.
Nothing short of full program transformation will give you any better
experience than core.async.

A good way to look at it is this...if you do this in ClojureScript what
javascript is this supposed to execute?

(deref (promise))

The only way this can work is with a code transform like go. Perhaps
someday a new version of JS will arise that presents a different solution,
but until then core.async is the best you're going to get.

Timothy


On Tue, Apr 8, 2014 at 3:11 PM, t x txrev...@gmail.com wrote:

 I'm guilty of the X-Y problem.


 I'm trying to, inside of CLJS, write a simple WebOS.


 So I want to simultaneously be able to run things like:
   * a notepad app
   * an IRC app
   * a webRTC video chat app


 I have built each of these individual pieces in CLJS, -- but combining
 them / having them work well together in a clean, non-spaghetti way is
 harder than I thought.



 ### The main problems here I have are:

   * multi-threading (run all three apps at once) and
   * have is inter-process (in this case app) communication


 I'd also prefer to do this in a way where I write each app as if it's
 the only app running (i.e. no callback hell.)


 One possible approach is to make each app a go-thread, but then I
 run into the issue of:

   (go ... (! ... ) (! ... )) all forced into the same lexical function.



 I'm looking for alternatives to this. By using:

   settimeout(func, 0); I should be able to fire off 3 threads

   now, if I had something like promises, I can do inter-process
 communication



 I'm still working this through -- so if my thinking is sloppy /
 unclear, please point it out so I can make it clearer.


 Thanks!

 On Tue, Apr 8, 2014 at 2:05 PM, James Reeves ja...@booleanknot.com
 wrote:
  What exactly are you trying to do? Could you describe the problem you're
  trying to solve in more detail?
 
  - James
 
 
  On 8 April 2014 22:02, t x txrev...@gmail.com wrote:
 
  I'd really like to avoid callbacks. :-)
 
  If cljs had promises, it would suffice. :-)
 
  On Tue, Apr 8, 2014 at 2:00 PM, Gary Trakhman gary.trakh...@gmail.com
  wrote:
   I think you might be able to use put! with a callback, or (go (! ..))
   within foo for a transient go process.  Not sure if there's any ill
   effects.
  
  
   On Tue, Apr 8, 2014 at 4:51 PM, t x txrev...@gmail.com wrote:
  
   Hi,
  
  
 * I am aware of core.async. However, I don't like the fact that (go
   ... ) is a macro, thus forcing the ! and ! to appear in the body,
   and I can't do nested things like:
  
 (defn foo [chan]
(let [x (! chan)] ... ))
  
 (go ... (foo ... ))
  
  
 * For the following, I only need it to work in ClojureScript. I
   don't need it to work in Clojure. Furthermore, we can assume browser
 =
   latest Firefox, or browser = latest Chrome.
  
  
 Now, my question: is there a library which provides true
   lightweight Clojurescript threads?
  
  
   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/d/optout.
  
  
   --
   You received this message because you are subscribed to the Google
   Groups Clojure group.
   To post to this group, send email to clojure@googlegroups.com
   Note that posts from new members are moderated - please be patient
 with
   your
   first post.
   To unsubscribe from this group, send email to
   clojure+unsubscr...@googlegroups.com
   For more options, visit this group at
   http://groups.google.com/group/clojure?hl=en
   ---
   You received this message because you are subscribed to the Google
   Groups
   Clojure group.
   To unsubscribe from this group and stop receiving emails from it, send
   an
   email to clojure+unsubscr...@googlegroups.com.
   For more options, visit https://groups.google.com/d/optout.
 
  --
  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
  ---
  

A thought on Om/React

2014-04-08 Thread Dave Sann
I haven't built anything with OM or react as yet. But I have read about it 
and I like the model in principle.

A thought which repeatedly pops into my mind when I read about this is - 
ok, react in written in js. which is great for the web. What would happen 
if it were written in Clojure and available on server (As well as client (I 
am not thinking nodejs here).

Going on slightly, it might be possible to 

1. have a generally useful delta calculation - for this sort of use.
2. have a DOM structure and event model that could be mapped/bridged to 
swing or javafx or other.
3. have different UI models other than DOM that could be mapped to DOM or 
swing of javafx or other.

I have no plans to do anything with this currently - but am interested in 
peoples thoughts.

Dave

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


Re: cljsbuild dev/release, different debug levels

2014-04-08 Thread Tatu Tarvainen

I had the same issue and solved it by having 3 source paths:
- src (containing the app)
- src-dev (containing the dev version of the logging ns)
- src-prod (containing the production version of the logging ns)

cljsbuild development builds use source paths [src src-dev] and 
production builds use [src src-prod]

Seems to work ok. Added benefit of forcing you to put all the varying 
pieces in their own namespaces.
Currently I only have the one log.cljs with a logging function in both 
src-dev and src-prod (with dev version being console.log and prod version 
being a dummy that does nothing).

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