Re: A doubt about core.matrix

2016-02-16 Thread Mikera
Hi Sunil,

You are correct that the naive code will eagerly produce the full matrix 
UxV, which may be very large :-)

I think your strategy of extracting rows and columns from U and V is the 
best one. Row and column extraction for dense matrices in vectorz-clj is 
very efficient since it just uses strided vectors, as is the dot product 
operation, so you probably won't see much of a performance overhead from 
doing it this way. I wouldn't worry about the verbosity - obviously you 
should encapsulate this logic in a function if you are doing it in many 
places.

Top tip: also remember to use (non-zero-indices W) if you want to know 
which elements of the sparse matrix are non-zero without iterating over 
every element

  Mike. 

On Tuesday, 16 February 2016 23:17:52 UTC+8, Sunil Nandihalli wrote:
>
> Hi Everybody,
>  I am newbie to core.matrix .. I have the following expression
>
> W -> a large spare matrix of size MxN
> U  -> a dense matrix of size MxK
> V ->  a dense matrix of size KxN
>
> and K << (M,N)
> (require [clojure.core.matrix :as m])
>
> I want to compute (m/mul W (m/* U V))
>
> m/mul computes element-wise product
>
> m/*  computes regular matrix multiplication
>
> I want to know if the above would compute full-matrix UV .. if it does 
> then I want to know if there is an elegant way to compute the 
> spare-resultant matrix without blowing up memory in the intermediate stage
>
> I am currently just extracting the corresponding rows and columns from U 
> and V for the elements which are non-zero in W .. but that seems 
> unnecessarily verbose...
>
> I am using the vectorz implementation of core.matrix
>
> Thanks in advance.
>
> Sunil.
>

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


[ANN] Clojure/west 2016 speakers list now available!

2016-02-16 Thread Alex Miller
Clojure/west 2016 will be held Apr 15-16 in Seattle, WA. 
http://clojurewest.org

You can now find the full list of speakers 
at http://clojurewest.org/speakers! We had a fantastic set of proposals 
(115) this year and an excellent program as a result.

I also want to highlight our keynote speaker, Matthias Felleisen, who has 
been the shepherd for Racket for many years. Matthias will be presenting 
his talk "Types Are Like The Weather, Type Systems Are Like Weathermen" for 
Clojure/west.

Registration is available now at https://ti.to/cognitect/clojure-west-2016 
- hope to see you there!

If you have any questions, please contact us at eve...@cognitect.com.

Alex

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


Re: Datascript return values

2016-02-16 Thread Jonah Benton
Hey Derek-

Your datascript query is actually returning a set- syntax is #{}- of array
elements, also called "tuples". You can treat the set as a sequence, use
doseq to visit each item, and destructuring on the items to assign
individual array/tuple members to symbols.

For instance, say that each array item has 2 elements, which semantically
you think of as name and value. You can do something like this:

(let [results (d/q q-list @conn)]
  (doseq [[name value] results]
(println (str "name: " name " has value: " value

Does that help?

Jonah


On Tue, Feb 16, 2016 at 11:38 AM, Derek Frost  wrote:

> I need some advice about return values please.  I'm using Datascript on
> the console with clojure and I'm doing this to get values from the d/b
> (println(d/q q-list @conn)) which gives me a hash-map of arrays.  I'm
> trying to put values in a text file to convert to pdf - this is a bit mad
> but it's just to see if I can move some stuff away from xslt.  Well I can
> get at individual values doing something like this (def
> -main[](println(first(d/q etc... but it seems really messy.  When I try
> to do this in a let block I get arity problems and I also tried passing
> this to a str then to the third argument of spit to create a text file.
> Ideally I'm trying to format the output with newlines which I know how to
> do but I can't figure out how to nest the d/b results into a variable.
>
> So my question is, is there a nicer way of putting my bulk return values
> into a variable?  If I could do that, I think I could figure the rest out.
> Many thanks.  I'm relatively new to clojure but I have some experience in
> scheme and lisp...
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Datascript return values

2016-02-16 Thread Derek Frost
I need some advice about return values please.  I'm using Datascript on the 
console with clojure and I'm doing this to get values from the d/b 
(println(d/q q-list @conn)) which gives me a hash-map of arrays.  I'm 
trying to put values in a text file to convert to pdf - this is a bit mad 
but it's just to see if I can move some stuff away from xslt.  Well I can 
get at individual values doing something like this (def 
-main[](println(first(d/q etc... but it seems really messy.  When I try 
to do this in a let block I get arity problems and I also tried passing 
this to a str then to the third argument of spit to create a text file.  
Ideally I'm trying to format the output with newlines which I know how to 
do but I can't figure out how to nest the d/b results into a variable.

So my question is, is there a nicer way of putting my bulk return values 
into a variable?  If I could do that, I think I could figure the rest out.  
Many thanks.  I'm relatively new to clojure but I have some experience in 
scheme and lisp...

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


Re: Command Interpreter in Clojure?

2016-02-16 Thread Jason Felice
Here are some thoughts from having done similar things:

1. Don't invent a syntax, as we already have lisp.  If the parens
intimidate people, just inserting the outermost set for each line will get
you a long way.  e.g.

(clojure.edn/read-string (str "(" line ")"))

2. Make a multimethod to dispatch the first element of the list.  (Not
eval, or apply, since security is a concern.)  If you want nested
expressions, a simple evaluator does essentially this, except evaluates
arguments first.

With a little finess, you could instead allow only public symbols from a
specific namespace in the first position, and call those functions in a
secure way.

3. JLine is the command-line editing library that's like readline for Java.




On Tue, Feb 16, 2016 at 8:06 AM, Nick Vargish  wrote:

> My current project requires a command-line interpreter with limited
> functionality... For various non-technical reasons we can't expose bash to
> our users.
>
> Our plans call for writing a console shell that will accept some limited
> command set, and Clojure would be the natural implementation language,
> since much of our functionality has been implemented in a Clojure library.
> We even have a command-line tool that exposes a lot of the functionality to
> shell scripts, but the parsing/function routing is quite primitive...
>
> Any suggestions? Has anyone done work on a CLI implemented in Clojure?
>
> Thanks,
>
> Nick
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Command Interpreter in Clojure?

2016-02-16 Thread Jonah Benton
Hey Nick, tools.cli is great for interpretation of command line arguments
to a program; to actually provide a user with your own
limited-functionality shell, take a look at wrapping JLine:

https://github.com/jline/jline2

along the lines of what Reply did:

https://github.com/trptcolin/reply/tree/master/src/clj/reply/reader

Good luck,

Jonah


On Tue, Feb 16, 2016 at 9:42 AM, Alan Thompson  wrote:

> Have you seen this:
>
> https://github.com/clojure/tools.cli
>
> https://github.com/clojure-cookbook/clojure-cookbook/blob/master/03_general-computing/3-07_parse-command-line-arguments.asciidoc
>
> Alan
>
> On Tue, Feb 16, 2016 at 5:06 AM, Nick Vargish 
> wrote:
>
>> My current project requires a command-line interpreter with limited
>> functionality... For various non-technical reasons we can't expose bash to
>> our users.
>>
>> Our plans call for writing a console shell that will accept some limited
>> command set, and Clojure would be the natural implementation language,
>> since much of our functionality has been implemented in a Clojure library.
>> We even have a command-line tool that exposes a lot of the functionality to
>> shell scripts, but the parsing/function routing is quite primitive...
>>
>> Any suggestions? Has anyone done work on a CLI implemented in Clojure?
>>
>> Thanks,
>>
>> Nick
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clojure@googlegroups.com
>> Note that posts from new members are moderated - please be patient with
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+unsubscr...@googlegroups.com
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> ---
>> You received this message because you are subscribed to the Google Groups
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to clojure+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Trouble replacing deprecated map< function

2016-02-16 Thread James Reeves
Thanks for the reply. Now that you point it out, I see what you mean about
channels being queues, rather than generic communication streams.

Perhaps rather than return a bidirectional channel, Chord should instead
return two channels, one for input and one for output. Or perhaps it should
take them as an argument, allowing for transducers to be used directly.

- James

On 15 February 2016 at 20:24, Francis Avila  wrote:

> I think the difficulty here is that Chord has a bidirectional channel,
> where putting and taking operate on different "streams" inside the channel.
> (Internally, Chord is actually using a different channel for reads and
> writes. It constructs the "joined" channel using chord.channels/bidi-ch)
>
> I don't think this was envisioned as a proper way to use channels. I think
> they were envisioned as a queue, and queues hold values, not communication
> streams. When you put onto a channel, it contains what you put until you
> take it off. (Note that channels with attached transducers must be buffered
> because it needs a place to hold the result of the reduction step.) A Chord
> channel isn't like this: when you put on it, the value is gone, and
> different values from some other place appear when you take from it.  The
> more usual solution is to use a pair of channels.
>
> map<, map>, etc happened to work because they always put/take a value
> unchanged in the opposite direction onto the transformed channel.
>
> I suspect the core developers were only using map>, map< et al in
> pipelines (where transducers are fine) and not realizing people were using
> them in a way that relied on the other direction being pass-through.
>
> You will always need either a pair of channels to undo the unification
> done by Chord, or you will need to implement a channel (using reify and the
> WritePort and ReadPort protocols) where take and put mean different things
> and you can attach a transducer independently to each. Something like that
> would probably not make it in to core because it encourages the use of
> Chord-style "multistream" channels.
>
> You could try something like this:
>
> (defn eduction> [xform ch]
>   (let [in-stream (chan 1 xform)
> out-stream (chan)]
> (pipe in-stream ch)
> (pipe ch out-stream)
> (chord.channels/bidi-ch in-stream out-stream)))
>
> Of course it would be more efficient to use reify and implement the
> channel interfaces directly, like map> does, but with transducer semantics
> for f (including the finalize arity and when the f is called).
>
>
> On Friday, February 12, 2016 at 1:41:20 PM UTC-6, James Reeves wrote:
>>
>> I currently have some core.async code that looks like:
>>
>> (map< :foo ch)
>>
>> However, map< and map> are now deprecated, with the suggestion to use
>> transducers instead. Unfortunately it's not obvious how to go about that.
>>
>> At first I thought that I could use a pipe and a new channel:
>>
>> (pipe ch (chan 1 (map :foo)))
>>
>> But there's no distinction between channel input and output here. This
>> matters because I'm using a bidirectional channel from Chord
>> .
>>
>> I'm thinking that it would be nice to have some functions like:
>>
>> (eduction< ch xform)
>> (eduction> ch xform)
>> (eduction ch xform)
>>
>> So I could write something like:
>>
>> (eduction< ch (map :foo))
>>
>> Have I missed anything? Is there some equivalent to this functionality
>> already in core.async that I haven't noticed?
>>
>> - James
>>
>

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


A doubt about core.matrix

2016-02-16 Thread Sunil S Nandihalli
Hi Everybody,
 I am newbie to core.matrix .. I have the following expression

W -> a large spare matrix of size MxN
U  -> a dense matrix of size MxK
V ->  a dense matrix of size KxN

and K << (M,N)
(require [clojure.core.matrix :as m])

I want to compute (m/mul W (m/* U V))

m/mul computes element-wise product

m/*  computes regular matrix multiplication

I want to know if the above would compute full-matrix UV .. if it does then
I want to know if there is an elegant way to compute the spare-resultant
matrix without blowing up memory in the intermediate stage

I am currently just extracting the corresponding rows and columns from U
and V for the elements which are non-zero in W .. but that seems
unnecessarily verbose...

I am using the vectorz implementation of core.matrix

Thanks in advance.

Sunil.

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


Re: Command Interpreter in Clojure?

2016-02-16 Thread Alan Thompson
Have you seen this:

https://github.com/clojure/tools.cli
https://github.com/clojure-cookbook/clojure-cookbook/blob/master/03_general-computing/3-07_parse-command-line-arguments.asciidoc

Alan

On Tue, Feb 16, 2016 at 5:06 AM, Nick Vargish  wrote:

> My current project requires a command-line interpreter with limited
> functionality... For various non-technical reasons we can't expose bash to
> our users.
>
> Our plans call for writing a console shell that will accept some limited
> command set, and Clojure would be the natural implementation language,
> since much of our functionality has been implemented in a Clojure library.
> We even have a command-line tool that exposes a lot of the functionality to
> shell scripts, but the parsing/function routing is quite primitive...
>
> Any suggestions? Has anyone done work on a CLI implemented in Clojure?
>
> Thanks,
>
> Nick
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

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


Command Interpreter in Clojure?

2016-02-16 Thread Nick Vargish
My current project requires a command-line interpreter with limited 
functionality... For various non-technical reasons we can't expose bash to 
our users.

Our plans call for writing a console shell that will accept some limited 
command set, and Clojure would be the natural implementation language, 
since much of our functionality has been implemented in a Clojure library. 
We even have a command-line tool that exposes a lot of the functionality to 
shell scripts, but the parsing/function routing is quite primitive...

Any suggestions? Has anyone done work on a CLI implemented in Clojure?

Thanks,

Nick



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


Re: [ANN] Graclj 0.1.0 -- New Gradle Plugin for Clojure

2016-02-16 Thread 'Sven Richter' via Clojure
I wanted to thank you for stepping up on this. As gradle is getting more 
and more used in a lot of environments a working clojure plugin for gradle 
would be awesome.

Best Regards,
Sven

Am Montag, 15. Februar 2016 03:11:00 UTC+1 schrieb Andrew Oberstar:
>
> I just released the first version of Graclj, which is a new Gradle plugin 
> for Clojure. The goal is to make something that feels native to Gradle, 
> while giving the creature comforts Clojurians are used to from lein or 
> boot. For those familiar with Gradle, this targets their new (and still 
> evolving) software model support.
>
> Current features include:
>
> - Packaging Clojure code into JARs
> - AOT compilation
> - clojure.test execution
> - Publishing to any repo supported by Gradle (including Clojars)
>
> I wouldn't suggest dropping your current build tool yet, but if you'd like 
> to try it out, you can walk through the learning-graclj repo. I'd welcome 
> any feedback on the plugin or documentation.
>
> Source: https://github.com/graclj/graclj
> Documentation: 
> https://github.com/graclj/learning-graclj/tree/learning-0.1.0
>
> Thanks,
> Andrew Oberstar
>
>

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