Re: Possible to add dependency within leiningen plugin dynamically?

2013-07-11 Thread Shantanu Kumar


On Thursday, 11 July 2013 12:24:34 UTC+5:30, Chris Kuttruff wrote:
>
> Eg: 
>
> I have a leiningen plugin I'm building that calls some jdbc stuff, but the 
> specific driver would be specified in the project that brings in my plugin 
> as a dependency.
>

Can you describe your use case with an example maybe? I am not sure if it's 
similar to what you want, but some time back I wrote a plugin called 
lein-servlet that can fetch a user-specified dependency (in project.clj) 
from Clojars. Checking out the sample project.clj is pretty easy -- run the 
following at command line:

$ lein new lein-servlet foo
$ cd foo
$ lein servlet run  # Ctrl+C to stop
$ # see the project.clj that uses Jetty by default

The plugin is here:

https://github.com/kumarshantanu/lein-servlet

Shantanu

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




Re: Possible to add dependency within leiningen plugin dynamically?

2013-07-11 Thread Chris Kuttruff
Shantanu, thanks for the reply; yes, that definitely seems like a similar 
situation.  I will take a close look at that code tomorrow.

Here is the example that you requested:
Entry point for the plugin:
https://github.com/ckuttruff/clj-sql-up/blob/master/src/leiningen/clj_sql_up.clj

Function that is called:
https://github.com/ckuttruff/clj-sql-up/blob/master/src/clj_sql_up/migrate.clj

Example project.clj that uses the plugin:
(defproject foo "0.1.0"
  :plugins [[clj-sql-up "0.1.0"]]
  :clj-sql-up {:database "jdbc:postgresql://localhost:5432/slackz?slackz"})

Leiningen call:
lein clj-sql-up migrate

** Note: I know there are some existing tools to manage db migrations, but 
I'm developing this in large part to learn more about leiningen / writing 
plugins.

Thanks again,
-Chris


On Thursday, July 11, 2013 12:19:03 AM UTC-7, Shantanu Kumar wrote:
>
>
>
> On Thursday, 11 July 2013 12:24:34 UTC+5:30, Chris Kuttruff wrote:
>>
>> Eg: 
>>
>> I have a leiningen plugin I'm building that calls some jdbc stuff, but 
>> the specific driver would be specified in the project that brings in my 
>> plugin as a dependency.
>>
>
> Can you describe your use case with an example maybe? I am not sure if 
> it's similar to what you want, but some time back I wrote a plugin called 
> lein-servlet that can fetch a user-specified dependency (in project.clj) 
> from Clojars. Checking out the sample project.clj is pretty easy -- run the 
> following at command line:
>
> $ lein new lein-servlet foo
> $ cd foo
> $ lein servlet run  # Ctrl+C to stop
> $ # see the project.clj that uses Jetty by default
>
> The plugin is here:
>
> https://github.com/kumarshantanu/lein-servlet
>
> Shantanu
>

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




Re: core.async pub/sub

2013-07-11 Thread Thomas Heller
Hey,

the lab stuff looks very interesting, I however couldn't quite figure out 
how to "unsubscribe" one channel from the broadcast since I cannot exchange 
the "topic" for every subscriber when one subscriber decides to leave. Its 
also a lot lower level than I'm currently comfortable with since I haven't 
checked out any of the core.async internals yet.

However I wrote my own little pubsub utilities which (almost) only use the 
public API.

(def my-topic (pubsub/topic 100))
 
(pubsub/subscribe-go
 [subscription my-topic (sliding-buffer 100)]
 (loop []
   (when-let [ev (https://gist.github.com/thheller/5973825

subscribe-go is a convenience macro which allows to subscribe to multiple 
topics and is a normal go block, so same rules apply and you may take! from 
any other channel as well. When the block ends the subscription is 
automatically removed, otherwise a subscription is removed by closing it.

Could be optimized but it seems to work fine for me.

Will follow the lab.clj when I'm ready to get dirty with the internals. ;) 

Cheers,
/thomas

On Wednesday, July 10, 2013 12:27:59 PM UTC+2, Alex Miller wrote:
>
> There is a broadcast fn in the lab namespace (
> https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async/lab.clj)
>  
> that does this and I believe David Nolen has created a different variant in 
> some of his stuff. The lab one is experimental and would welcome feedback 
> on it.
>
> Alex
>
> On Tuesday, July 9, 2013 6:46:21 PM UTC-5, Thomas Heller wrote:
>>
>> Hey,
>>
>> I'm doing some core.async tests and want to create a basic pub/sub model. 
>> Messages are >! on one channel and >! to many others.
>>
>> (deftest ^:wip async-test2
>>  
>>   (let [subscribers (atom [])
>> events (chan 100)]
>>  
>> (go (loop []
>>   (when-let [ev (> (doseq [c @subscribers]
>>   (alt!
>>[[c ev]] :sent
>>:default nil ;; could "force" unsubscribe c?
>>))
>> (recur
>>  
>> (let [s1 (chan 1)
>>   s2 (chan 100)
>> r1 (atom [])
>>   r2 (atom [])]
>> (swap! subscribers conj s1 s2)
>> ;; simulated slow reader
>>   (go (loop []
>> (when-let [ev (>   (swap! r1 conj ev)
>>   (>   (recur 
>> ;; good reader
>>   (go (loop []
>> (when-let [ev (>   (swap! r2 conj ev)
>>   (recur
>> (>  (when (< i 100)
>>(>! events i)
>>(recur (inc i))
>>  
>>   (close! events)
>> (Thread/sleep 25)
>> (pprint @r1)
>>   (pprint @r2))
>> ))
>>
>>
>> In this example the s1 subscriber will loose almost all messages since he 
>> cannot keep up (and buffer is too small). I choose to alt!/:default to drop 
>> messages, since I don't want any subscriber to block others. How do you 
>> guys deal with slow-readers?
>>
>> I don't really have a specific problem but I wonder if there are any 
>> plans for some built-in pub/sub mechanisms for core.async. Seems like a 
>> very common pattern.
>>
>> Anyways, core.async is nice!
>>
>> Cheers,
>> /thomas
>>
>>
>>

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




Re: java.jdbc - (sql/where ...) with multiple values (i.e. 'x in (1,2,3')

2013-07-11 Thread Max Penet
Honeysql is nice but it only supports select statements FYI.

That said it's probably easy to extend, but my point is that it's far from 
complete, so I am not sure it's a good recommendation at the moment. 

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




Re: cljx 0.3.0 released

2013-07-11 Thread Thomas Heller
This is awesome, thanks a ton. Solved all the issues I had with 0.2

Cheers,
/thomas

On Wednesday, July 10, 2013 8:26:03 PM UTC+2, Chas Emerick wrote:
> Earlier today, we released [com.keminglabs/cljx "0.3.0"], which brings a 
> bunch of significant changes and improvements:
> 
> 
> 
>   https://github.com/lynaghk/cljx
> 
> 
> 
> Existing users should review the changelog entry, as this is a breaking 
> release:
> 
> 
> 
>   https://github.com/lynaghk/cljx/blob/master/CHANGES.md
> 
> 
> 
> cljx is a way to statically rewrite Clojure (or ClojureScript) to be portable 
> to ClojureScript (or Clojure).  This means that you can target both languages 
> with a single codebase.  To do this, you write code in .cljx files, and use 
> annotations to elide language/runtime-specific forms from the output intended 
> for different targets.  There's better examples in the README (and some 
> handful of projects using cljx out in the wild, like 
> https://github.com/cemerick/pprng), but you should get the flavour from this 
> snippet:
> 
> 
> 
> (defn x
> 
>   []
> 
>   (throw (#+clj Exception. #+cljs js/Error. "WTF")))
> 
> 
> 
> cljx will produce two files from this input: a .clj file containing the 
> `Exception.` symbol but not the `js/Error.` symbol, and a .cljs file 
> containing the inverse.  In short, cljx is an s-expression preprocessor 
> (intentionally very limited — this is all you really need to write practical, 
> portable Clojure[Script]).
> 
> 
> 
> Thanks to Kevin Lynagh for cutting releases and allowing me to play in his 
> sandbox, and all the others noted in the README that inspired or helped in 
> the effort.
> 
> 
> 
> Happy Clojure[Script]-ing!
> 
> 
> 
> - Chas

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




Re: vectorz doesn't handle scalars?

2013-07-11 Thread Mikera
OK thanks Brian - I've managed to reproduce it with this config. 

I'll figure out a fix and do a new release in the next couple of hours.

On Thursday, 11 July 2013 01:52:16 UTC+1, Brian Craft wrote:
>
> [org.clojure/clojure "1.5.1"]
> [net.mikera/core.matrix "0.8.0"]
> [net.mikera/vectorz-clj "0.10.0"]
>
>
> On Wednesday, July 10, 2013 5:40:41 PM UTC-7, Mikera wrote:
>>
>> Hmmm it seems to work for me:
>>
>> (+ 5 (matrix [1 2 3]))
>> => #
>>
>> What environment and what versions of vectorz-clj / Clojure are you 
>> using? Some of the older versions didn't support scalar to vector 
>> broadcasting so that might be the problem
>>
>> On Thursday, 11 July 2013 00:44:46 UTC+1, Brian Craft wrote:
>>>
>>> Without vectorz:
>>>
>>> => (+ 5 (matrix [1 2 3]))
>>> [6 7 8]
>>>
>>> With vectorz:
>>>
>>> => (+ 5 (matrix [1 2 3]))
>>> ClassCastException java.lang.Double cannot be cast to 
>>> mikera.arrayz.INDArray  mikera.vectorz.matrix-api/eval12140/fn--12145 
>>> (matrix_api.clj:644)
>>>
>>>
>>>
>>>

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




Re: Documentation / usage --- Array vs. Vector

2013-07-11 Thread Mikera
This is a heavily overloaded naming space - especially when you consider 
code.matrix as well, and usage of these words in mathematical / scientific 
communities. 

Data scientists generally expect a "vector" to be a 1D collection of 
numeric values, in the same sense that a "matrix" is a 2D collection of 
numeric values. Sometimes "array" is also used as a generalisation of this 
to mean N-Dimensional arrays (tensors and suchlike), e.g. in NumPy.

I would avoid using "array" when you mean a Clojure Persistent Vector. 
"array" is most likely referring to the host platform array type.

Whenever there is a potential for confusion, I always find it is helpful to 
add an extra word to resolve the ambiguity, e.g.
- 1D vector / 2D matrix / ND array - when talking about scientific / 
mathematical arrays (typically in a core.matrix context)
- Persistent Vector / Clojure Vector - when talking about a Clojure 
persistent vector data structure
- Java Vector - when talking about the old java.util.Vector (not that 
anyone should be using it nowadays, but still it's there)
- Java array - when talking about an Object[], double[] etc. (this seems to 
be the convention in Clojure docstrings for aget, alength etc.)

Hope that adds some clarity

On Thursday, 11 July 2013 02:48:38 UTC+1, vra...@gmail.com wrote:
>
> I see that Lists and Vectors are similar, but have different uses and for 
> logical reasons. My question may be more about language of datatypes in 
> Clojure than usage.
>
> Is it appropriate to use the term Array and Vector interchangeably when 
> writing documentation about Clojure/EDN for non-Clojure programmers? (1-- 
> "Vector" can be a difficult concept to "map" in English without context, 
> for instance: "so it's a direction as well as a value?") (2-- Map (Clojure) 
> / Dict (Python) / Tuple (Python) / Object (JavaScript) / Hash (Ruby), 
> there's probably no resolution there.)
>
> I'm hesitant to use the word Array interchangeably with Vector in 
> technical specs since Array occurs in Clojure at least as array-map and 
> to-array, which aren't the same as a Vector. On the other hand, "Array" 
> would seem especially interchangeable in documentation when talking about 
> Clojure in context of ClojureScript, but descriptive language about Clojure 
> should probably stay consistent regardless of the hosting programming 
> language.
>
>

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




Group words by their first letter and sum their frequencies

2013-07-11 Thread James Trunk
Hi everyone, I'm new to Clojure and trying to learn my way around the 
language.

I've written a function that sums the frequencies of words starting with 
the same letter, however I'm not fully satisfied with the result. I'm 
striving for readability and idomaticity, but I fear that my rather limited 
grasp of Clojure's core functions and lack of experience with functional 
programming are letting me down on both counts.

(def text (slurp "http://www.ccel.org/ccel/bible/kjv.txt";))

(defn sum-last-elements [coll]
  (reduce + (map last coll)))

(defn group-first-elements [coll]
  (map first coll))

(->> text
 (re-seq 
#"(?:(?:\bm[a|e]n\b)|(?:\bwom[a|e]n\b)|(?:\bchild\b)|(?:\bchildren\b))")
 frequencies
 (group-by ffirst)
 vals
 (#(zipmap (map group-first-elements %) (map sum-last-elements %

Which on that file gives the result:

{("woman" "women") 663, ("children" "child") 2274, ("men" "man") 5314}

My questions:

   1. Is there a way to avoid using ?: everywhere in the regex?
   2. (group-by ffirst) vals - is there a more 
   readable/declarative/idiomatic way to group by first letter?
   3. Is there a trick to avoid the ugly looking anonymous function (which 
   I'm only using to reorder the thread-last argument)?
   4. Is it idiomatic to extract small functions to give them names (with 
   an eye to aiding readability) or would most Clojure programmers prefer 
   these to be anonymous and in-line?
   5. Is thread-last the right approach when dealing with nested 
   data-structures or is list comprehension, or some other approach preferred?

Thanks in advance for any help.

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




Stack overflow deep in repl printer

2013-07-11 Thread David Goldfarb
The following pathological case triggers a confusing stack overflow error.

*$ lein repl*
*...*
*user=> (def x (atom nil))*
*#'user/x*
*user=> (reset! x x)*
*
*
*StackOverflowError   java.util.regex.Pattern$Curly.match 
(Pattern.java:4125)*
*
*
*;;; Of course, I can avoid the problem:*
*user=> (set! *print-level* 3)*
*3*
*user=> (reset! x x)*
*#>>*



Would it be reasonable for the repl to wrap a safe *print-level* and 
*print-length* around the printing?  100, or even 500, would probably never 
stack-overflow, and would be more reasonable behavior for most users.

Even if this is not reasonable in general, perhaps it would still make 
sense around the printing of any "#< ...>" entity, where the internal text 
is always just for human consumption.


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




Re: Stack overflow deep in repl printer

2013-07-11 Thread Meikel Brandmeyer (kotarak)
David,

I wouldn't automatically set any values around the printing. The user 
should be free to do what he likes.

But the repl could start out with some sane defaults, which are not 
limiting in the usual case, but safe in general. Like 50 for the level and 
1000 for the length. Then you are not caught by the infitinite recursion, 
but still can override the default should the need arise.

Meikel

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




core.async: communicating termination

2013-07-11 Thread vemv
Consider a happy, oblivious producer of values:

(def c (chan 42))

(go (while true (>! c (rand

It doesn't know where/now the channel is consumed (which part of the point 
of channels/queues). However, we *do* know that at some point, nobody will 
need the result of our producing, so we should stop our activity.

It seems to me that a natural way to tell the producer to stop is to close 
the channel. However:

* there's nothing like a clojure.core.async/chan-closed? fn, AFAICT
* The >! fn unconditionally returns nil, whether the channel is open or 
not. Only the blocking nature of the call can potentially vary - which is 
not particularly useful for the purpose.

What would be an adequate way to indicate termination? Just telling the 
producer to stop (e.g. (reset! keep-producing false)) would break the 
indirection one gains by using channels.

What if >! returned true/false depending on whether the value was put 
(because the channel was open)?

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




Re: Group words by their first letter and sum their frequencies

2013-07-11 Thread Laurent PETIT
Hello James,

2013/7/11 James Trunk :
> Hi everyone, I'm new to Clojure and trying to learn my way around the
> language.
>
> I've written a function that sums the frequencies of words starting with the
> same letter, however I'm not fully satisfied with the result. I'm striving
> for readability and idomaticity, but I fear that my rather limited grasp of
> Clojure's core functions and lack of experience with functional programming
> are letting me down on both counts.
>
> (def text (slurp "http://www.ccel.org/ccel/bible/kjv.txt";))
>
> (defn sum-last-elements [coll]
>   (reduce + (map last coll)))
>
> (defn group-first-elements [coll]
>   (map first coll))
>
> (->> text
>  (re-seq
> #"(?:(?:\bm[a|e]n\b)|(?:\bwom[a|e]n\b)|(?:\bchild\b)|(?:\bchildren\b))")
>  frequencies
>  (group-by ffirst)
>  vals
>  (#(zipmap (map group-first-elements %) (map sum-last-elements %
>
> Which on that file gives the result:
>
> {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 5314}
>
> My questions:
>
> Is there a way to avoid using ?: everywhere in the regex?
> (group-by ffirst) vals - is there a more readable/declarative/idiomatic way
> to group by first letter?

you could first (group-by first), then create the final map by calling
(distinct) and count

> Is there a trick to avoid the ugly looking anonymous function (which I'm
> only using to reorder the thread-last argument)?

You could use the new as-> macro in clojure 1.5

> Is it idiomatic to extract small functions to give them names (with an eye
> to aiding readability) or would most Clojure programmers prefer these to be
> anonymous and in-line?

depends :-) since your 2 fns are helper fns rather than
generically-reusable fns, I would make them private to enforce that :
(defn- ...)

> Is thread-last the right approach when dealing with nested data-structures
> or is list comprehension, or some other approach preferred?

The thread-last as you employed it is fine by me.

May I suggest alternative implementations ?

(def text (slurp "http://www.ccel.org/ccel/bible/kjv.txt";))
(let [words (re-seq
#"(?:(?:\bm[a|e]n\b)|(?:\bwom[a|e]n\b)|(?:\bchild\b)|(?:\bchildren\b))"
text)
   words-per-initial (vals (group-by first words))]
  (zipmap
(map distinct words-per-initial)
(map count words-per-initial)))

;; => {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 5314}



or to avoid the intermediary creation of seqs of distincts and seqs of counts:

(defn- reduce-initial [m initial initial-words]
  (assoc m (distinct initial-words) (count initial-words)))

(let [words (re-seq
#"(?:(?:\bm[a|e]n\b)|(?:\bwom[a|e]n\b)|(?:\bchild\b)|(?:\bchildren\b))"
text)
   words-per-initial (group-by first words)]
  (reduce-kv reduce-initial {} words-per-initial))

;; => {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 5314}


HTH,

-- 
Laurent

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




Clojure: Superset of XML, HTML, CSS, JavaScript, Flash (SVG/ActionScript), etc.?

2013-07-11 Thread Alexander Gunnarson
No comments?

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




Re: vectorz doesn't handle scalars?

2013-07-11 Thread Mikera
Hi Brian,

I've released a new vectorz-clj version to Clojars which should fix the 
problem:

[net.mikera/vectorz-clj "0.11.0"]

Hopefully that works for you!

On Thursday, 11 July 2013 00:44:46 UTC+1, Brian Craft wrote:
>
> Without vectorz:
>
> => (+ 5 (matrix [1 2 3]))
> [6 7 8]
>
> With vectorz:
>
> => (+ 5 (matrix [1 2 3]))
> ClassCastException java.lang.Double cannot be cast to 
> mikera.arrayz.INDArray  mikera.vectorz.matrix-api/eval12140/fn--12145 
> (matrix_api.clj:644)
>
>
>
>

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




Re: vectorz doesn't handle scalars?

2013-07-11 Thread P Martin
I am having a similar error, but it is happening for the vectors. I just 
updated to the 0.11.0 version of vectorz. I have the following project file:

[org.clojure/clojure "1.5.1"]

[incanter/incanter-core "1.5.1"]

[incanter/incanter-charts "1.5.1"]

[net.mikera/vectorz-clj "0.11.0"]


And I get an error when I try to add a scalar to a vector:

(require '[mikera.vectorz.core :as vz])

(vz/+ 5 (vec [1 2 3]))


ClassCastException java.lang.Long cannot be cast to mikera.vectorz.AVector  
mikera.vectorz.core/clone (core.clj:38)


Any suggestions? Is there anything else I need to do to my repl? Am I just 
misusing the API?

Patrick

On Thursday, July 11, 2013 8:57:30 AM UTC-4, Mikera wrote:
>
> Hi Brian,
>
> I've released a new vectorz-clj version to Clojars which should fix the 
> problem:
>
> [net.mikera/vectorz-clj "0.11.0"]
>
> Hopefully that works for you!
>
> On Thursday, 11 July 2013 00:44:46 UTC+1, Brian Craft wrote:
>>
>> Without vectorz:
>>
>> => (+ 5 (matrix [1 2 3]))
>> [6 7 8]
>>
>> With vectorz:
>>
>> => (+ 5 (matrix [1 2 3]))
>> ClassCastException java.lang.Double cannot be cast to 
>> mikera.arrayz.INDArray  mikera.vectorz.matrix-api/eval12140/fn--12145 
>> (matrix_api.clj:644)
>>
>>
>>
>>

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




Re: vectorz doesn't handle scalars?

2013-07-11 Thread P Martin
Woops - my error is really different from my prior post. I forgot to put 
vz/vec in my function call:

(vz/+ 5 (vz/vec [1 2 3]))


ClassCastException java.lang.Long cannot be cast to mikera.vectorz.AVector  
mikera.vectorz.core/clone (core.clj:38)

On Thursday, July 11, 2013 9:37:06 AM UTC-4, P Martin wrote:
>
> I am having a similar error, but it is happening for the vectors. I just 
> updated to the 0.11.0 version of vectorz. I have the following project file:
>
> [org.clojure/clojure "1.5.1"]
>
> [incanter/incanter-core "1.5.1"]
>
> [incanter/incanter-charts "1.5.1"]
>
> [net.mikera/vectorz-clj "0.11.0"]
>
>
> And I get an error when I try to add a scalar to a vector:
>
> (require '[mikera.vectorz.core :as vz])
>
> (vz/+ 5 (vec [1 2 3]))
>
>
> ClassCastException java.lang.Long cannot be cast to 
> mikera.vectorz.AVector  mikera.vectorz.core/clone (core.clj:38)
>
>
> Any suggestions? Is there anything else I need to do to my repl? Am I just 
> misusing the API?
>
> Patrick
>
> On Thursday, July 11, 2013 8:57:30 AM UTC-4, Mikera wrote:
>>
>> Hi Brian,
>>
>> I've released a new vectorz-clj version to Clojars which should fix the 
>> problem:
>>
>> [net.mikera/vectorz-clj "0.11.0"]
>>
>> Hopefully that works for you!
>>
>> On Thursday, 11 July 2013 00:44:46 UTC+1, Brian Craft wrote:
>>>
>>> Without vectorz:
>>>
>>> => (+ 5 (matrix [1 2 3]))
>>> [6 7 8]
>>>
>>> With vectorz:
>>>
>>> => (+ 5 (matrix [1 2 3]))
>>> ClassCastException java.lang.Double cannot be cast to 
>>> mikera.arrayz.INDArray  mikera.vectorz.matrix-api/eval12140/fn--12145 
>>> (matrix_api.clj:644)
>>>
>>>
>>>
>>>

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




Re: vectorz doesn't handle scalars?

2013-07-11 Thread Mikera
Ah - that is expected behaviour because you are using the specialised 
vector-only operators in "mikera.vectorz.core". These are fast type-hinted 
versions of functions (that only work on vectors).

If you want to use the broadcasting operations that work with different 
types, you need to use the operators in "clojure.core.matrix.operators". In 
general, it is usually better to use the core.matrix API as it provides 
more capabilities and flexibility.

It would be nice if one version could do everything, however currently 
Clojure doesn't allow overloading functions on type, so we need to have the 
different namespaces.

On Thursday, 11 July 2013 14:37:06 UTC+1, P Martin wrote:
>
> I am having a similar error, but it is happening for the vectors. I just 
> updated to the 0.11.0 version of vectorz. I have the following project file:
>
> [org.clojure/clojure "1.5.1"]
>
> [incanter/incanter-core "1.5.1"]
>
> [incanter/incanter-charts "1.5.1"]
>
> [net.mikera/vectorz-clj "0.11.0"]
>
>
> And I get an error when I try to add a scalar to a vector:
>
> (require '[mikera.vectorz.core :as vz])
>
> (vz/+ 5 (vec [1 2 3]))
>
>
> ClassCastException java.lang.Long cannot be cast to 
> mikera.vectorz.AVector  mikera.vectorz.core/clone (core.clj:38)
>
>
> Any suggestions? Is there anything else I need to do to my repl? Am I just 
> misusing the API?
>
> Patrick
>
> On Thursday, July 11, 2013 8:57:30 AM UTC-4, Mikera wrote:
>>
>> Hi Brian,
>>
>> I've released a new vectorz-clj version to Clojars which should fix the 
>> problem:
>>
>> [net.mikera/vectorz-clj "0.11.0"]
>>
>> Hopefully that works for you!
>>
>> On Thursday, 11 July 2013 00:44:46 UTC+1, Brian Craft wrote:
>>>
>>> Without vectorz:
>>>
>>> => (+ 5 (matrix [1 2 3]))
>>> [6 7 8]
>>>
>>> With vectorz:
>>>
>>> => (+ 5 (matrix [1 2 3]))
>>> ClassCastException java.lang.Double cannot be cast to 
>>> mikera.arrayz.INDArray  mikera.vectorz.matrix-api/eval12140/fn--12145 
>>> (matrix_api.clj:644)
>>>
>>>
>>>
>>>

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




Re: Group words by their first letter and sum their frequencies

2013-07-11 Thread James Trunk
Hello Laurent,

Thank you so much for your detailed and helpful reply.

> You could use the new as-> macro in clojure 1.5 
Is it possible to get as-> to work with thread-last?

> depends :-) since your 2 fns are helper fns rather than 
> generically-reusable fns, I would make them private to enforce that : 
> (defn- ...)
Good point, and I'll definitely try to remember that in the future.

> May I suggest alternative implementations ?
> 
I really like both of your alternative solutions, and have learned several 
new ideas from them. Thank you.

By the way, I'm using the Clojure Cheat Sheet 
(http://clojure.org/cheatsheet) as my guide to the core functions, but it 
doesn't seem to be up-to-date with all these fancy 1.5 functions that 
you're using. Is there a new website that has superseded CCS? Do you know 
why CCS isn't kept up-to-date?

Regards,
James

On Thursday, July 11, 2013 2:29:38 PM UTC+2, Laurent PETIT wrote:
>
> Hello James, 
>
> 2013/7/11 James Trunk >: 
> > Hi everyone, I'm new to Clojure and trying to learn my way around the 
> > language. 
> > 
> > I've written a function that sums the frequencies of words starting with 
> the 
> > same letter, however I'm not fully satisfied with the result. I'm 
> striving 
> > for readability and idomaticity, but I fear that my rather limited grasp 
> of 
> > Clojure's core functions and lack of experience with functional 
> programming 
> > are letting me down on both counts. 
> > 
> > (def text (slurp "http://www.ccel.org/ccel/bible/kjv.txt";)) 
> > 
> > (defn sum-last-elements [coll] 
> >   (reduce + (map last coll))) 
> > 
> > (defn group-first-elements [coll] 
> >   (map first coll)) 
> > 
> > (->> text 
> >  (re-seq 
> > #"(?:(?:\bm[a|e]n\b)|(?:\bwom[a|e]n\b)|(?:\bchild\b)|(?:\bchildren\b))") 
> >  frequencies 
> >  (group-by ffirst) 
> >  vals 
> >  (#(zipmap (map group-first-elements %) (map sum-last-elements % 
> > 
> > Which on that file gives the result: 
> > 
> > {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 5314} 
> > 
> > My questions: 
> > 
> > Is there a way to avoid using ?: everywhere in the regex? 
> > (group-by ffirst) vals - is there a more readable/declarative/idiomatic 
> way 
> > to group by first letter? 
>
> you could first (group-by first), then create the final map by calling 
> (distinct) and count 
>
> > Is there a trick to avoid the ugly looking anonymous function (which I'm 
> > only using to reorder the thread-last argument)? 
>
> You could use the new as-> macro in clojure 1.5 
>
> > Is it idiomatic to extract small functions to give them names (with an 
> eye 
> > to aiding readability) or would most Clojure programmers prefer these to 
> be 
> > anonymous and in-line? 
>
> depends :-) since your 2 fns are helper fns rather than 
> generically-reusable fns, I would make them private to enforce that : 
> (defn- ...) 
>
> > Is thread-last the right approach when dealing with nested 
> data-structures 
> > or is list comprehension, or some other approach preferred? 
>
> The thread-last as you employed it is fine by me. 
>
> May I suggest alternative implementations ? 
>
> (def text (slurp "http://www.ccel.org/ccel/bible/kjv.txt";)) 
> (let [words (re-seq 
> #"(?:(?:\bm[a|e]n\b)|(?:\bwom[a|e]n\b)|(?:\bchild\b)|(?:\bchildren\b))" 
> text) 
>words-per-initial (vals (group-by first words))] 
>   (zipmap 
> (map distinct words-per-initial) 
> (map count words-per-initial))) 
>
> ;; => {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 
> 5314} 
>
>
>
> or to avoid the intermediary creation of seqs of distincts and seqs of 
> counts: 
>
> (defn- reduce-initial [m initial initial-words] 
>   (assoc m (distinct initial-words) (count initial-words))) 
>
> (let [words (re-seq 
> #"(?:(?:\bm[a|e]n\b)|(?:\bwom[a|e]n\b)|(?:\bchild\b)|(?:\bchildren\b))" 
> text) 
>words-per-initial (group-by first words)] 
>   (reduce-kv reduce-initial {} words-per-initial)) 
>
> ;; => {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 
> 5314} 
>
>
> HTH, 
>
> -- 
> Laurent 
>

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




Re: [ANN] CHP Web Framework Documentation Update

2013-07-11 Thread Steven Degutis
I am.


On Wed, Jul 10, 2013 at 2:59 PM, Kelker Ryan  wrote:

> Thanks. It's currently alpha and there's a lot more to come.
>
> Are you by chance the same Degutis from 8th light?
>
> 11.07.2013, 02:12, "Steven Degutis" :
>
> Wow. You obviously put a lot of work into this. And it looks extremely
> well documented!
>
>
> On Wed, Jul 10, 2013 at 5:36 AM, Kelker Ryan wrote:
>
> ClojureHomePage is a Clojure Web Framework
>
>
>
> *CHTML, Routing, and Sessions *
>
>- CHTML & Routes
>- Session handling, Cookies, and 
> Compojure
>
> * Ring *
>
>- Ring and port 
> configuration
>- Auto-loading 
> middleware
>
> * Code Generation & Modules *
>
>- Generating views from a 
> table
>- View bindings 
>- View bindings 
> Example
>- Enable admin 
> account
>- Database and Bindings 
> tutorial
>- HTML 
> Generation
>- CSS 
> Generation
>- JavaScript 
> Generation
>- CHP Modules 
>- Module Packages 
>
> * SQL Configuration, Migrations, and Manipulation *
>
>- SQL DB configuration and 
> creation
>- SQL DB Migrations 
>- SQL Manipulation 
>- Get column syntax 
> example
>
> * General Information *
>
>- Install 
>- UML Relationships 
>- Unit Tests
>- Removing example 
> files
>- License 
>- How? 
>- Tutorial 
>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
You received this message because you are subscrib

Clojure: One language to rule the Web

2013-07-11 Thread Alexander Gunnarson
This idea's been on my mind lately: could Clojure be used as a unifying 
force for all those disparate file formats and frameworks like:
- XML / XLink / XPointer / XQuery,
- JSON,
- HTML / XHTML,
- CSS,
- JavaScript / jQuery,
- Flash (SVG/ActionScript),
- SQL,
- and (of course) Java?

As a disclaimer, I'm no expert on all of these things I'm listing. But my 
thoughts go like this.
- XML and JSON are roughly equivalent.
  - HTML, XHTML, and SVG are subsets of XML.
  - *These "data storage" filetypes are equivalent to Clojure data 
structures like vectors, symbols, keywords, lists, maps, etc. and could 
theoretically be reduced to Clojure S-expressions.*
- Java, JavaScript, and ActionScript all play roughly the same role.
  - Some aspects of their libraries overlap with XML navigation and 
manipulation functions (XLink / XPointer / XQuery).
  - *Clojure covers what these languages aim for. It has direct access to 
Java libraries and the Clojure to JavaScript compiler has already been 
written, so further interop with ActionScript/Flash shouldn't be too 
terribly difficult (there's already a port on GitHub 
here
).*
- *SQL is a subset of Clojure. It just uses operations on the equivalent of 
Clojure data structures.*
*- *Probably other languages can be included in this set of which Clojure 
is a superset.

As it gains more popularity and notoriety, Clojure could be used 
side-by-side with and eventually in place of all of the above filetypes and 
frameworks I mentioned (and more). Say goodbye to 15 different Web 
technologies and hello to one, much better, more powerful one that envelops 
all of them.

Of course, I think my parade is going to get rained on. Clojure runs on the 
JVM and we've already said goodbye to Java applets long ago. So maybe a 
workaround would be to compile Clojure to a hundred little 
XML/HTML/CSS/SQL/JavaScript files, but to really only code in Clojure.

But not having to compile it would be nice. Think about it: with Clojure 
macros, you can have self-optimizing code, which would make for a 
self-optimizing web. Clojure running on the JVM would mean fairly easy 
concurrency, which would speed up video streaming/processing and (Clojure 
ported) Flash media significantly, especially as Moore's Law kicks in with 
multicore processors.

Thoughts?

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




Re: Clojure: One language to rule the Web

2013-07-11 Thread Gary Trakhman
It's true that many of these systems are equivalently powerful and
redundant, but the dominant forces driving them are social, not technical.

Fred Brooks's 'The Mythical Man-Month' is the classic book on this topic.

In an ideal world, where information flowed freely and instantly, all these
mentioned technologies would not exist.


On Thu, Jul 11, 2013 at 10:37 AM, Alexander Gunnarson <
alexandergunnar...@gmail.com> wrote:

> This idea's been on my mind lately: could Clojure be used as a unifying
> force for all those disparate file formats and frameworks like:
> - XML / XLink / XPointer / XQuery,
> - JSON,
> - HTML / XHTML,
> - CSS,
> - JavaScript / jQuery,
> - Flash (SVG/ActionScript),
> - SQL,
> - and (of course) Java?
>
> As a disclaimer, I'm no expert on all of these things I'm listing. But my
> thoughts go like this.
> - XML and JSON are roughly equivalent.
>   - HTML, XHTML, and SVG are subsets of XML.
>   - *These "data storage" filetypes are equivalent to Clojure data
> structures like vectors, symbols, keywords, lists, maps, etc. and could
> theoretically be reduced to Clojure S-expressions.*
> - Java, JavaScript, and ActionScript all play roughly the same role.
>   - Some aspects of their libraries overlap with XML navigation and
> manipulation functions (XLink / XPointer / XQuery).
>   - *Clojure covers what these languages aim for. It has direct access to
> Java libraries and the Clojure to JavaScript compiler has already been
> written, so further interop with ActionScript/Flash shouldn't be too
> terribly difficult (there's already a port on GitHub 
> here
> ).*
> - *SQL is a subset of Clojure. It just uses operations on the equivalent
> of Clojure data structures.*
> *- *Probably other languages can be included in this set of which Clojure
> is a superset.
>
> As it gains more popularity and notoriety, Clojure could be used
> side-by-side with and eventually in place of all of the above filetypes and
> frameworks I mentioned (and more). Say goodbye to 15 different Web
> technologies and hello to one, much better, more powerful one that envelops
> all of them.
>
> Of course, I think my parade is going to get rained on. Clojure runs on
> the JVM and we've already said goodbye to Java applets long ago. So maybe a
> workaround would be to compile Clojure to a hundred little
> XML/HTML/CSS/SQL/JavaScript files, but to really only code in Clojure.
>
> But not having to compile it would be nice. Think about it: with Clojure
> macros, you can have self-optimizing code, which would make for a
> self-optimizing web. Clojure running on the JVM would mean fairly easy
> concurrency, which would speed up video streaming/processing and (Clojure
> ported) Flash media significantly, especially as Moore's Law kicks in with
> multicore processors.
>
> Thoughts?
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Clojure: One language to rule the Web

2013-07-11 Thread Kelker Ryan
With the exception of XML and Flash, my framework covers all of that 
https://github.com/runexec/chp

11.07.2013, 23:37, "Alexander Gunnarson" :
> This idea's been on my mind lately: could Clojure be used as a unifying force 
> for all those disparate file formats and frameworks like:- XML / XLink / 
> XPointer / XQuery,
> - JSON,
> - HTML / XHTML,
> - CSS,
> - JavaScript / jQuery,
> - Flash (SVG/ActionScript),
> - SQL,
> - and (of course) Java?
>
> As a disclaimer, I'm no expert on all of these things I'm listing. But my 
> thoughts go like this.
> - XML and JSON are roughly equivalent.
>   - HTML, XHTML, and SVG are subsets of XML.
>   - These "data storage" filetypes are equivalent to Clojure data structures 
> like vectors, symbols, keywords, lists, maps, etc. and could theoretically be 
> reduced to Clojure S-expressions.
> - Java, JavaScript, and ActionScript all play roughly the same role.
>   - Some aspects of their libraries overlap with XML navigation and 
> manipulation functions (XLink / XPointer / XQuery).
>   - Clojure covers what these languages aim for. It has direct access to Java 
> libraries and the Clojure to JavaScript compiler has already been written, so 
> further interop with ActionScript/Flash shouldn't be too terribly difficult 
> (there's already a port on GitHub here).
> - SQL is a subset of Clojure. It just uses operations on the equivalent of 
> Clojure data structures.
> - Probably other languages can be included in this set of which Clojure is a 
> superset.
>
> As it gains more popularity and notoriety, Clojure could be used side-by-side 
> with and eventually in place of all of the above filetypes and frameworks I 
> mentioned (and more). Say goodbye to 15 different Web technologies and hello 
> to one, much better, more powerful one that envelops all of them.
>
> Of course, I think my parade is going to get rained on. Clojure runs on the 
> JVM and we've already said goodbye to Java applets long ago. So maybe a 
> workaround would be to compile Clojure to a hundred little 
> XML/HTML/CSS/SQL/JavaScript files, but to really only code in Clojure.
>
> But not having to compile it would be nice. Think about it: with Clojure 
> macros, you can have self-optimizing code, which would make for a 
> self-optimizing web. Clojure running on the JVM would mean fairly easy 
> concurrency, which would speed up video streaming/processing and (Clojure 
> ported) Flash media significantly, especially as Moore's Law kicks in with 
> multicore processors.
>
> Thoughts?
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

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




Re: Group words by their first letter and sum their frequencies

2013-07-11 Thread Andy Fingerhut
There is a link "Download other versions with tooltips" near the top of the
Clojure Cheat Sheet page (http://clojure.org/cheatsheet) that links to
versions that are a bit more recent, and they include tooltips of the doc
strings when you hover your cursor over the symbol.

The version at clojure.org/cheatsheet gets updated less frequently, simply
because I have to ask someone else to do it who has the necessary
permissions.  I'll ask again now.

Andy


On Thu, Jul 11, 2013 at 6:50 AM, James Trunk  wrote:

> Hello Laurent,
>
> Thank you so much for your detailed and helpful reply.
>
> > You could use the new as-> macro in clojure 1.5
> Is it possible to get as-> to work with thread-last?
>
> > depends :-) since your 2 fns are helper fns rather than
> > generically-reusable fns, I would make them private to enforce that :
> > (defn- ...)
> Good point, and I'll definitely try to remember that in the future.
>
> > May I suggest alternative implementations ?
> > 
> I really like both of your alternative solutions, and have learned several
> new ideas from them. Thank you.
>
> By the way, I'm using the Clojure Cheat Sheet (
> http://clojure.org/cheatsheet) as my guide to the core functions, but it
> doesn't seem to be up-to-date with all these fancy 1.5 functions that
> you're using. Is there a new website that has superseded CCS? Do you know
> why CCS isn't kept up-to-date?
>
> Regards,
> James
>
> On Thursday, July 11, 2013 2:29:38 PM UTC+2, Laurent PETIT wrote:
>
>> Hello James,
>>
>> 2013/7/11 James Trunk :
>> > Hi everyone, I'm new to Clojure and trying to learn my way around the
>> > language.
>> >
>> > I've written a function that sums the frequencies of words starting
>> with the
>> > same letter, however I'm not fully satisfied with the result. I'm
>> striving
>> > for readability and idomaticity, but I fear that my rather limited
>> grasp of
>> > Clojure's core functions and lack of experience with functional
>> programming
>> > are letting me down on both counts.
>> >
>> > (def text (slurp 
>> > "http://www.ccel.org/ccel/**bible/kjv.txt"))
>>
>> >
>> > (defn sum-last-elements [coll]
>> >   (reduce + (map last coll)))
>> >
>> > (defn group-first-elements [coll]
>> >   (map first coll))
>> >
>> > (->> text
>> >  (re-seq
>> > #"(?:(?:\bm[a|e]n\b)|(?:\bwom[**a|e]n\b)|(?:\bchild\b)|(?:\**bchildren\b))")
>>
>> >  frequencies
>> >  (group-by ffirst)
>> >  vals
>> >  (#(zipmap (map group-first-elements %) (map sum-last-elements
>> %
>> >
>> > Which on that file gives the result:
>> >
>> > {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 5314}
>> >
>> > My questions:
>> >
>> > Is there a way to avoid using ?: everywhere in the regex?
>> > (group-by ffirst) vals - is there a more readable/declarative/idiomatic
>> way
>> > to group by first letter?
>>
>> you could first (group-by first), then create the final map by calling
>> (distinct) and count
>>
>> > Is there a trick to avoid the ugly looking anonymous function (which
>> I'm
>> > only using to reorder the thread-last argument)?
>>
>> You could use the new as-> macro in clojure 1.5
>>
>> > Is it idiomatic to extract small functions to give them names (with an
>> eye
>> > to aiding readability) or would most Clojure programmers prefer these
>> to be
>> > anonymous and in-line?
>>
>> depends :-) since your 2 fns are helper fns rather than
>> generically-reusable fns, I would make them private to enforce that :
>> (defn- ...)
>>
>> > Is thread-last the right approach when dealing with nested
>> data-structures
>> > or is list comprehension, or some other approach preferred?
>>
>> The thread-last as you employed it is fine by me.
>>
>> May I suggest alternative implementations ?
>>
>> (def text (slurp 
>> "http://www.ccel.org/ccel/**bible/kjv.txt"))
>>
>> (let [words (re-seq
>> #"(?:(?:\bm[a|e]n\b)|(?:\bwom[**a|e]n\b)|(?:\bchild\b)|(?:\**bchildren\b))"
>>
>> text)
>>words-per-initial (vals (group-by first words))]
>>   (zipmap
>> (map distinct words-per-initial)
>> (map count words-per-initial)))
>>
>> ;; => {("woman" "women") 663, ("children" "child") 2274, ("men" "man")
>> 5314}
>>
>>
>>
>> or to avoid the intermediary creation of seqs of distincts and seqs of
>> counts:
>>
>> (defn- reduce-initial [m initial initial-words]
>>   (assoc m (distinct initial-words) (count initial-words)))
>>
>> (let [words (re-seq
>> #"(?:(?:\bm[a|e]n\b)|(?:\bwom[**a|e]n\b)|(?:\bchild\b)|(?:\**bchildren\b))"
>>
>> text)
>>words-per-initial (group-by first words)]
>>   (reduce-kv reduce-initial {} words-per-initial))
>>
>> ;; => {("woman" "women") 663, ("children" "child") 2274, ("men" "man")
>> 5314}
>>
>>
>> HTH,
>>
>> --
>> Laurent
>>
>  --
> --
> 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 

Re: vectorz doesn't handle scalars?

2013-07-11 Thread Brian Craft
Yes, that works better, thanks!

Is there an element-wise matrix multiply? Maybe I can copy the code for the 
/ operator.


On Thursday, July 11, 2013 5:57:30 AM UTC-7, Mikera wrote:
>
> Hi Brian,
>
> I've released a new vectorz-clj version to Clojars which should fix the 
> problem:
>
> [net.mikera/vectorz-clj "0.11.0"]
>
> Hopefully that works for you!
>
> On Thursday, 11 July 2013 00:44:46 UTC+1, Brian Craft wrote:
>>
>> Without vectorz:
>>
>> => (+ 5 (matrix [1 2 3]))
>> [6 7 8]
>>
>> With vectorz:
>>
>> => (+ 5 (matrix [1 2 3]))
>> ClassCastException java.lang.Double cannot be cast to 
>> mikera.arrayz.INDArray  mikera.vectorz.matrix-api/eval12140/fn--12145 
>> (matrix_api.clj:644)
>>
>>
>>
>>

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




Making RPCs with Shoreleave

2013-07-11 Thread Alex Fowler
Hi all, this is my first experience with Shoreleave and I'm trying to use 
it's RPC mechanism to perform AJAX tasks. However, on a call to a remote 
procedure, I get this:

`

   1. POST http://localhost:8080/_shoreleave 404 (Not Found) 
cljs.js:25223
  1. goog.net.XhrIo.sendcljs.js:25223 
  2. xhr__delegatecljs.js:31416 
  3. xhrcljs.js:31423 
  4. 
remote_callback__delegatecljs.js:32504
  5. remote_callbackcljs.js:32515 
  6. load_storecljs.js:32745 
  7. 
mk__AMPERSAND__load_store__delegatecljs.js:32755
  8. 
mk__AMPERSAND__load_storecljs.js:32763
  9. example_storecljs.js:33341 
  10. simplecljs.js:33361 
  11. setup_guicljs.js:33962 
  12. setup_allcljs.js:33982 
  13. startupcljs.js:41166 
  14. onloadapp:2 
  
XHR ERROR: Not Found 
`

What is wrong and how do I fix it? I have been following this tutorial: 
Shoreleave 
Tutorial 10 - Introducing 
Ajax 
my 
code (relevant parts) is this:

Project.clj:
`
(defproject projectname "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME";
  :dependencies [[org.clojure/clojure "1.5.1"]
 [lib-noir "0.6.3"]
 [compojure "1.2.0-SNAPSHOT"]
 [ring-server "0.2.8"]
 [clabango "0.5"]
 [hiccup "1.0.3"]
 [com.taoensso/timbre "2.1.2"]
 [com.taoensso/tower "1.7.1"]
 [markdown-clj "0.9.26"]
   
 ; -- ajax
 [shoreleave "0.3.0"]
 [shoreleave/shoreleave-remote-ring "0.3.0"]
 [shoreleave/shoreleave-remote "0.3.0"]
 
 ; -- cljs
 [com.keminglabs/singult "0.1.6"]
 [enfocus "1.0.1"]
 [jayq "2.3.0"]
 ]
  :plugins [[lein-ring "0.8.5"]
[lein-cljsbuild "0.3.2"]]
  :hooks [leiningen.cljsbuild]
  :cljsbuild {
  :builds [{
:jar true
:source-paths ["src/family/webapp"]
:compiler {
   :output-to "resources/public/js/cljs.js"
   :optimizations :whitespace
   :externs ["externs/jquery-1.9.js"]
   :pretty-print true}}]}
  :ring {:handler projectname.handler/war-handler
 :initprojectname.handler/init
 :destroy projectname.handler/destroy}
  :profiles
  {:production {:ring {:open-browser? false
   :stacktraces?  false
   :auto-reload?  false}}
   :dev {:dependencies [[ring-mock "0.1.5"]
[ring/ring-devel "1.1.8"]]}}
  :min-lein-version "2.0.0")
`

Handler:
`
(ns projectname.handler
  (:use projectname.routes.home
compojure.core)
  (:require [noir.util.middleware :as middleware]
[compojure.route :as route]
[shoreleave.middleware.rpc :refer [wrap-rpc]]))

(def all-routes [home-routes app-routes])

(def app (-> all-routes
 middleware/app-handler
 wrap-rpc
 ;;add your middlewares here
 ))

(def war-handler (middleware/war-handler app))
` 

Remote procedure declaration:
`
(ns projectname.ajax
  (:require [shoreleave.middleware.rpc :refer [defremote]]))

(defremote my-remote-proc [some-arg] (println "remote call ok" some-arg) 
some-arg)
`

Client side ClojureScript code:
`
(ns projectname.webapp.model.store
  (:require
[shoreleave.remotes.http-rpc :refer [remote-callback]]))

(defn do-smth-useful [useful-args]
  (log "This is the last log statement that get's printed")
  (remote-callback :my-remote-proc [useful-args] #(process-feedback %))
`

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

[ANN] Clojure/conj CFP brainstorming Hangout tomorrow @ 11am EST

2013-07-11 Thread Lynn Grogan
Hey All!
The Clojure/conj speaker selection folks will be hosting a G+ Hangout 
tomorrow at 11am Eastern to discuss/brainstorm talk submissions for this 
year's conference. 
If you're thinking about submitting a CFP (deadline is July 19 @ 5pm EST) 
but you need help fleshing out your idea, this will be a great time to get 
some help. 

Email lynn [at] thinkrelevance [dot] com to get in on the call. 

Thanks!
Lynn from Relevance, Inc

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




Re: vectorz doesn't handle scalars?

2013-07-11 Thread P Martin
Ok understood! Thanks for the tip. I'll switch over to the core.matrix 
system. So as I understand it, I need the vectorz dependencies in my 
project file, then I use the core.matrix and core.matrix.operators with the 
:vectorz implementation specified?

Thanks!

Patrick

On Thursday, July 11, 2013 9:50:52 AM UTC-4, Mikera wrote:
>
> Ah - that is expected behaviour because you are using the specialised 
> vector-only operators in "mikera.vectorz.core". These are fast type-hinted 
> versions of functions (that only work on vectors).
>
> If you want to use the broadcasting operations that work with different 
> types, you need to use the operators in "clojure.core.matrix.operators". In 
> general, it is usually better to use the core.matrix API as it provides 
> more capabilities and flexibility.
>
> It would be nice if one version could do everything, however currently 
> Clojure doesn't allow overloading functions on type, so we need to have the 
> different namespaces.
>
> On Thursday, 11 July 2013 14:37:06 UTC+1, P Martin wrote:
>>
>> I am having a similar error, but it is happening for the vectors. I just 
>> updated to the 0.11.0 version of vectorz. I have the following project file:
>>
>> [org.clojure/clojure "1.5.1"]
>>
>> [incanter/incanter-core "1.5.1"]
>>
>> [incanter/incanter-charts "1.5.1"]
>>
>> [net.mikera/vectorz-clj "0.11.0"]
>>
>>
>> And I get an error when I try to add a scalar to a vector:
>>
>> (require '[mikera.vectorz.core :as vz])
>>
>> (vz/+ 5 (vec [1 2 3]))
>>
>>
>> ClassCastException java.lang.Long cannot be cast to 
>> mikera.vectorz.AVector  mikera.vectorz.core/clone (core.clj:38)
>>
>>
>> Any suggestions? Is there anything else I need to do to my repl? Am I 
>> just misusing the API?
>>
>> Patrick
>>
>> On Thursday, July 11, 2013 8:57:30 AM UTC-4, Mikera wrote:
>>>
>>> Hi Brian,
>>>
>>> I've released a new vectorz-clj version to Clojars which should fix the 
>>> problem:
>>>
>>> [net.mikera/vectorz-clj "0.11.0"]
>>>
>>> Hopefully that works for you!
>>>
>>> On Thursday, 11 July 2013 00:44:46 UTC+1, Brian Craft wrote:

 Without vectorz:

 => (+ 5 (matrix [1 2 3]))
 [6 7 8]

 With vectorz:

 => (+ 5 (matrix [1 2 3]))
 ClassCastException java.lang.Double cannot be cast to 
 mikera.arrayz.INDArray  mikera.vectorz.matrix-api/eval12140/fn--12145 
 (matrix_api.clj:644)





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




Re: vectorz doesn't handle scalars?

2013-07-11 Thread Brian Craft
Just found emul, which I believe is what I need.

On Thursday, July 11, 2013 9:52:12 AM UTC-7, Brian Craft wrote:
>
> Yes, that works better, thanks!
>
> Is there an element-wise matrix multiply? Maybe I can copy the code for 
> the / operator.
>
>
> On Thursday, July 11, 2013 5:57:30 AM UTC-7, Mikera wrote:
>>
>> Hi Brian,
>>
>> I've released a new vectorz-clj version to Clojars which should fix the 
>> problem:
>>
>> [net.mikera/vectorz-clj "0.11.0"]
>>
>> Hopefully that works for you!
>>
>> On Thursday, 11 July 2013 00:44:46 UTC+1, Brian Craft wrote:
>>>
>>> Without vectorz:
>>>
>>> => (+ 5 (matrix [1 2 3]))
>>> [6 7 8]
>>>
>>> With vectorz:
>>>
>>> => (+ 5 (matrix [1 2 3]))
>>> ClassCastException java.lang.Double cannot be cast to 
>>> mikera.arrayz.INDArray  mikera.vectorz.matrix-api/eval12140/fn--12145 
>>> (matrix_api.clj:644)
>>>
>>>
>>>
>>>

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




Re: vectorz doesn't handle scalars?

2013-07-11 Thread Mikera
Elementwise matrix multiply is called "emul" (clojure.core.matrix/emul)

It's named for consistency with the other operations that work on elements, 
e.g. ecount, esum, emap, ereduce etc.

On Thursday, 11 July 2013 17:52:12 UTC+1, Brian Craft wrote:
>
> Yes, that works better, thanks!
>
> Is there an element-wise matrix multiply? Maybe I can copy the code for 
> the / operator.
>
>
> On Thursday, July 11, 2013 5:57:30 AM UTC-7, Mikera wrote:
>>
>> Hi Brian,
>>
>> I've released a new vectorz-clj version to Clojars which should fix the 
>> problem:
>>
>> [net.mikera/vectorz-clj "0.11.0"]
>>
>> Hopefully that works for you!
>>
>> On Thursday, 11 July 2013 00:44:46 UTC+1, Brian Craft wrote:
>>>
>>> Without vectorz:
>>>
>>> => (+ 5 (matrix [1 2 3]))
>>> [6 7 8]
>>>
>>> With vectorz:
>>>
>>> => (+ 5 (matrix [1 2 3]))
>>> ClassCastException java.lang.Double cannot be cast to 
>>> mikera.arrayz.INDArray  mikera.vectorz.matrix-api/eval12140/fn--12145 
>>> (matrix_api.clj:644)
>>>
>>>
>>>
>>>

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




Re: vectorz doesn't handle scalars?

2013-07-11 Thread Mikera
Yes that should work fine.

You can also use (clojure.core.matrix/set-current-implementation :vectorz) 
if you are working at the REPL / don't want to explicitly ask for a vectorz 
type every time. It is a global setting however - so use with caution.

On Thursday, 11 July 2013 18:14:04 UTC+1, P Martin wrote:
>
> Ok understood! Thanks for the tip. I'll switch over to the core.matrix 
> system. So as I understand it, I need the vectorz dependencies in my 
> project file, then I use the core.matrix and core.matrix.operators with the 
> :vectorz implementation specified?
>
> Thanks!
>
> Patrick
>
> On Thursday, July 11, 2013 9:50:52 AM UTC-4, Mikera wrote:
>>
>> Ah - that is expected behaviour because you are using the specialised 
>> vector-only operators in "mikera.vectorz.core". These are fast type-hinted 
>> versions of functions (that only work on vectors).
>>
>> If you want to use the broadcasting operations that work with different 
>> types, you need to use the operators in "clojure.core.matrix.operators". In 
>> general, it is usually better to use the core.matrix API as it provides 
>> more capabilities and flexibility.
>>
>> It would be nice if one version could do everything, however currently 
>> Clojure doesn't allow overloading functions on type, so we need to have the 
>> different namespaces.
>>
>> On Thursday, 11 July 2013 14:37:06 UTC+1, P Martin wrote:
>>>
>>> I am having a similar error, but it is happening for the vectors. I just 
>>> updated to the 0.11.0 version of vectorz. I have the following project file:
>>>
>>> [org.clojure/clojure "1.5.1"]
>>>
>>> [incanter/incanter-core "1.5.1"]
>>>
>>> [incanter/incanter-charts "1.5.1"]
>>>
>>> [net.mikera/vectorz-clj "0.11.0"]
>>>
>>>
>>> And I get an error when I try to add a scalar to a vector:
>>>
>>> (require '[mikera.vectorz.core :as vz])
>>>
>>> (vz/+ 5 (vec [1 2 3]))
>>>
>>>
>>> ClassCastException java.lang.Long cannot be cast to 
>>> mikera.vectorz.AVector  mikera.vectorz.core/clone (core.clj:38)
>>>
>>>
>>> Any suggestions? Is there anything else I need to do to my repl? Am I 
>>> just misusing the API?
>>>
>>> Patrick
>>>
>>> On Thursday, July 11, 2013 8:57:30 AM UTC-4, Mikera wrote:

 Hi Brian,

 I've released a new vectorz-clj version to Clojars which should fix the 
 problem:

 [net.mikera/vectorz-clj "0.11.0"]

 Hopefully that works for you!

 On Thursday, 11 July 2013 00:44:46 UTC+1, Brian Craft wrote:
>
> Without vectorz:
>
> => (+ 5 (matrix [1 2 3]))
> [6 7 8]
>
> With vectorz:
>
> => (+ 5 (matrix [1 2 3]))
> ClassCastException java.lang.Double cannot be cast to 
> mikera.arrayz.INDArray  mikera.vectorz.matrix-api/eval12140/fn--12145 
> (matrix_api.clj:644)
>
>
>
>

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




Re: Core Logic Reference Documentation

2013-07-11 Thread Benjamin Peter
Hello,

I went through the clojure core logic code and picked the functions I 
though that might go into the cheat sheet. The groups are pretty much 
defined by the code comments left by David and co.

https://rawgithub.com/dedeibel/clojure-cheatsheets/master/src/clj-jvm/cheatsheet-use-title-attribute-no-cdocs-summary.html

It would be really great if someone could look over that and leave comments 
about missing or superfluous entries. Additionally the grouping and their 
names should be considered a draft. 

The next question is where this and xavrilley's clojuredocs clone could be 
hosted. Is there already a place where it would fit? minikanren.org? 
clojurecorelogic.org?


Thanks

Ben.



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




Re: Core Logic Reference Documentation

2013-07-11 Thread Plínio Balduino
Hey, good job.

I missed a cheat sheet like this.

Thank you.

On Thu, Jul 11, 2013 at 3:06 PM, Benjamin Peter wrote:

> Hello,
>
> I went through the clojure core logic code and picked the functions I
> though that might go into the cheat sheet. The groups are pretty much
> defined by the code comments left by David and co.
>
>
> https://rawgithub.com/dedeibel/clojure-cheatsheets/master/src/clj-jvm/cheatsheet-use-title-attribute-no-cdocs-summary.html
>
> It would be really great if someone could look over that and leave
> comments about missing or superfluous entries. Additionally the grouping
> and their names should be considered a draft.
>
> The next question is where this and xavrilley's clojuredocs clone could be
> hosted. Is there already a place where it would fit? minikanren.org?
> clojurecorelogic.org?
>
>
> Thanks
>
> Ben.
>
>
>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Core Logic Reference Documentation

2013-07-11 Thread David Nolen
This mostly looks good I remove the references to the defnc, fnc and predc
these are very experimental, likely to change, and easy to cause trouble if
you're not careful.

David


On Thu, Jul 11, 2013 at 1:06 PM, Benjamin Peter wrote:

> Hello,
>
> I went through the clojure core logic code and picked the functions I
> though that might go into the cheat sheet. The groups are pretty much
> defined by the code comments left by David and co.
>
>
> https://rawgithub.com/dedeibel/clojure-cheatsheets/master/src/clj-jvm/cheatsheet-use-title-attribute-no-cdocs-summary.html
>
> It would be really great if someone could look over that and leave
> comments about missing or superfluous entries. Additionally the grouping
> and their names should be considered a draft.
>
> The next question is where this and xavrilley's clojuredocs clone could be
> hosted. Is there already a place where it would fit? minikanren.org?
> clojurecorelogic.org?
>
>
> Thanks
>
>
> Ben.
>
>
>
>  --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Lamina receive-all functionality

2013-07-11 Thread P Martin
Hi there,

I am working on an application using Lamina where I register several 
callbacks on a channel with receive-all. At some point in the application, 
I want to cancel all current callbacks. When this occurs the channel 
appears to close. Why does this happen? Is this a safety feature? For 
example:

(def test-channel (channel))
(def cb1 (receive-all test-channel #(println %)))
(def cb2 (receive-all test-channel #(println % " two!")))

... some time later

(cancel-callback test-channel cb1)
(cancel-callback test-channel cb2)

(enqueue test-channel "something")
>> :lamina/closed!

Thanks!
Patrick

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




ANN Elastisch 1.2.0-beta3 is released

2013-07-11 Thread Michael Klishin
Elastisch [1] is a minimalistic Clojure client for ElasticSearch.

1.2.0-beta3 is a development release that adds a minor feature to the REST
client
and upgrades ElasticSearch dependency to 0.90.2.

Release notes:
http://blog.clojurewerkz.org/blog/2013/07/11/elastisch-1-dot-2-0-beta3-is-released/

1. http://clojureelasticsearch.info
-- 
MK

http://github.com/michaelklishin
http://twitter.com/michaelklishin

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




Re: Lamina receive-all functionality

2013-07-11 Thread Zach Tellman
Hi Patrick,

A similar question has been asked in the Aleph mailing list, and you can 
see my answer there: 
https://groups.google.com/forum/#!topic/aleph-lib/SIO9Z8d3tdo.  For future 
reference, you're more likely to get my attention, or the attention of 
someone else who can answer your question, if you post it there.

Zach

On Thursday, July 11, 2013 12:21:20 PM UTC-7, P Martin wrote:
>
> Hi there,
>
> I am working on an application using Lamina where I register several 
> callbacks on a channel with receive-all. At some point in the application, 
> I want to cancel all current callbacks. When this occurs the channel 
> appears to close. Why does this happen? Is this a safety feature? For 
> example:
>
> (def test-channel (channel))
> (def cb1 (receive-all test-channel #(println %)))
> (def cb2 (receive-all test-channel #(println % " two!")))
>
> ... some time later
>
> (cancel-callback test-channel cb1)
> (cancel-callback test-channel cb2)
>
> (enqueue test-channel "something")
> >> :lamina/closed!
>
> Thanks!
> Patrick
>

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




Re: Clojure: One language to rule the Web

2013-07-11 Thread Alexander Gunnarson

>
> With the exception of XML and Flash, my framework covers all of that 
> https://github.com/runexec/chp 
>

Your framework seems very promising. I'll have to play around with it. Any 
plans for extending it to enclose XML?

ActionScript/Flash seems to have been addressed somewhat by 
las3ron GitHub, but time will tell 
whether it's really up for use in production. 
The author hasn't updated it in two years already, so it seems somewhat 
dead.

It'll be interesting to see what some key Clojure contributors have to say 
about plans to make a unified Clojure framework to encompass all the 
frontend and backend technologies out there. It seems like you've gotten 
much of the way there.

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




Re: Lamina receive-all functionality

2013-07-11 Thread P Martin
Awesome! After I posted I ran into the permanent-channel in the API docs. 
Thanks for your help,

Patrick

On Thursday, July 11, 2013 3:58:47 PM UTC-4, Zach Tellman wrote:
>
> Hi Patrick,
>
> A similar question has been asked in the Aleph mailing list, and you can 
> see my answer there: 
> https://groups.google.com/forum/#!topic/aleph-lib/SIO9Z8d3tdo.  For 
> future reference, you're more likely to get my attention, or the attention 
> of someone else who can answer your question, if you post it there.
>
> Zach
>
> On Thursday, July 11, 2013 12:21:20 PM UTC-7, P Martin wrote:
>>
>> Hi there,
>>
>> I am working on an application using Lamina where I register several 
>> callbacks on a channel with receive-all. At some point in the application, 
>> I want to cancel all current callbacks. When this occurs the channel 
>> appears to close. Why does this happen? Is this a safety feature? For 
>> example:
>>
>> (def test-channel (channel))
>> (def cb1 (receive-all test-channel #(println %)))
>> (def cb2 (receive-all test-channel #(println % " two!")))
>>
>> ... some time later
>>
>> (cancel-callback test-channel cb1)
>> (cancel-callback test-channel cb2)
>>
>> (enqueue test-channel "something")
>> >> :lamina/closed!
>>
>> Thanks!
>> Patrick
>>
>

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




Re: Clojure: One language to rule the Web

2013-07-11 Thread Alexander Gunnarson
As a side note, maybe we can keep a running list of "Clojure-ized" 
technologies we're aware of:
- XML - *clojure/data.xml *
  - XLink + XPointer + XQuery - 
*clojure/data.xml
*
- JSON -* Clojure Home Page (CHP) *
- HTML - *Hiccup* 
  - XHTML - *?*
- CSS - *Garden* 
- JavaScript + jQuery - *ClojureScript*
- Java -* (Already available)*
- Flash: SVG + ActionScript - *las3r  
*(partially?)
- SQL - *Korma *

On second appraisal, it seems like Clojure has got pretty much all of these 
under control.

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




State monad issue

2013-07-11 Thread JvJ
I'm trying to use a domonad block with the state monad, and I'm running 
into trouble chaining together multiple monadic instructions.

Take this for example:

;; This block of code fetches the value from :a in the state,
;; and then associates a new value for :b if :a is set.
(domonad state-m
 [a (fetch-val :a)
 _ (if a
   (update-state #(assoc % :b 2))
   (m-result nil))
 ]
 nil)

My question is, what if I wanted to run two update functions, like
(update-state #(assoc % :b 2)) and (update-state #(assoc % :c 3)),
but within the if statement?

(p.s.  I realize that assoc is variadic, and could easily deal with this, 
however I'm using
it as a simple example of a more general case)

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




Re: State monad issue

2013-07-11 Thread Ben Wolfson
Is it not possible just to put another domonad block in the true branch of
the if? Alternately, it should be possible to do it with an explicit bind
operation.


On Thu, Jul 11, 2013 at 2:11 PM, JvJ  wrote:

> I'm trying to use a domonad block with the state monad, and I'm running
> into trouble chaining together multiple monadic instructions.
>
> Take this for example:
>
> ;; This block of code fetches the value from :a in the state,
> ;; and then associates a new value for :b if :a is set.
> (domonad state-m
>  [a (fetch-val :a)
>  _ (if a
>(update-state #(assoc % :b 2))
>(m-result nil))
>  ]
>  nil)
>
> My question is, what if I wanted to run two update functions, like
> (update-state #(assoc % :b 2)) and (update-state #(assoc % :c 3)),
> but within the if statement?
>
> (p.s.  I realize that assoc is variadic, and could easily deal with this,
> however I'm using
> it as a simple example of a more general case)
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

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




Re: State monad issue

2013-07-11 Thread JvJ
Yeah it is possible to do it with another domonad block.  I just don't want 
to clutter up the code by repeating myself.

I made a macro do-state that introduces a new domonad block using the 
current state.  It works:

(defmacro do-state [bindings & r]
`(fn [st] ( (domonad state-m ~bindings ~@r) st)))

(domonad state-m
 [a (fetch-val :a)
 _ (if a
   (do-state[ _ (update-state #(assoc % :b 2))
  _ (update-state 
#(assoc % :b 2))]
  nil)
   (m-result nil))
 ]
 nil)

On Thursday, July 11, 2013 2:18:44 PM UTC-7, Ben wrote:
>
> Is it not possible just to put another domonad block in the true branch of 
> the if? Alternately, it should be possible to do it with an explicit bind 
> operation.
>
>
> On Thu, Jul 11, 2013 at 2:11 PM, JvJ >wrote:
>
>> I'm trying to use a domonad block with the state monad, and I'm running 
>> into trouble chaining together multiple monadic instructions.
>>
>> Take this for example:
>>
>> ;; This block of code fetches the value from :a in the state,
>> ;; and then associates a new value for :b if :a is set.
>> (domonad state-m
>>  [a (fetch-val :a)
>>  _ (if a
>>(update-state #(assoc % :b 2))
>>(m-result nil))
>>  ]
>>  nil)
>>
>> My question is, what if I wanted to run two update functions, like
>> (update-state #(assoc % :b 2)) and (update-state #(assoc % :c 3)),
>> but within the if statement?
>>
>> (p.s.  I realize that assoc is variadic, and could easily deal with this, 
>> however I'm using
>> it as a simple example of a more general case)
>>
>> -- 
>> -- 
>> 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/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Ben Wolfson
> "Human kind has used its intelligence to vary the flavour of drinks, which 
> may be sweet, aromatic, fermented or spirit-based. ... Family and social 
> life also offer numerous other occasions to consume drinks for pleasure." 
> [Larousse, "Drink" entry]
>
>  

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




Multiple REPLs in Emacs? (was: test run startup time

2013-07-11 Thread Sean Corfield
On Wed, Jul 10, 2013 at 10:53 AM, Jay Fields  wrote:
> I work in emacs with 2 repls running - 1 for running my app and 1 for
> running my tests.

What is the magic to get this working and how does Emacs / nrepl.el
know which REPL to send commands to?

I've often wanted multiple active REPLs (usually for working with
multiple projects) but have never figured out how to get it working...
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

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

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




Re: ClassCastException in APersistentVector.doEquiv with custom implementation of IPersistentVector

2013-07-11 Thread Sean Corfield
On Wed, Jul 10, 2013 at 11:00 AM, Vincent  wrote:
> I guess I can proxy APersistentVector, but the Clojure docs [1] advise to
> use reify in favour to proxy whenever possible. My goal is to have my byte
> stream behave like a standard Clojure vector.

Given the definition of IPersistentVector, I would expect you to need
to provide several more method definitions?

https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/IPersistentVector.java
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

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

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




Re: Multiple REPLs in Emacs? (was: test run startup time

2013-07-11 Thread Jay Fields
On Thu, Jul 11, 2013 at 5:53 PM, Sean Corfield wrote:

> On Wed, Jul 10, 2013 at 10:53 AM, Jay Fields  wrote:
> > I work in emacs with 2 repls running - 1 for running my app and 1 for
> > running my tests.
>
> What is the magic to get this working and how does Emacs / nrepl.el
> know which REPL to send commands to?
>
>
I don't remember how I ended up with my current config, but I'm pretty sure
I started here:
https://github.com/kingtim/nrepl.el#managing-multiple-sessions

After that, it was as easy as configuring my emacs to push compiles to both
repls, and defaulting to 1 repl for running the app.

https://github.com/jaycfields/unplugged-pack/blob/master/init.el#L15-L16 &
https://github.com/jaycfields/unplugged-pack/blob/master/init.el#L29-L43

If you want multi repls for different projects, you'll probably want
slightly different behavior.

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




Re: Multiple REPLs in Emacs? (was: test run startup time

2013-07-11 Thread Sean Corfield
Thanx Jay. For whatever reason, multiple nREPL buffers has never
worked for me before but on reading that I suspect I may just have had
incorrect assumptions about how it was actually supposed to work...

Sean

On Thu, Jul 11, 2013 at 3:10 PM, Jay Fields  wrote:
>
>
>
> On Thu, Jul 11, 2013 at 5:53 PM, Sean Corfield 
> wrote:
>>
>> On Wed, Jul 10, 2013 at 10:53 AM, Jay Fields  wrote:
>> > I work in emacs with 2 repls running - 1 for running my app and 1 for
>> > running my tests.
>>
>> What is the magic to get this working and how does Emacs / nrepl.el
>> know which REPL to send commands to?
>>
>
> I don't remember how I ended up with my current config, but I'm pretty sure
> I started here:
> https://github.com/kingtim/nrepl.el#managing-multiple-sessions
>
> After that, it was as easy as configuring my emacs to push compiles to both
> repls, and defaulting to 1 repl for running the app.
>
> https://github.com/jaycfields/unplugged-pack/blob/master/init.el#L15-L16 &
> https://github.com/jaycfields/unplugged-pack/blob/master/init.el#L29-L43
>
> If you want multi repls for different projects, you'll probably want
> slightly different behavior.
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/

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

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




Re: core.async: communicating termination

2013-07-11 Thread Alex Miller
I haven't been in any discussions about this with the team, so it's 
entirely possible I am ignorant of some established future direction... but

- "closed?" seems useful to me. (It may also be useful to ask "drained?" 
(closed + empty).)
- >! returning an indicator of success also seems useful. However, since it 
executes asynchronously, I suspect adding that functionality may not be 
feasible (or may be feasible but incur a synchronization or complexity cost 
that is unacceptable). 

If you'd like to file a ticket at http://dev.clojure.org/jira/browse/ASYNC 
that would help to track the request. 

With respect to other strategies for dealing with this:

1) You could simply ignore the producer. If no one is requesting new 
values, the producer will not be run and no thread time should be consumed 
(there is of course heap being used). Not really recommending this but it's 
an option!

2) You could create a control channel for the producer (and other 
interested processes) that could transmit a stop message. Then alts! on the 
control channel in combination with the >! so that you're waiting on either 
the need to stop or the ability to put a new value in the channel.

Alex


On Thursday, July 11, 2013 7:16:56 AM UTC-5, vemv wrote:
>
> Consider a happy, oblivious producer of values:
>
> (def c (chan 42))
>
> (go (while true (>! c (rand
>
> It doesn't know where/now the channel is consumed (which part of the point 
> of channels/queues). However, we *do* know that at some point, nobody 
> will need the result of our producing, so we should stop our activity.
>
> It seems to me that a natural way to tell the producer to stop is to close 
> the channel. However:
>
> * there's nothing like a clojure.core.async/chan-closed? fn, AFAICT
> * The >! fn unconditionally returns nil, whether the channel is open or 
> not. Only the blocking nature of the call can potentially vary - which is 
> not particularly useful for the purpose.
>
> What would be an adequate way to indicate termination? Just telling the 
> producer to stop (e.g. (reset! keep-producing false)) would break the 
> indirection one gains by using channels.
>
> What if >! returned true/false depending on whether the value was put 
> (because the channel was open)?
>

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




Re: core.async: communicating termination

2013-07-11 Thread Michał Marczyk
I think you could pass the producer a higher-order (chan 1) with the
actual communication channel placed in the buffer.

Then at each step the producer would do

(when-let [c (! c (rand))
  (>! communication-channel c))

Once you close communication-channel, the put succeeds, but then the
take on communication-channel returns nil and the producer stops.

Cheers,
M.


On 12 July 2013 00:37, Alex Miller  wrote:
> I haven't been in any discussions about this with the team, so it's entirely
> possible I am ignorant of some established future direction... but
>
> - "closed?" seems useful to me. (It may also be useful to ask "drained?"
> (closed + empty).)
> - >! returning an indicator of success also seems useful. However, since it
> executes asynchronously, I suspect adding that functionality may not be
> feasible (or may be feasible but incur a synchronization or complexity cost
> that is unacceptable).
>
> If you'd like to file a ticket at http://dev.clojure.org/jira/browse/ASYNC
> that would help to track the request.
>
> With respect to other strategies for dealing with this:
>
> 1) You could simply ignore the producer. If no one is requesting new values,
> the producer will not be run and no thread time should be consumed (there is
> of course heap being used). Not really recommending this but it's an option!
>
> 2) You could create a control channel for the producer (and other interested
> processes) that could transmit a stop message. Then alts! on the control
> channel in combination with the >! so that you're waiting on either the need
> to stop or the ability to put a new value in the channel.
>
> Alex
>
>
> On Thursday, July 11, 2013 7:16:56 AM UTC-5, vemv wrote:
>>
>> Consider a happy, oblivious producer of values:
>>
>> (def c (chan 42))
>>
>> (go (while true (>! c (rand
>>
>> It doesn't know where/now the channel is consumed (which part of the point
>> of channels/queues). However, we do know that at some point, nobody will
>> need the result of our producing, so we should stop our activity.
>>
>> It seems to me that a natural way to tell the producer to stop is to close
>> the channel. However:
>>
>> * there's nothing like a clojure.core.async/chan-closed? fn, AFAICT
>> * The >! fn unconditionally returns nil, whether the channel is open or
>> not. Only the blocking nature of the call can potentially vary - which is
>> not particularly useful for the purpose.
>>
>> What would be an adequate way to indicate termination? Just telling the
>> producer to stop (e.g. (reset! keep-producing false)) would break the
>> indirection one gains by using channels.
>>
>> What if >! returned true/false depending on whether the value was put
>> (because the channel was open)?
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

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




Re: core.async: communicating termination

2013-07-11 Thread Timothy Baldridge
It's interesting to note that blocking go blocks can actually be GC'd. For
example, run this in a repl:

(loop [] (let [c (chan)]
 (go (>! c 42)))
  (recur))

On my box the CPU and memory spikes, but after I CTRL+C and kill the loop,
the GC kicks in and collects all the channels and gos

When go's are parked, they are put into a queue on the channel, thus when
the channel is unreachable (besides inside the go block) both are
collected, and the thread of execution is effectively terminated.



Timothy


On Thu, Jul 11, 2013 at 4:53 PM, Michał Marczyk wrote:

> I think you could pass the producer a higher-order (chan 1) with the
> actual communication channel placed in the buffer.
>
> Then at each step the producer would do
>
> (when-let [c (   (>! c (rand))
>   (>! communication-channel c))
>
> Once you close communication-channel, the put succeeds, but then the
> take on communication-channel returns nil and the producer stops.
>
> Cheers,
> M.
>
>
> On 12 July 2013 00:37, Alex Miller  wrote:
> > I haven't been in any discussions about this with the team, so it's
> entirely
> > possible I am ignorant of some established future direction... but
> >
> > - "closed?" seems useful to me. (It may also be useful to ask "drained?"
> > (closed + empty).)
> > - >! returning an indicator of success also seems useful. However, since
> it
> > executes asynchronously, I suspect adding that functionality may not be
> > feasible (or may be feasible but incur a synchronization or complexity
> cost
> > that is unacceptable).
> >
> > If you'd like to file a ticket at
> http://dev.clojure.org/jira/browse/ASYNC
> > that would help to track the request.
> >
> > With respect to other strategies for dealing with this:
> >
> > 1) You could simply ignore the producer. If no one is requesting new
> values,
> > the producer will not be run and no thread time should be consumed
> (there is
> > of course heap being used). Not really recommending this but it's an
> option!
> >
> > 2) You could create a control channel for the producer (and other
> interested
> > processes) that could transmit a stop message. Then alts! on the control
> > channel in combination with the >! so that you're waiting on either the
> need
> > to stop or the ability to put a new value in the channel.
> >
> > Alex
> >
> >
> > On Thursday, July 11, 2013 7:16:56 AM UTC-5, vemv wrote:
> >>
> >> Consider a happy, oblivious producer of values:
> >>
> >> (def c (chan 42))
> >>
> >> (go (while true (>! c (rand
> >>
> >> It doesn't know where/now the channel is consumed (which part of the
> point
> >> of channels/queues). However, we do know that at some point, nobody will
> >> need the result of our producing, so we should stop our activity.
> >>
> >> It seems to me that a natural way to tell the producer to stop is to
> close
> >> the channel. However:
> >>
> >> * there's nothing like a clojure.core.async/chan-closed? fn, AFAICT
> >> * The >! fn unconditionally returns nil, whether the channel is open or
> >> not. Only the blocking nature of the call can potentially vary - which
> is
> >> not particularly useful for the purpose.
> >>
> >> What would be an adequate way to indicate termination? Just telling the
> >> producer to stop (e.g. (reset! keep-producing false)) would break the
> >> indirection one gains by using channels.
> >>
> >> What if >! returned true/false depending on whether the value was put
> >> (because the channel was open)?
> >
> > --
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> your
> > first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
> > ---
> > You received this message because you are subscribed to the Google Groups
> > "Clojure" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to clojure+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>


-- 
“One of the main 

Re: core.async: communicating termination

2013-07-11 Thread Michał Marczyk
Hi Timothy,

That's very cool and very good to know!

Cheers,
M.


On 12 July 2013 00:56, Timothy Baldridge  wrote:
> It's interesting to note that blocking go blocks can actually be GC'd. For
> example, run this in a repl:
>
> (loop [] (let [c (chan)]
>  (go (>! c 42)))
>   (recur))
>
> On my box the CPU and memory spikes, but after I CTRL+C and kill the loop,
> the GC kicks in and collects all the channels and gos
>
> When go's are parked, they are put into a queue on the channel, thus when
> the channel is unreachable (besides inside the go block) both are collected,
> and the thread of execution is effectively terminated.
>
>
>
> Timothy
>
>
> On Thu, Jul 11, 2013 at 4:53 PM, Michał Marczyk 
> wrote:
>>
>> I think you could pass the producer a higher-order (chan 1) with the
>> actual communication channel placed in the buffer.
>>
>> Then at each step the producer would do
>>
>> (when-let [c (>   (>! c (rand))
>>   (>! communication-channel c))
>>
>> Once you close communication-channel, the put succeeds, but then the
>> take on communication-channel returns nil and the producer stops.
>>
>> Cheers,
>> M.
>>
>>
>> On 12 July 2013 00:37, Alex Miller  wrote:
>> > I haven't been in any discussions about this with the team, so it's
>> > entirely
>> > possible I am ignorant of some established future direction... but
>> >
>> > - "closed?" seems useful to me. (It may also be useful to ask "drained?"
>> > (closed + empty).)
>> > - >! returning an indicator of success also seems useful. However, since
>> > it
>> > executes asynchronously, I suspect adding that functionality may not be
>> > feasible (or may be feasible but incur a synchronization or complexity
>> > cost
>> > that is unacceptable).
>> >
>> > If you'd like to file a ticket at
>> > http://dev.clojure.org/jira/browse/ASYNC
>> > that would help to track the request.
>> >
>> > With respect to other strategies for dealing with this:
>> >
>> > 1) You could simply ignore the producer. If no one is requesting new
>> > values,
>> > the producer will not be run and no thread time should be consumed
>> > (there is
>> > of course heap being used). Not really recommending this but it's an
>> > option!
>> >
>> > 2) You could create a control channel for the producer (and other
>> > interested
>> > processes) that could transmit a stop message. Then alts! on the control
>> > channel in combination with the >! so that you're waiting on either the
>> > need
>> > to stop or the ability to put a new value in the channel.
>> >
>> > Alex
>> >
>> >
>> > On Thursday, July 11, 2013 7:16:56 AM UTC-5, vemv wrote:
>> >>
>> >> Consider a happy, oblivious producer of values:
>> >>
>> >> (def c (chan 42))
>> >>
>> >> (go (while true (>! c (rand
>> >>
>> >> It doesn't know where/now the channel is consumed (which part of the
>> >> point
>> >> of channels/queues). However, we do know that at some point, nobody
>> >> will
>> >> need the result of our producing, so we should stop our activity.
>> >>
>> >> It seems to me that a natural way to tell the producer to stop is to
>> >> close
>> >> the channel. However:
>> >>
>> >> * there's nothing like a clojure.core.async/chan-closed? fn, AFAICT
>> >> * The >! fn unconditionally returns nil, whether the channel is open or
>> >> not. Only the blocking nature of the call can potentially vary - which
>> >> is
>> >> not particularly useful for the purpose.
>> >>
>> >> What would be an adequate way to indicate termination? Just telling the
>> >> producer to stop (e.g. (reset! keep-producing false)) would break the
>> >> indirection one gains by using channels.
>> >>
>> >> What if >! returned true/false depending on whether the value was put
>> >> (because the channel was open)?
>> >
>> > --
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups "Clojure" group.
>> > To post to this group, send email to clojure@googlegroups.com
>> > Note that posts from new members are moderated - please be patient with
>> > your
>> > first post.
>> > To unsubscribe from this group, send email to
>> > clojure+unsubscr...@googlegroups.com
>> > For more options, visit this group at
>> > http://groups.google.com/group/clojure?hl=en
>> > ---
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Clojure" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> > an
>> > email to clojure+unsubscr...@googlegroups.com.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> 

Re: core.async: communicating termination

2013-07-11 Thread Michał Marczyk
As for the producer/consumer scheme with the higher-order channel, it
works in the single-producer case:

https://gist.github.com/michalmarczyk/5980097

(Actually this is simplified a bit in that it's also single consumer,
but that's not a feature of the approach, but rather my quick & dirty
poc.)

Multi-producer, single-consumer could be done dually.


On 12 July 2013 00:53, Michał Marczyk  wrote:
> I think you could pass the producer a higher-order (chan 1) with the
> actual communication channel placed in the buffer.
>
> Then at each step the producer would do
>
> (when-let [c (   (>! c (rand))
>   (>! communication-channel c))
>
> Once you close communication-channel, the put succeeds, but then the
> take on communication-channel returns nil and the producer stops.
>
> Cheers,
> M.
>
>
> On 12 July 2013 00:37, Alex Miller  wrote:
>> I haven't been in any discussions about this with the team, so it's entirely
>> possible I am ignorant of some established future direction... but
>>
>> - "closed?" seems useful to me. (It may also be useful to ask "drained?"
>> (closed + empty).)
>> - >! returning an indicator of success also seems useful. However, since it
>> executes asynchronously, I suspect adding that functionality may not be
>> feasible (or may be feasible but incur a synchronization or complexity cost
>> that is unacceptable).
>>
>> If you'd like to file a ticket at http://dev.clojure.org/jira/browse/ASYNC
>> that would help to track the request.
>>
>> With respect to other strategies for dealing with this:
>>
>> 1) You could simply ignore the producer. If no one is requesting new values,
>> the producer will not be run and no thread time should be consumed (there is
>> of course heap being used). Not really recommending this but it's an option!
>>
>> 2) You could create a control channel for the producer (and other interested
>> processes) that could transmit a stop message. Then alts! on the control
>> channel in combination with the >! so that you're waiting on either the need
>> to stop or the ability to put a new value in the channel.
>>
>> Alex
>>
>>
>> On Thursday, July 11, 2013 7:16:56 AM UTC-5, vemv wrote:
>>>
>>> Consider a happy, oblivious producer of values:
>>>
>>> (def c (chan 42))
>>>
>>> (go (while true (>! c (rand
>>>
>>> It doesn't know where/now the channel is consumed (which part of the point
>>> of channels/queues). However, we do know that at some point, nobody will
>>> need the result of our producing, so we should stop our activity.
>>>
>>> It seems to me that a natural way to tell the producer to stop is to close
>>> the channel. However:
>>>
>>> * there's nothing like a clojure.core.async/chan-closed? fn, AFAICT
>>> * The >! fn unconditionally returns nil, whether the channel is open or
>>> not. Only the blocking nature of the call can potentially vary - which is
>>> not particularly useful for the purpose.
>>>
>>> What would be an adequate way to indicate termination? Just telling the
>>> producer to stop (e.g. (reset! keep-producing false)) would break the
>>> indirection one gains by using channels.
>>>
>>> What if >! returned true/false depending on whether the value was put
>>> (because the channel was open)?
>>
>> --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with your
>> first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>

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




Re: Possible to add dependency within leiningen plugin dynamically?

2013-07-11 Thread Chris Kuttruff
Brilliant!  worked perfectly for me... found the magic you were referring 
to in load-deps ( 
https://github.com/kumarshantanu/lein-servlet/blob/master/plugin/src/leiningen/servlet.clj#L35
 
)
and the pomegranate/add-dependencies call ( 
https://github.com/cemerick/pomegranate/blob/master/src/main/clojure/cemerick/pomegranate.clj#L57
 
)

Thanks so much for sharing... btw, how does that require work for the 
pomegranate when it isn't listed in your project.clj dependencies.  seems 
like some chicken and egg type problem

-Chris


On Thursday, July 11, 2013 12:19:03 AM UTC-7, Shantanu Kumar wrote:
>
>
>
> On Thursday, 11 July 2013 12:24:34 UTC+5:30, Chris Kuttruff wrote:
>>
>> Eg: 
>>
>> I have a leiningen plugin I'm building that calls some jdbc stuff, but 
>> the specific driver would be specified in the project that brings in my 
>> plugin as a dependency.
>>
>
> Can you describe your use case with an example maybe? I am not sure if 
> it's similar to what you want, but some time back I wrote a plugin called 
> lein-servlet that can fetch a user-specified dependency (in project.clj) 
> from Clojars. Checking out the sample project.clj is pretty easy -- run the 
> following at command line:
>
> $ lein new lein-servlet foo
> $ cd foo
> $ lein servlet run  # Ctrl+C to stop
> $ # see the project.clj that uses Jetty by default
>
> The plugin is here:
>
> https://github.com/kumarshantanu/lein-servlet
>
> Shantanu
>

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




Re: core.async: communicating termination

2013-07-11 Thread Brandon Bloom
Wouldn't closed and drained predicates introduce race conditions?

(Sorry for brevity, on my phone)

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




[ANN] Proteus: local mutable variables for the masses

2013-07-11 Thread Zach Tellman
There was some discussion a few days ago about how the lack of local 
mutable variables were harming performance, or possibly elegance, I'm not 
sure.  Regardless, I fixed it: https://github.com/ztellman/proteus

Enjoy!

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




Re: core.async: communicating termination

2013-07-11 Thread Michał Marczyk
On 12 July 2013 01:08, Michał Marczyk  wrote:
> (Actually this is simplified a bit in that it's also single consumer,
> but that's not a feature of the approach, but rather my quick & dirty
> poc.)

Single consumer, multiple producers:

https://gist.github.com/michalmarczyk/5980700

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




Re: [ANN] Proteus: local mutable variables for the masses

2013-07-11 Thread Ben Wolfson
Note:

proteus> (defmacro aif [test then else]
   (let [it (first (filter #(not (contains? &env %))
   (cons 'it (map #(symbol (str "it-" %))
(iterate inc 1)]
 `(let [~it ~test] (if ~it ~then ~else
#'proteus/aif
proteus> (aif (get {:x {:y 3}} :x)
  (aif (get it :y)
   [it it-1]
   it)
  nil)
[{:y 3} 3]
proteus> (let-mutable [x 1]
  (aif (get {:x {:y 3}} :x)
   (aif (get it :y)
(set! x [it it-1])
(set! x it))
   (set! x nil))
  x)
CompilerException java.lang.RuntimeException: Unable to resolve symbol:
it-1 in this context, compiling:(NO_SOURCE_PATH:1:1)
proteus>




On Thu, Jul 11, 2013 at 6:16 PM, Zach Tellman  wrote:

> There was some discussion a few days ago about how the lack of local
> mutable variables were harming performance, or possibly elegance, I'm not
> sure.  Regardless, I fixed it: https://github.com/ztellman/proteus
>
> Enjoy!
>
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

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




Re: [ANN] Proteus: local mutable variables for the masses

2013-07-11 Thread Zach Tellman
Yeah, for safety's sake I need to macroexpand everything, which wipes out 
the &env for internal macros.  There might be a gentler way to do this, but 
it's not obvious to me.  If anyone has suggestions, I'd be interested in 
hearing them.

Zach

On Thursday, July 11, 2013 6:35:21 PM UTC-7, Ben wrote:
>
> Note:
>
> proteus> (defmacro aif [test then else]
>(let [it (first (filter #(not (contains? &env %))
>(cons 'it (map #(symbol (str "it-" %)) 
> (iterate inc 1)]
>  `(let [~it ~test] (if ~it ~then ~else
> #'proteus/aif
> proteus> (aif (get {:x {:y 3}} :x)
>   (aif (get it :y)
>[it it-1]
>it)
>   nil)
> [{:y 3} 3]
> proteus> (let-mutable [x 1]
>   (aif (get {:x {:y 3}} :x)
>(aif (get it :y)
> (set! x [it it-1])
> (set! x it))
>(set! x nil))
>   x)
> CompilerException java.lang.RuntimeException: Unable to resolve symbol: 
> it-1 in this context, compiling:(NO_SOURCE_PATH:1:1) 
> proteus> 
>
>
>
>
> On Thu, Jul 11, 2013 at 6:16 PM, Zach Tellman 
> > wrote:
>
>> There was some discussion a few days ago about how the lack of local 
>> mutable variables were harming performance, or possibly elegance, I'm not 
>> sure.  Regardless, I fixed it: https://github.com/ztellman/proteus
>>
>> Enjoy!
>>
>> -- 
>> -- 
>> 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/groups/opt_out.
>>  
>>  
>>
>
>
>
> -- 
> Ben Wolfson
> "Human kind has used its intelligence to vary the flavour of drinks, which 
> may be sweet, aromatic, fermented or spirit-based. ... Family and social 
> life also offer numerous other occasions to consume drinks for pleasure." 
> [Larousse, "Drink" entry]
>
>  

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




Re: [ANN] Proteus: local mutable variables for the masses

2013-07-11 Thread Ben Wolfson
On Thu, Jul 11, 2013 at 6:48 PM, Zach Tellman  wrote:

> Yeah, for safety's sake I need to macroexpand everything, which wipes out
> the &env for internal macros.  There might be a gentler way to do this, but
> it's not obvious to me.  If anyone has suggestions, I'd be interested in
> hearing them.


You can track the environment through expansion:

https://github.com/bwo/conditions/blob/master/test/conditions/free_test.clj#L19

The core.async internals do something similar (or did at the time of
release, that code has been rewritten, apparently).

You're also missing some binding forms:

proteus> (clojure.pprint/pprint (macroexpand-1 '(let-mutable [x 1] (try (/
1 0) (catch Exception x (set! x 2) x)
(clojure.core/let
 [x (new proteus.Containers$L 1)]
 (do
  (try
   (. clojure.lang.Numbers (divide 1 0))
   (catch Exception (.x x) (do (.set x 2) nil) (.x x)


proteus> (clojure.pprint/pprint (macroexpand-1 '(let-mutable [x 1] (letfn
[(x [] 4)] (set! x 4) x
(clojure.core/let
 [x (new proteus.Containers$L 1)]
 (do (letfn* [x (fn* x ([] 4))] (do (.set x 4) nil) (.x x




>
> Zach
>
>
> On Thursday, July 11, 2013 6:35:21 PM UTC-7, Ben wrote:
>
>> Note:
>>
>> proteus> (defmacro aif [test then else]
>>(let [it (first (filter #(not (contains? &env %))
>>   ** (cons 'it (map #(symbol (str "it-"
>> %)) (iterate inc 1)]
>>  `(let [~it ~test] (if ~it ~then ~else
>> #'proteus/aif
>> proteus> (aif (get {:x {:y 3}} :x)
>>   (aif (get it :y)
>>[it it-1]
>>it)
>>   nil)
>> [{:y 3} 3]
>> proteus> (let-mutable [x 1]
>>   (aif (get {:x {:y 3}} :x)
>>(aif (get it :y)
>>   **  (set! x [it it-1])
>>   **  (set! x it))
>>(set! x nil))
>>   x)
>> CompilerException java.lang.RuntimeException: Unable to resolve symbol:
>> it-1 in this context, compiling:(NO_SOURCE_PATH:1:1)
>> proteus>
>>
>>
>>
>>
>> On Thu, Jul 11, 2013 at 6:16 PM, Zach Tellman  wrote:
>>
>>> There was some discussion a few days ago about how the lack of local
>>> mutable variables were harming performance, or possibly elegance, I'm not
>>> sure.  Regardless, I fixed it: 
>>> https://github.com/**ztellman/proteus
>>>
>>> Enjoy!
>>>
>>> --
>>> --
>>> 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/**groups/opt_out
>>> .
>>>
>>>
>>>
>>
>>
>>
>> --
>> Ben Wolfson
>> "Human kind has used its intelligence to vary the flavour of drinks,
>> which may be sweet, aromatic, fermented or spirit-based. ... Family and
>> social life also offer numerous other occasions to consume drinks for
>> pleasure." [Larousse, "Drink" entry]
>>
>>   --
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Ben Wolfson
"Human kind has used its intelligence to vary the flavour of drinks, which
may be sweet, aromatic, fermented or spirit-based. ... Family and social
life also offer numerous other occasions to consume drinks for pleasure."
[Larousse, "Drink" entry]

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

Re: [ANN] Proteus: local mutable variables for the masses

2013-07-11 Thread Zach Tellman
It looks like the macroexpansion code in conditions.free is fairly generic.
 What would you say to putting it into its own library?


On Thu, Jul 11, 2013 at 6:54 PM, Ben Wolfson  wrote:

> On Thu, Jul 11, 2013 at 6:48 PM, Zach Tellman  wrote:
>
>> Yeah, for safety's sake I need to macroexpand everything, which wipes out
>> the &env for internal macros.  There might be a gentler way to do this, but
>> it's not obvious to me.  If anyone has suggestions, I'd be interested in
>> hearing them.
>
>
> You can track the environment through expansion:
>
>
> https://github.com/bwo/conditions/blob/master/test/conditions/free_test.clj#L19
>
> The core.async internals do something similar (or did at the time of
> release, that code has been rewritten, apparently).
>
> You're also missing some binding forms:
>
> proteus> (clojure.pprint/pprint (macroexpand-1 '(let-mutable [x 1] (try (/
> 1 0) (catch Exception x (set! x 2) x)
> (clojure.core/let
>  [x (new proteus.Containers$L 1)]
>  (do
>   (try
>(. clojure.lang.Numbers (divide 1 0))
>(catch Exception (.x x) (do (.set x 2) nil) (.x x)
>
>
> proteus> (clojure.pprint/pprint (macroexpand-1 '(let-mutable [x 1] (letfn
> [(x [] 4)] (set! x 4) x
> (clojure.core/let
>  [x (new proteus.Containers$L 1)]
>  (do (letfn* [x (fn* x ([] 4))] (do (.set x 4) nil) (.x x
>
>
>
>
>>
>> Zach
>>
>>
>> On Thursday, July 11, 2013 6:35:21 PM UTC-7, Ben wrote:
>>
>>> Note:
>>>
>>> proteus> (defmacro aif [test then else]
>>>(let [it (first (filter #(not (contains? &env %))
>>>   ** (cons 'it (map #(symbol (str "it-"
>>> %)) (iterate inc 1)]
>>>  `(let [~it ~test] (if ~it ~then ~else
>>> #'proteus/aif
>>> proteus> (aif (get {:x {:y 3}} :x)
>>>   (aif (get it :y)
>>>[it it-1]
>>>it)
>>>   nil)
>>> [{:y 3} 3]
>>> proteus> (let-mutable [x 1]
>>>   (aif (get {:x {:y 3}} :x)
>>>(aif (get it :y)
>>>   **  (set! x [it it-1])
>>>   **  (set! x it))
>>>(set! x nil))
>>>   x)
>>> CompilerException java.lang.RuntimeException: Unable to resolve symbol:
>>> it-1 in this context, compiling:(NO_SOURCE_PATH:1:1)
>>> proteus>
>>>
>>>
>>>
>>>
>>> On Thu, Jul 11, 2013 at 6:16 PM, Zach Tellman  wrote:
>>>
 There was some discussion a few days ago about how the lack of local
 mutable variables were harming performance, or possibly elegance, I'm not
 sure.  Regardless, I fixed it: 
 https://github.com/**ztellman/proteus

 Enjoy!

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



>>>
>>>
>>>
>>> --
>>> Ben Wolfson
>>> "Human kind has used its intelligence to vary the flavour of drinks,
>>> which may be sweet, aromatic, fermented or spirit-based. ... Family and
>>> social life also offer numerous other occasions to consume drinks for
>>> pleasure." [Larousse, "Drink" entry]
>>>
>>>   --
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> Ben Wolfson
> "Human kind has used its intelligence to vary the flavour of drinks, which
> may be sweet, aromatic, fermented or spirit-based. ... Family and social
> life also offer numerous other occasions to consume drinks for pleasure."
> [Larousse, "Drink" entry]
>
>  --
> --
> You r

Re: Clojure: One language to rule the Web

2013-07-11 Thread Kelker Ryan
Sorry, but I don't have any plans on adding AS2/3 or XML support by default. Thanks! The framework is currently Alpha and I just added auto-documenting features for the JSON API. https://github.com/runexec/chp/releases/tag/v.0.162-alpha  CHTML, Routing, and Sessions CHTML & RoutesSession handling, Cookies, and Compojure Ring Ring and port configurationAuto-loading middleware Code Generation, Modules, and JSON API Generating views from a tableView bindingsView bindings ExampleEnable admin accountDatabase and Bindings tutorialHTML GenerationCSS Generation_javascript_ GenerationCHP ModulesModule PackagesJSON APIAuto Documenting API SQL Configuration, Migrations, and Manipulation SQL DB configuration and creationSQL DB MigrationsSQL ManipulationGet column syntax example General Information InstallUML RelationshipsUnit TestsRemoving example filesLicenseHow?Tutorial  12.07.2013, 05:14, "Alexander Gunnarson" :With the exception of XML and Flash, my framework covers all of that https://github.com/runexec/chp  Your framework seems very promising. I'll have to play around with it. Any plans for extending it to enclose XML? ActionScript/Flash seems to have been addressed somewhat by las3r on GitHub, but time will tell whether it's really up for use in production. The author hasn't updated it in two years already, so it seems somewhat dead. It'll be interesting to see what some key Clojure contributors have to say about plans to make a unified Clojure framework to encompass all the frontend and backend technologies out there. It seems like you've gotten much of the way there.



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


Re: Clojure: One language to rule the Web

2013-07-11 Thread Kelker Ryan
Try these.

http://www.clojuresphere.com/
http://www.clojure-toolbox.com/
https://clojure-libraries.appspot.com/


12.07.2013, 05:32, "Alexander Gunnarson" :
> As a side note, maybe we can keep a running list of "Clojure-ized" 
> technologies we're aware of:- XML - clojure/data.xml
>   - XLink + XPointer + XQuery - clojure/data.xml
> - JSON - Clojure Home Page (CHP)
> - HTML - Hiccup
>   - XHTML - ?
> - CSS - Garden
> - JavaScript + jQuery - ClojureScript
> - Java - (Already available)
> - Flash: SVG + ActionScript - las3r (partially?)
> - SQL - Korma
>
> On second appraisal, it seems like Clojure has got pretty much all of these 
> under control.

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




Re: [ANN] Proteus: local mutable variables for the masses

2013-07-11 Thread Ben Wolfson
Sure, I was considering that anyway. I'm not sure, though, whether it
should be in its own library all by its lonesome or in one with at least a
fairly generic name, since I've got some other macro-related utilities
(specifically https://github.com/bwo/macroparser) that could all be
usefully (I think) grouped together.


On Thu, Jul 11, 2013 at 7:02 PM, Zach Tellman  wrote:

> It looks like the macroexpansion code in conditions.free is fairly
> generic.  What would you say to putting it into its own library?
>
>
> On Thu, Jul 11, 2013 at 6:54 PM, Ben Wolfson  wrote:
>
>> On Thu, Jul 11, 2013 at 6:48 PM, Zach Tellman  wrote:
>>
>>> Yeah, for safety's sake I need to macroexpand everything, which wipes
>>> out the &env for internal macros.  There might be a gentler way to do this,
>>> but it's not obvious to me.  If anyone has suggestions, I'd be interested
>>> in hearing them.
>>
>>
>> You can track the environment through expansion:
>>
>>
>> https://github.com/bwo/conditions/blob/master/test/conditions/free_test.clj#L19
>>
>> The core.async internals do something similar (or did at the time of
>> release, that code has been rewritten, apparently).
>>
>> You're also missing some binding forms:
>>
>> proteus> (clojure.pprint/pprint (macroexpand-1 '(let-mutable [x 1] (try
>> (/ 1 0) (catch Exception x (set! x 2) x)
>> (clojure.core/let
>>  [x (new proteus.Containers$L 1)]
>>  (do
>>   (try
>>(. clojure.lang.Numbers (divide 1 0))
>>(catch Exception (.x x) (do (.set x 2) nil) (.x x)
>>
>>
>> proteus> (clojure.pprint/pprint (macroexpand-1 '(let-mutable [x 1] (letfn
>> [(x [] 4)] (set! x 4) x
>> (clojure.core/let
>>  [x (new proteus.Containers$L 1)]
>>  (do (letfn* [x (fn* x ([] 4))] (do (.set x 4) nil) (.x x
>>
>>
>>
>>
>>>
>>> Zach
>>>
>>>
>>> On Thursday, July 11, 2013 6:35:21 PM UTC-7, Ben wrote:
>>>
 Note:

 proteus> (defmacro aif [test then else]
(let [it (first (filter #(not (contains? &env %))
   ** (cons 'it (map #(symbol (str
 "it-" %)) (iterate inc 1)]
  `(let [~it ~test] (if ~it ~then ~else
 #'proteus/aif
 proteus> (aif (get {:x {:y 3}} :x)
   (aif (get it :y)
[it it-1]
it)
   nil)
 [{:y 3} 3]
 proteus> (let-mutable [x 1]
   (aif (get {:x {:y 3}} :x)
(aif (get it :y)
   **  (set! x [it it-1])
   **  (set! x it))
(set! x nil))
   x)
 CompilerException java.lang.RuntimeException: Unable to resolve symbol:
 it-1 in this context, compiling:(NO_SOURCE_PATH:1:1)
 proteus>




 On Thu, Jul 11, 2013 at 6:16 PM, Zach Tellman wrote:

> There was some discussion a few days ago about how the lack of local
> mutable variables were harming performance, or possibly elegance, I'm not
> sure.  Regardless, I fixed it: 
> https://github.com/**ztellman/proteus
>
> Enjoy!
>
> --
> --
> 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/**groups/opt_out
> .
>
>
>



 --
 Ben Wolfson
 "Human kind has used its intelligence to vary the flavour of drinks,
 which may be sweet, aromatic, fermented or spirit-based. ... Family and
 social life also offer numerous other occasions to consume drinks for
 pleasure." [Larousse, "Drink" entry]

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

Re: Making RPCs with Shoreleave

2013-07-11 Thread Samrat Man Singh
I think you need to (use projectname.ajax) in your projectname.handler 
page. If I remember correctly, there's also a way to specify which 
namespace your remote function is in.

On Thursday, July 11, 2013 10:42:15 PM UTC+5:45, Alex Fowler wrote:
>
> Hi all, this is my first experience with Shoreleave and I'm trying to use 
> it's RPC mechanism to perform AJAX tasks. However, on a call to a remote 
> procedure, I get this:
>
> `
>
>1. POST http://localhost:8080/_shoreleave 404 (Not Found) 
> cljs.js:25223
>   1. goog.net.XhrIo.sendcljs.js:25223
>   2. xhr__delegatecljs.js:31416 
>   3. xhrcljs.js:31423 
>   4. 
> remote_callback__delegatecljs.js:32504
>   5. remote_callbackcljs.js:32515 
>   6. load_storecljs.js:32745 
>   7. 
> mk__AMPERSAND__load_store__delegatecljs.js:32755
>   8. 
> mk__AMPERSAND__load_storecljs.js:32763
>   9. example_storecljs.js:33341 
>   10. simplecljs.js:33361 
>   11. setup_guicljs.js:33962 
>   12. setup_allcljs.js:33982 
>   13. startupcljs.js:41166 
>   14. onloadapp:2 
>   
> XHR ERROR: Not Found 
> `
>
> What is wrong and how do I fix it? I have been following this tutorial: 
> Shoreleave 
> Tutorial 10 - Introducing 
> Ajax 
> my 
> code (relevant parts) is this:
>
> Project.clj:
> `
> (defproject projectname "0.1.0-SNAPSHOT"
>   :description "FIXME: write description"
>   :url "http://example.com/FIXME";
>   :dependencies [[org.clojure/clojure "1.5.1"]
>  [lib-noir "0.6.3"]
>  [compojure "1.2.0-SNAPSHOT"]
>  [ring-server "0.2.8"]
>  [clabango "0.5"]
>  [hiccup "1.0.3"]
>  [com.taoensso/timbre "2.1.2"]
>  [com.taoensso/tower "1.7.1"]
>  [markdown-clj "0.9.26"]
>
>  ; -- ajax
>  [shoreleave "0.3.0"]
>  [shoreleave/shoreleave-remote-ring "0.3.0"]
>  [shoreleave/shoreleave-remote "0.3.0"]
>  
>  ; -- cljs
>  [com.keminglabs/singult "0.1.6"]
>  [enfocus "1.0.1"]
>  [jayq "2.3.0"]
>  ]
>   :plugins [[lein-ring "0.8.5"]
> [lein-cljsbuild "0.3.2"]]
>   :hooks [leiningen.cljsbuild]
>   :cljsbuild {
>   :builds [{
> :jar true
> :source-paths ["src/family/webapp"]
> :compiler {
>:output-to "resources/public/js/cljs.js"
>:optimizations :whitespace
>:externs ["externs/jquery-1.9.js"]
>:pretty-print true}}]}
>   :ring {:handler projectname.handler/war-handler
>  :initprojectname.handler/init
>  :destroy projectname.handler/destroy}
>   :profiles
>   {:production {:ring {:open-browser? false
>:stacktraces?  false
>:auto-reload?  false}}
>:dev {:dependencies [[ring-mock "0.1.5"]
> [ring/ring-devel "1.1.8"]]}}
>   :min-lein-version "2.0.0")
> `
>
> Handler:
> `
> (ns projectname.handler
>   (:use projectname.routes.home
> compojure.core)
>   (:require [noir.util.middleware :as middleware]
> [compojure.route :as route]
> [shoreleave.middleware.rpc :refer [wrap-rpc]]))
>
> (def all-routes [home-routes app-routes])
>
> (def app (-> all-routes
>  middleware/app-handler
>  wrap-rpc
>  ;;add your middlewares here
>  ))
>
> (def war-handler (middleware/war-handler app))
> ` 
>
> Remote procedure declaration:
> `
> (ns projectname.ajax
>   (:require [shoreleave.middleware.rpc :refer [defremote]]))
>
> (defremote my-remote-proc [some-arg] (println "remote call ok" some-arg) 
> some-arg)
> `
>
> Client side ClojureScript code:
> `
> (ns projectname.webapp.model.store
>   (:require
> [shoreleave.remotes.http-rpc :refer [remote-callback]]))
>
> (defn do-smth-useful [useful-args]
>   (log "This is the last log statement that get's printed")
>   (remote-callback :my-remote-proc [useful-args] #(process-feedback %))
> `
>
> Thanks!
>

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

Re: Possible to add dependency within leiningen plugin dynamically?

2013-07-11 Thread Shantanu Kumar


On Friday, 12 July 2013 05:00:43 UTC+5:30, Chris Kuttruff wrote:
>
> Brilliant!  worked perfectly for me... found the magic you were referring 
> to in load-deps ( 
> https://github.com/kumarshantanu/lein-servlet/blob/master/plugin/src/leiningen/servlet.clj#L35)
> and the pomegranate/add-dependencies call ( 
> https://github.com/cemerick/pomegranate/blob/master/src/main/clojure/cemerick/pomegranate.clj#L57)
>
> Thanks so much for sharing... btw, how does that require work for the 
> pomegranate when it isn't listed in your project.clj dependencies.  seems 
> like some chicken and egg type problem
>

Glad it worked for you. Pomegranate is included as one of Leiningen's 
dependency so it's available to all leiningen plugins by default. More 
specifically, Leiningen depends on Leiningen-core, which in turn depends on 
Pomegranate as you can see at the URLs below:

https://github.com/technomancy/leiningen/blob/master/project.clj#L9

https://github.com/technomancy/leiningen/blob/master/leiningen-core/project.clj#L11

Shantanu

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




Re: Group words by their first letter and sum their frequencies

2013-07-11 Thread James Trunk
Hi Andy,

I'd missed the more recent versions with tool-tips, thank you for pointing 
me to them.

Regards,
James

On Thursday, July 11, 2013 5:11:21 PM UTC+2, Andy Fingerhut wrote:
>
> There is a link "Download other versions with tooltips" near the top of 
> the Clojure Cheat Sheet page (http://clojure.org/cheatsheet) that links 
> to versions that are a bit more recent, and they include tooltips of the 
> doc strings when you hover your cursor over the symbol.
>
> The version at clojure.org/cheatsheet gets updated less frequently, 
> simply because I have to ask someone else to do it who has the necessary 
> permissions.  I'll ask again now.
>
> Andy
>
>
> On Thu, Jul 11, 2013 at 6:50 AM, James Trunk 
> > wrote:
>
>> Hello Laurent,
>>
>> Thank you so much for your detailed and helpful reply.
>>
>> > You could use the new as-> macro in clojure 1.5 
>> Is it possible to get as-> to work with thread-last?
>>
>> > depends :-) since your 2 fns are helper fns rather than 
>> > generically-reusable fns, I would make them private to enforce that : 
>> > (defn- ...)
>> Good point, and I'll definitely try to remember that in the future.
>>
>> > May I suggest alternative implementations ?
>> > 
>> I really like both of your alternative solutions, and have learned 
>> several new ideas from them. Thank you.
>>
>> By the way, I'm using the Clojure Cheat Sheet (
>> http://clojure.org/cheatsheet) as my guide to the core functions, but it 
>> doesn't seem to be up-to-date with all these fancy 1.5 functions that 
>> you're using. Is there a new website that has superseded CCS? Do you know 
>> why CCS isn't kept up-to-date?
>>
>> Regards,
>> James
>>
>> On Thursday, July 11, 2013 2:29:38 PM UTC+2, Laurent PETIT wrote:
>>
>>> Hello James, 
>>>
>>> 2013/7/11 James Trunk : 
>>> > Hi everyone, I'm new to Clojure and trying to learn my way around the 
>>> > language. 
>>> > 
>>> > I've written a function that sums the frequencies of words starting 
>>> with the 
>>> > same letter, however I'm not fully satisfied with the result. I'm 
>>> striving 
>>> > for readability and idomaticity, but I fear that my rather limited 
>>> grasp of 
>>> > Clojure's core functions and lack of experience with functional 
>>> programming 
>>> > are letting me down on both counts. 
>>> > 
>>> > (def text (slurp 
>>> > "http://www.ccel.org/ccel/**bible/kjv.txt"))
>>> >  
>>>
>>> > 
>>> > (defn sum-last-elements [coll] 
>>> >   (reduce + (map last coll))) 
>>> > 
>>> > (defn group-first-elements [coll] 
>>> >   (map first coll)) 
>>> > 
>>> > (->> text 
>>> >  (re-seq 
>>> > #"(?:(?:\bm[a|e]n\b)|(?:\bwom[**a|e]n\b)|(?:\bchild\b)|(?:\**bchildren\b))")
>>> >  
>>>
>>> >  frequencies 
>>> >  (group-by ffirst) 
>>> >  vals 
>>> >  (#(zipmap (map group-first-elements %) (map sum-last-elements 
>>> % 
>>> > 
>>> > Which on that file gives the result: 
>>> > 
>>> > {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 5314} 
>>> > 
>>> > My questions: 
>>> > 
>>> > Is there a way to avoid using ?: everywhere in the regex? 
>>> > (group-by ffirst) vals - is there a more 
>>> readable/declarative/idiomatic way 
>>> > to group by first letter? 
>>>
>>> you could first (group-by first), then create the final map by calling 
>>> (distinct) and count 
>>>
>>> > Is there a trick to avoid the ugly looking anonymous function (which 
>>> I'm 
>>> > only using to reorder the thread-last argument)? 
>>>
>>> You could use the new as-> macro in clojure 1.5 
>>>
>>> > Is it idiomatic to extract small functions to give them names (with an 
>>> eye 
>>> > to aiding readability) or would most Clojure programmers prefer these 
>>> to be 
>>> > anonymous and in-line? 
>>>
>>> depends :-) since your 2 fns are helper fns rather than 
>>> generically-reusable fns, I would make them private to enforce that : 
>>> (defn- ...) 
>>>
>>> > Is thread-last the right approach when dealing with nested 
>>> data-structures 
>>> > or is list comprehension, or some other approach preferred? 
>>>
>>> The thread-last as you employed it is fine by me. 
>>>
>>> May I suggest alternative implementations ? 
>>>
>>> (def text (slurp 
>>> "http://www.ccel.org/ccel/**bible/kjv.txt"))
>>>  
>>>
>>> (let [words (re-seq 
>>> #"(?:(?:\bm[a|e]n\b)|(?:\bwom[**a|e]n\b)|(?:\bchild\b)|(?:\**bchildren\b))" 
>>>
>>> text) 
>>>words-per-initial (vals (group-by first words))] 
>>>   (zipmap 
>>> (map distinct words-per-initial) 
>>> (map count words-per-initial))) 
>>>
>>> ;; => {("woman" "women") 663, ("children" "child") 2274, ("men" "man") 
>>> 5314} 
>>>
>>>
>>>
>>> or to avoid the intermediary creation of seqs of distincts and seqs of 
>>> counts: 
>>>
>>> (defn- reduce-initial [m initial initial-words] 
>>>   (assoc m (distinct initial-words) (count initial-words))) 
>>>
>>> (let [words (re-seq 
>>> #"(?:(?:\bm[a|e]n\b)|(?:\bwom[**a|e]n\b)|(?:\bchild\b)|(?:\**bchildren\b))"