Re: Recursive definition in core.logic

2014-09-22 Thread Joshua Ballanco
On Sunday, September 21, 2014 at 21:40, Tassilo Horn wrote:
> I think instead of `conde' you can use `conda' here, because when the
> first clause succeeds the second one cannot succeed and doesn't need to
>  


Careful with the use of `conde` vs `conda`, as `conda` is an early cut. In 
other words, if you substituted `conda` in Tassilo’s solution, and you had 
multiple generations, then `descendants` would only find the first generation 
of descendants. If you wanted to find *all* descendants, then you need `conde`.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from 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: Surprised by behaviour of `compile` vs positional constructor fns

2014-09-22 Thread Jozef Wagner
It looks like following not so well known bug
http://dev.clojure.org/jira/browse/CLJ-979

On Mon, Sep 22, 2014 at 8:55 AM, Peter Taoussanis  wrote:
> Hi all!
>
> Ran into some behaviour today that I wasn't expecting and am wondering if
> someone could shed some light.
>
> Steps to reproduce (reproducible with at least Clojure 1.4.0 and
> 1.7.0-alpha2):
> 1. Setup a namespace with `(defrecord Foo [x])`.
> 2. Call cider's `cider-load-current-buffer` in Emacs.
> 3. Evaluate `(compile ')` in that namespace.
>
> At this point, we have:
>
> (instance? Foo (Foo.  "bar")) => true
> (instance? Foo (->Foo "bar")) => false
>
> I wouldn't normally call `compile` like this, but I'm curious if someone has
> any idea what's actually happening? The `build-positional-factory` code
> seems to just call the `new` constructor anyway so it's not obvious to me
> why the behaviour would differ. Are the class files getting out of sync
> somehow?
>
> Thanks a lot, cheers! :-)
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from 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: Surprised by behaviour of `compile` vs positional constructor fns

2014-09-22 Thread Peter Taoussanis
Hi Jozef, thanks a lot for the pointer - that does seem to be the cause! 
Will continue to track from there.

Cheers :-)

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


Re: clojure.org uses a wikispaces TLS certificate

2014-09-22 Thread Laurens Van Houtven
Hi Alex,

On 20 Sep 2014, at 20:20, Alex Miller  wrote:

> Clojure.org is hosted on wikispaces. For what purpose would you access it by 
> https?

It’s not a (purposeful) choice; my browser is configured to access any site 
that supports it over HTTPS.

Since this is intentional, I have simply instructed it to remember this 
(Wikispaces) certificate as the certificate for Clojure.org.

thanks
lvh


signature.asc
Description: Message signed with OpenPGP using GPGMail


[ANN] clecs 1.0.1

2014-09-22 Thread Atamert Ölçgen
clecs is an entity-component-system framework for Clojure.

The repo is here: https://github.com/muhuk/clecs

Changes Since Version 0.2.x

* Replaced function based queries with data driven queries.


-- 
Kind Regards,
Atamert Ölçgen

-+-
--+
+++

www.muhuk.com

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


`remove-ns' prevents namespace from being reloaded by `require' in clj 1.5.1 and 1.6

2014-09-22 Thread Daniel König
Hi,

after removing a namespace with the remove-ns form, I am not able to 
require it a second time.
>From what I can tell, I should be able to reload a namespace after removing 
it.
This behaviour was found in Clojure 1.5.1 and Clojure 1.6.

Example:

=> (require 'config :reload)
nil
=> (remove-ns 'config)
#
=> (require 'config :reload)
nil
=> (remove-ns 'config)
nil



Is this intentional or can it be considered broken?

Best regards,
Daniel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from 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] Clojure Videos (with options for Linux users)

2014-09-22 Thread Mateusz Fiołka

Paypal payment option would be nice.


On Friday, September 19, 2014 2:51:46 AM UTC+2, tbc++ wrote:
>
> Just wanted to throw this out there, but I've been making steady progress 
> on my Clojure Tutorial Videos (https://tbaldridge.pivotshare.com). We're 
> up to 43 videos with new episodes added at a rate of about 2-3 a week. 
>
> Some users have expressed a desire for the raw MP4 files for use on Linux, 
> or other platforms where flash is not optimal, so I'm also happy to 
> announce that the videos are available via Dropbox. There's a link on the 
> site, the price is the same, but the process is manual so there is a 
> processing delay of 1-2 days. 
>
> Thanks to everyone who's offered encouragement and feedback. And 
> yes...transducer videos will be up *soon*. They're recorded, but you should 
> really start by watching the video of Rich's Strange Loop talk, that he'll 
> be giving tomorrow. 
>
> 
>

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


Re: clojure.org uses a wikispaces TLS certificate

2014-09-22 Thread Alex Miller
It is likely that at some point in the future, clojure.org will be hosted 
elsewhere. For now, this doesn't seem to be a high priority to address so I 
don't plan to do anything about it (presumably it would be difficult to do 
so).

On Monday, September 22, 2014 7:02:06 AM UTC-5, Laurens Van Houtven wrote:
>
> Hi Alex, 
>
> On 20 Sep 2014, at 20:20, Alex Miller > 
> wrote: 
>
> > Clojure.org is hosted on wikispaces. For what purpose would you access 
> it by https? 
>
> It’s not a (purposeful) choice; my browser is configured to access any 
> site that supports it over HTTPS. 
>
> Since this is intentional, I have simply instructed it to remember this 
> (Wikispaces) certificate as the certificate for Clojure.org. 
>
> thanks 
> lvh 
>

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


Re: clojure.org uses a wikispaces TLS certificate

2014-09-22 Thread Laurens Van Houtven
On 22 Sep 2014, at 17:30, Alex Miller  wrote:

> It is likely that at some point in the future, clojure.org will be hosted 
> elsewhere. For now, this doesn't seem to be a high priority to address so I 
> don't plan to do anything about it (presumably it would be difficult to do 
> so).

Absolutely. I just wanted to report the issue, not insist that it’s fixed right 
away.

Thanks!
lvh



signature.asc
Description: Message signed with OpenPGP using GPGMail


[ANN] lein-plz "0.3.0" - Add dependencies quickly

2014-09-22 Thread john walker
Hi everyone,

lein-plz is a plugin for adding dependencies quickly. It lets you do things 
like


$ lein plz add cljs core.async

instead of editing the project.clj directly. @luxbock 
 added ~450 new builtins from crossclj.info and 
a list task that simplifies searching builtins. For example:


$ lein plz list ring

+---++
| Dependency| Nickname(s)|
+---++
| im.chit/hara.common.string| hara.common.string |
| ring/ring-devel   | ring-devel |
| metosin/ring-http-response| ring-http-response |
| im.chit/hara.string.path  | hara.string.path   |
| metosin/ring-swagger-ui   | ring-swagger-ui|
| ring-anti-forgery | ring-anti-forgery  |
| ring/ring-jetty-adapter   | ring-jetty-adapter |
| ring/ring-json| ring-json  |
| ring-refresh  | ring-refresh   |
| shoreleave/shoreleave-remote-ring | shoreleave-remote-ring |
| ring-mock | ring-mock  |
| ring  | ring   |
| metosin/ring-swagger  | ring-swagger   |
| ring-cors | ring-cors  |
| ring-serve| ring-serve |
| ring/ring-codec   | ring-codec |
| ring-server   | ring-server|
| ring/ring-servlet | ring-servlet   |
| ring-reload-modified  | ring-reload-modified   |
| org.maravillas/ring-core-gae  | ring-core-gae  |
| ring/ring-core| ring-core  |
| ring-middleware-format| ring-middleware-format |
+---++

You can get these changes in the latest version with coordinates [lein-plz 
"0.3.0"]. As usual, let me know if you have ideas to share!

https://github.com/johnwalker/lein-plz

John

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from 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: `remove-ns' prevents namespace from being reloaded by `require' in clj 1.5.1 and 1.6

2014-09-22 Thread Laurent PETIT
I think it is broken, and I think I know who the culprit may be (me).

Before 1.5.1 (I guess), it was impossible to do things like that from e.g.
a live repl session:

(ns a)

(ns b (:require a))


because somehow the filesystem for ns a would be checked, no file found.

So a check was added to see whether ns a is already loaded or not, and if
already loaded, not try to reach for the filesystem.

It's weird, because I think I had checked that it wouldn't affect :reload /
:reload-all options, and all unit tests passed at that time.











2014-09-22 16:04 GMT+02:00 Daniel König :

> Hi,
>
> after removing a namespace with the remove-ns form, I am not able to
> require it a second time.
> From what I can tell, I should be able to reload a namespace after
> removing it.
> This behaviour was found in Clojure 1.5.1 and Clojure 1.6.
>
> Example:
>
> => (require 'config :reload)
> nil
> => (remove-ns 'config)
> #
> => (require 'config :reload)
> nil
> => (remove-ns 'config)
> nil
>
>
>
> Is this intentional or can it be considered broken?
>
> Best regards,
> Daniel
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from 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.
>



-- 
Laurent Petit

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


Re: [ANN] Clojure Videos (with options for Linux users)

2014-09-22 Thread Bozhidar Batsov
I was thinking the same thing. Lack of paypal support is the only reason I 
haven’t subscribed yet…

Not sure if it’s something supported by pivotshare, though.

—
Cheers, 
Bozhidar

On September 22, 2014 at 5:52:05 PM, Mateusz Fiołka (mateusz.fio...@gmail.com) 
wrote:


Paypal payment option would be nice.


On Friday, September 19, 2014 2:51:46 AM UTC+2, tbc++ wrote:
Just wanted to throw this out there, but I've been making steady progress on my 
Clojure Tutorial Videos (https://tbaldridge.pivotshare.com). We're up to 43 
videos with new episodes added at a rate of about 2-3 a week. 

Some users have expressed a desire for the raw MP4 files for use on Linux, or 
other platforms where flash is not optimal, so I'm also happy to announce that 
the videos are available via Dropbox. There's a link on the site, the price is 
the same, but the process is manual so there is a processing delay of 1-2 days. 

Thanks to everyone who's offered encouragement and feedback. And 
yes...transducer videos will be up *soon*. They're recorded, but you should 
really start by watching the video of Rich's Strange Loop talk, that he'll be 
giving tomorrow. 


--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from 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: [ANN] Clojure Videos (with options for Linux users)

2014-09-22 Thread Timothy Baldridge
If you don't mind using Dropbox instead of Pivotshare, the "Linux option" I
described is exactly that, you sign up via PayPal and I manually add you to
the Dropbox share. The link for Paypal is at the bottom of the site:
https://tbaldridge.pivotshare.com/

Timothy Baldridge

On Mon, Sep 22, 2014 at 10:21 AM, Bozhidar Batsov  wrote:

> I was thinking the same thing. Lack of paypal support is the only reason I
> haven’t subscribed yet…
>
> Not sure if it’s something supported by pivotshare, though.
>
> —
> Cheers,
> Bozhidar
>
> On September 22, 2014 at 5:52:05 PM, Mateusz Fiołka (
> mateusz.fio...@gmail.com) wrote:
>
>
> Paypal payment option would be nice.
>
>
> On Friday, September 19, 2014 2:51:46 AM UTC+2, tbc++ wrote:
>>
>> Just wanted to throw this out there, but I've been making steady progress
>> on my Clojure Tutorial Videos (https://tbaldridge.pivotshare.com). We're
>> up to 43 videos with new episodes added at a rate of about 2-3 a week.
>>
>> Some users have expressed a desire for the raw MP4 files for use on
>> Linux, or other platforms where flash is not optimal, so I'm also happy to
>> announce that the videos are available via Dropbox. There's a link on the
>> site, the price is the same, but the process is manual so there is a
>> processing delay of 1-2 days.
>>
>> Thanks to everyone who's offered encouragement and feedback. And
>> yes...transducer videos will be up *soon*. They're recorded, but you should
>> really start by watching the video of Rich's Strange Loop talk, that he'll
>> be giving tomorrow.
>>
>> 
>>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from 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.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from 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: Eager (cat) in transducers

2014-09-22 Thread Alex Miller
This is an excellent question and the answer is: no, there is not a clever 
way (or a desire) to avoid this.

The internals of transducer functions are never lazy. Each "step" will be 
eagerly completed for each output element. This is a fundamental difference 
between the lazy sequence and transducer approaches. 

On Sunday, September 21, 2014 11:16:47 AM UTC-5, Glen Mailer wrote:
>
> While watching Rich's strangeloop talk, I noticed a slight oddity in the 
> definition of mapcat.
>
> I brought this up briefly in the IRC channel yesterday and the general 
> consensus seemed to be that this is awkward, but not easily solvable:
>
> The original lazy definition of (mapcat) uses (concat), and concat 
> explicitly uses a lazy sequence:
>
> https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L679
>
> The reducers defintion of (mapcat), like all reducers, explicitly uses 
> (reduce)
>
> https://github.com/clojure/clojure/blob/f3259f4f34a68eae7db7efc0be9d19fa5dafbd3c/src/clj/clojure/core/reducers.clj#L171
>
>
> As I understand it, part of the goals of transducers is to unify the 
> similar patterns seen in reducers, lazy-sequences and elsewhere.
>
>
> However, transducers' (mapcat) is currently implemented via a new core 
> function called (cat)
>
> https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L2648 
> 
>
> https://github.com/clojure/clojure/blob/master/src/clj/clojure/core.clj#L7221 
> 
>
> (cat) unfortunately contains an explicit call to (reduce), which makes the 
> (map) part eager, here's an example of something that works with the 
> previous mapcat, but not with the tranducers flavour:
>
> (take 3 (mapcat repeat [1]))
> ; => (1 1 1)
> (take 3 (sequence (mapcat repeat) [1]))
> ; => #
>
> Despite asking for a lazy transducer implementation, we get an eager step.
>
> Is there some clever way to avoid this? I believe this applies generally 
> to any transducer which calls the step function multiple times. 
> Conceptually I think that transducer processor would have to wrap the step 
> function in some way to make it act like a continuation to enforce laziness 
> with the executing transducer?
>
>
> Hopefully that all makes sense!
>

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


Clojure beginner: angst about "doing things right"

2014-09-22 Thread J David Eisenberg
As part of a larger program, I'm testing a function that will turn a string 
of days on which a class occurs (such as "MWF") into a list of seven 
numbers: (1 0 1 0 1 0 0).
I first translate"TH" (Thursday) to "R" and "SU" (Sunday) to "N" to make 
things a bit easier.

I came up with the following code:

(defn days-number-maker
  "Recursively compare first item in days of week with
first item in string of days. If matching, add a 1,
else add a zero to the result"
  [all-days day-string result]
  (if (empty? all-days) (reverse result)
(if (= (first all-days) (first day-string))
  (recur (rest all-days)(rest day-string) (conj result 1))
  (recur (rest all-days) day-string (conj result 0)

(defn days-to-numbers
  "Change string like MTTH to (1 1 0 1 0 0 0)"
  [day-string]
  (let [days (clojure.string/replace
   (clojure.string/replace day-string #"TH" "R") #"SU" "N")]
(days-number-maker "MTWRFSN" days (list

The good news: the code works. The bad news: I'm convinced I'm doing it 
wrong, in the moral purity sense of the word. Something inside of me says, 
"You could have just used (map...) to do this the *right* way," but I can't 
see how to do it with (map). So, my two questions are:

1) Is there such a thing as "the Clojure way," and if so,
2) How can I rewrite the code to be more Clojure-ish?

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

2014-09-22 Thread Leon Grapenthin
The steps of your transducer composition are depending on each other. They 
can only produce a result from an input if they process it synchronously. 
If you had 
> Because it's Node-JS environment, and that can be the same for any async 
> Javascript, you never wanna call sync operations (like sync ajax) because 
> they block everything...
>
> I was noticing that is a non-issue at all in Java world, since you can 
> always read blocking into the predicate, for example: (filter (comp  my-chan-pred))
>
> But in Javascript that's not possible since it can't support read blocking.
>
> ---
> Wilker Lúcio
> http://about.me/wilkerlucio/bio
> Woboinc Consultant
> +55 81 82556600
>
> On Sun, Sep 21, 2014 at 8:50 PM, Leon Grapenthin  > wrote:
>
>> Why would you want the the predicates and readdir to return channels?
>>
>> On Monday, September 22, 2014 12:14:27 AM UTC+2, Wilker wrote:
>>>
>>> Just an add,
>>>
>>> I was thinking if we could have something like a "deref" running during 
>>> the transducers, in order to enable value unwrapping (that way we could 
>>> handle channels/values in same fashion). I understand that is complicated 
>>> maybe because overhead, and also more tricky into JS world were you can't 
>>> deref a channel into a sync fashion.
>>>
>>> But the point remains, there is way to seamlessly handle async and sync 
>>> operations using the same transducers? Or something like it.
>>>
>>> Best regards.
>>>
>>> ---
>>> Wilker Lúcio
>>> http://about.me/wilkerlucio/bio
>>> Woboinc Consultant
>>> +55 81 82556600
>>>
>>> On Sun, Sep 21, 2014 at 7:01 PM, Wilker  wrote:
>>>
 Hi guys,

 I'm playing with transducers here, and trying out stuff just for fun, 
 there is something that I'm kind stuck on how to approach. I understand 
 the 
 great abstraction that transducers provide over don't carrying about the 
 input source type, but I'm struggling to deal with async operations into 
 my 
 pipeline.

 For example, I'm working with Node.JS async API's for file system 
 operations, I want to stick with the async versions since I don't wanna 
 block the event loop of Node.

 So, let's say I have a source with ["dir", "other"] and I wanna create 
 an operation that will simple filter which paths exists, are directories, 
 and then list the `ls` of each remaining entry.

 So, I first created "channel returning" functions for the Node 
 operations, I'll not put the code here because I don't think it's really 
 relevant here, just consider that I have them.

 So, my pipeline would start looking something like this:

 (comp (filter exists?)
   (filter is-dir?)
   (mapcat readdir))

 Of course, this doesn't works... Because `exists?`, `is-dir?` and 
 `readdir`, all of them return channels, so the filter would always pass 
 since a channel is always a valid value... The same applies to mapcat, it 
 would try to concat into a channel...

 This is making me notice some barrier to be able to compose async 
 operations with regular operations.

 Maybe would be possible to "sign" somehow operations to make then run 
 async?

 The only viable option that I've found is with pipeline-async, which 
 accepts an async function, but that doesn't composes with the other 
 operations (map, filter, drop-while...)

 Is there already a solution to that? Or maybe I'm just doing it wrong 
 and there is a better way to handle those cases?

 I would love to know how you guys are handling those kind of situations.

 Thanks.

 ---
 Wilker Lúcio
 http://about.me/wilkerlucio/bio
 Woboinc Consultant
 +55 81 82556600
  
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google
>> Groups "Clojure" group.
>> To post to this group, send email to clo...@googlegroups.com 
>> 
>> Note that posts from new members are moderated - please be patient with 
>> your first post.
>> To unsubscribe from this group, send email to
>> clojure+u...@googlegroups.com 
>> For more options, visit this group at
>> http://groups.google.com/group/clojure?hl=en
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "Clojure" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to clojure+u...@googlegroups.com .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

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

Re: Clojure beginner: angst about "doing things right"

2014-09-22 Thread Timothy Baldridge
I'm not completely sure what you're trying to do, but I think reduce can
help you here. For example:

(reduce
  (fn [acc x]
(if (odd? x)
(conj acc x)
acc))
  []
  [1 2 3 4 5 6])

returns:

[1 3 5]

Reduce is good for when you want iterate over one data structure and
optionally update another data structure.

Timothy

On Mon, Sep 22, 2014 at 12:45 PM, J David Eisenberg <
jdavid.eisenb...@gmail.com> wrote:

> As part of a larger program, I'm testing a function that will turn a
> string of days on which a class occurs (such as "MWF") into a list of seven
> numbers: (1 0 1 0 1 0 0).
> I first translate"TH" (Thursday) to "R" and "SU" (Sunday) to "N" to make
> things a bit easier.
>
> I came up with the following code:
>
> (defn days-number-maker
>   "Recursively compare first item in days of week with
> first item in string of days. If matching, add a 1,
> else add a zero to the result"
>   [all-days day-string result]
>   (if (empty? all-days) (reverse result)
> (if (= (first all-days) (first day-string))
>   (recur (rest all-days)(rest day-string) (conj result 1))
>   (recur (rest all-days) day-string (conj result 0)
>
> (defn days-to-numbers
>   "Change string like MTTH to (1 1 0 1 0 0 0)"
>   [day-string]
>   (let [days (clojure.string/replace
>(clojure.string/replace day-string #"TH" "R") #"SU" "N")]
> (days-number-maker "MTWRFSN" days (list
>
> The good news: the code works. The bad news: I'm convinced I'm doing it
> wrong, in the moral purity sense of the word. Something inside of me says,
> "You could have just used (map...) to do this the *right* way," but I can't
> see how to do it with (map). So, my two questions are:
>
> 1) Is there such a thing as "the Clojure way," and if so,
> 2) How can I rewrite the code to be more Clojure-ish?
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from 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.
>



-- 
“One of the main causes of the fall of the Roman Empire was that–lacking
zero–they had no way to indicate successful termination of their C
programs.”
(Robert Firth)

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

2014-09-22 Thread Wilker
I understand Leon, but all that only applies on Java world... The issue
here is because I depend on async stuff, in Java you always have options to
do it sync, you don't need any of those callbacks at all, this is a JS API
issue. So in my case I really need the async factor here, I can't avoid it.

Given that, would be possible to make transducers async? I think the big
deal of transducers is exactly don't having to re-write map, filter, etc...
That's why I'm really trying to get then to work on this situation, unless
someone knows for sure that its not possible, than I can accept the
limitations and keep all my custom versions that can handle async
processing...

Thanks.

---
Wilker Lúcio
http://about.me/wilkerlucio/bio
Woboinc Consultant
+55 81 82556600

On Mon, Sep 22, 2014 at 4:22 PM, Leon Grapenthin 
wrote:

> The steps of your transducer composition are depending on each other. They
> can only produce a result from an input if they process it synchronously.
> If you had  reenforce synchronous input processing: Once you would consume an item, the
> code would have the exact same blocking characteristics as if the functions
> were returning values instead of channels. You would have gained nothing
> for the cost of creating overhead.
>
>
> On Monday, September 22, 2014 1:53:52 AM UTC+2, Wilker wrote:
>>
>> Because it's Node-JS environment, and that can be the same for any async
>> Javascript, you never wanna call sync operations (like sync ajax) because
>> they block everything...
>>
>> I was noticing that is a non-issue at all in Java world, since you can
>> always read blocking into the predicate, for example: (filter (comp > my-chan-pred))
>>
>> But in Javascript that's not possible since it can't support read
>> blocking.
>>
>> ---
>> Wilker Lúcio
>> http://about.me/wilkerlucio/bio
>> Woboinc Consultant
>> +55 81 82556600
>>
>> On Sun, Sep 21, 2014 at 8:50 PM, Leon Grapenthin 
>> wrote:
>>
>>> Why would you want the the predicates and readdir to return channels?
>>>
>>> On Monday, September 22, 2014 12:14:27 AM UTC+2, Wilker wrote:

 Just an add,

 I was thinking if we could have something like a "deref" running during
 the transducers, in order to enable value unwrapping (that way we could
 handle channels/values in same fashion). I understand that is complicated
 maybe because overhead, and also more tricky into JS world were you can't
 deref a channel into a sync fashion.

 But the point remains, there is way to seamlessly handle async and sync
 operations using the same transducers? Or something like it.

 Best regards.

 ---
 Wilker Lúcio
 http://about.me/wilkerlucio/bio
 Woboinc Consultant
 +55 81 82556600

 On Sun, Sep 21, 2014 at 7:01 PM, Wilker  wrote:

> Hi guys,
>
> I'm playing with transducers here, and trying out stuff just for fun,
> there is something that I'm kind stuck on how to approach. I understand 
> the
> great abstraction that transducers provide over don't carrying about the
> input source type, but I'm struggling to deal with async operations into 
> my
> pipeline.
>
> For example, I'm working with Node.JS async API's for file system
> operations, I want to stick with the async versions since I don't wanna
> block the event loop of Node.
>
> So, let's say I have a source with ["dir", "other"] and I wanna create
> an operation that will simple filter which paths exists, are directories,
> and then list the `ls` of each remaining entry.
>
> So, I first created "channel returning" functions for the Node
> operations, I'll not put the code here because I don't think it's really
> relevant here, just consider that I have them.
>
> So, my pipeline would start looking something like this:
>
> (comp (filter exists?)
>   (filter is-dir?)
>   (mapcat readdir))
>
> Of course, this doesn't works... Because `exists?`, `is-dir?` and
> `readdir`, all of them return channels, so the filter would always pass
> since a channel is always a valid value... The same applies to mapcat, it
> would try to concat into a channel...
>
> This is making me notice some barrier to be able to compose async
> operations with regular operations.
>
> Maybe would be possible to "sign" somehow operations to make then run
> async?
>
> The only viable option that I've found is with pipeline-async, which
> accepts an async function, but that doesn't composes with the other
> operations (map, filter, drop-while...)
>
> Is there already a solution to that? Or maybe I'm just doing it wrong
> and there is a better way to handle those cases?
>
> I would love to know how you guys are handling those kind of
> situations.
>
> Thanks.
>
> ---
> Wilker Lúcio
> http://about.me/wilkerlucio/bio
> Woboinc Consultant
>

Re: Clojure beginner: angst about "doing things right"

2014-09-22 Thread Tobias Kortkamp

Using map and sets:

(defn days-number-maker
  [all-days day-string]
  (let [day-set (set day-string)]
(map (fn [day]
   (if (day-set day)
 1
 0))
 all-days)))

(defn days-to-numbers
  "Change string like MTTH to (1 1 0 1 0 0 0)"
  [day-string]
  (let [days (clojure.string/replace
   (clojure.string/replace day-string #"TH" "R") #"SU" "N")]
(days-number-maker "MTWRFSN" days)))

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

To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Clojure beginner: angst about "doing things right"

2014-09-22 Thread Ray Miller
A general rule of thumb is to prefer higher-order functions to explicit
recursion. When you are trying to accumulate something (here, you are
accumulating a list of zeroes and ones), you can usually use reduce. This
is a little bit more tricky here as you need to keep track of which bits of
the input string you have consumed as well as your accumulator:

(defn days-to-numbers
  [day-string]
  (first (reduce (fn [[accum day-string] day]
   (let [next-day-string (clojure.string/replace day-string
day "")]
 [(conj accum (if (= day-string next-day-string) 0 1))
  next-day-string]))
 ['() day-string]
 ["SU" "S" "F" "TH" "W" "T" "M"])))

We'd have to work a bit harder if we weren't so lucky with the order the
two-character days appear above, as we *must* inspect the string for SU
before S and TH before T. But here we can get away with it.

Equivalently, but with an explicit loop/recur:

(defn days-to-numbers
  [day-string]
  (loop [day-string day-string days ["SU" "S" "F" "TH" "W" "T" "M"] accum
'()]
(if-let [day (first days)]
  (let [next-day-string (clojure.string/replace day-string day "")]
(recur next-day-string
   (rest days)
   (conj accum (if (= day-string next-day-string) 0 1
  accum)))

Another note on your code, you'll commonly see the thread-first macro used
to avoid nested calls to functions like clojure.string/replace; if you
(require '[clojure.string :as str]) you could then write:

(-> day-string (str/replace "SU" "N") (str/replace "TH" "R"))

Ray.

On 22 September 2014 19:45, J David Eisenberg 
wrote:

> As part of a larger program, I'm testing a function that will turn a
> string of days on which a class occurs (such as "MWF") into a list of seven
> numbers: (1 0 1 0 1 0 0).
> I first translate"TH" (Thursday) to "R" and "SU" (Sunday) to "N" to make
> things a bit easier.
>
> I came up with the following code:
>
> (defn days-number-maker
>   "Recursively compare first item in days of week with
> first item in string of days. If matching, add a 1,
> else add a zero to the result"
>   [all-days day-string result]
>   (if (empty? all-days) (reverse result)
> (if (= (first all-days) (first day-string))
>   (recur (rest all-days)(rest day-string) (conj result 1))
>   (recur (rest all-days) day-string (conj result 0)
>
> (defn days-to-numbers
>   "Change string like MTTH to (1 1 0 1 0 0 0)"
>   [day-string]
>   (let [days (clojure.string/replace
>(clojure.string/replace day-string #"TH" "R") #"SU" "N")]
> (days-number-maker "MTWRFSN" days (list
>
> The good news: the code works. The bad news: I'm convinced I'm doing it
> wrong, in the moral purity sense of the word. Something inside of me says,
> "You could have just used (map...) to do this the *right* way," but I can't
> see how to do it with (map). So, my two questions are:
>
> 1) Is there such a thing as "the Clojure way," and if so,
> 2) How can I rewrite the code to be more Clojure-ish?
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from 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: Working on a patch to add Clojure for Spring dynamic language support

2014-09-22 Thread henrik42
Hi Adan,

not sure if it helps, but defining Spring beans that call Clojure code is 
straight forward:



  

  

  

You can find more examples at https://github.com/henrik42/spring-break
I've played around with the Spring scpting API but as far as I can tell it
won't let you define BeanFactoryPostProcessor that Spring picks up when
it starts up the application context. So I tried to get away without using 
that.
What do you think?

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

2014-09-22 Thread Leon Grapenthin
I don't see a way for a reducing function to make its return value depend 
on the result of another callback. 


On Monday, September 22, 2014 9:45:15 PM UTC+2, Wilker wrote:
>
> I understand Leon, but all that only applies on Java world... The issue 
> here is because I depend on async stuff, in Java you always have options to 
> do it sync, you don't need any of those callbacks at all, this is a JS API 
> issue. So in my case I really need the async factor here, I can't avoid it.
>
> Given that, would be possible to make transducers async? I think the big 
> deal of transducers is exactly don't having to re-write map, filter, etc... 
> That's why I'm really trying to get then to work on this situation, unless 
> someone knows for sure that its not possible, than I can accept the 
> limitations and keep all my custom versions that can handle async 
> processing...
>
> Thanks.
>
> ---
> Wilker Lúcio
> http://about.me/wilkerlucio/bio
> Woboinc Consultant
> +55 81 82556600
>
> On Mon, Sep 22, 2014 at 4:22 PM, Leon Grapenthin  > wrote:
>
>> The steps of your transducer composition are depending on each other. 
>> They can only produce a result from an input if they process it 
>> synchronously. If you had > described, you would reenforce synchronous input processing: Once you would 
>> consume an item, the code would have the exact same blocking 
>> characteristics as if the functions were returning values instead of 
>> channels. You would have gained nothing for the cost of creating 
>> overhead. 
>>
>>
>> On Monday, September 22, 2014 1:53:52 AM UTC+2, Wilker wrote:
>>>
>>> Because it's Node-JS environment, and that can be the same for any async 
>>> Javascript, you never wanna call sync operations (like sync ajax) because 
>>> they block everything...
>>>
>>> I was noticing that is a non-issue at all in Java world, since you can 
>>> always read blocking into the predicate, for example: (filter (comp >> my-chan-pred))
>>>
>>> But in Javascript that's not possible since it can't support read 
>>> blocking.
>>>
>>> ---
>>> Wilker Lúcio
>>> http://about.me/wilkerlucio/bio
>>> Woboinc Consultant
>>> +55 81 82556600
>>>
>>> On Sun, Sep 21, 2014 at 8:50 PM, Leon Grapenthin  
>>> wrote:
>>>
 Why would you want the the predicates and readdir to return channels?

 On Monday, September 22, 2014 12:14:27 AM UTC+2, Wilker wrote:
>
> Just an add,
>
> I was thinking if we could have something like a "deref" running 
> during the transducers, in order to enable value unwrapping (that way we 
> could handle channels/values in same fashion). I understand that is 
> complicated maybe because overhead, and also more tricky into JS world 
> were 
> you can't deref a channel into a sync fashion.
>
> But the point remains, there is way to seamlessly handle async and 
> sync operations using the same transducers? Or something like it.
>
> Best regards.
>
> ---
> Wilker Lúcio
> http://about.me/wilkerlucio/bio
> Woboinc Consultant
> +55 81 82556600
>
> On Sun, Sep 21, 2014 at 7:01 PM, Wilker  wrote:
>
>> Hi guys,
>>
>> I'm playing with transducers here, and trying out stuff just for fun, 
>> there is something that I'm kind stuck on how to approach. I understand 
>> the 
>> great abstraction that transducers provide over don't carrying about the 
>> input source type, but I'm struggling to deal with async operations into 
>> my 
>> pipeline.
>>
>> For example, I'm working with Node.JS async API's for file system 
>> operations, I want to stick with the async versions since I don't wanna 
>> block the event loop of Node.
>>
>> So, let's say I have a source with ["dir", "other"] and I wanna 
>> create an operation that will simple filter which paths exists, are 
>> directories, and then list the `ls` of each remaining entry.
>>
>> So, I first created "channel returning" functions for the Node 
>> operations, I'll not put the code here because I don't think it's really 
>> relevant here, just consider that I have them.
>>
>> So, my pipeline would start looking something like this:
>>
>> (comp (filter exists?)
>>   (filter is-dir?)
>>   (mapcat readdir))
>>
>> Of course, this doesn't works... Because `exists?`, `is-dir?` and 
>> `readdir`, all of them return channels, so the filter would always pass 
>> since a channel is always a valid value... The same applies to mapcat, 
>> it 
>> would try to concat into a channel...
>>
>> This is making me notice some barrier to be able to compose async 
>> operations with regular operations.
>>
>> Maybe would be possible to "sign" somehow operations to make then run 
>> async?
>>
>> The only viable option that I've found is with pipeline-async, which 
>> accepts an async function, but that doesn't composes with the othe

Re: `remove-ns' prevents namespace from being reloaded by `require' in clj 1.5.1 and 1.6

2014-09-22 Thread Stuart Sierra
I'm not sure I understand what you mean.

`remove-ns` does not remove the namespace from the set of "loaded" 
namespaces kept by `require`.  tools.namespace 
 has a hack 

 
to work around this.

But `require ... :reload` should still work.

-S


On Monday, September 22, 2014 10:04:49 AM UTC-4, Daniel König wrote:
>
> Hi,
>
> after removing a namespace with the remove-ns form, I am not able to 
> require it a second time.
> From what I can tell, I should be able to reload a namespace after 
> removing it.
> This behaviour was found in Clojure 1.5.1 and Clojure 1.6.
>
> Example:
>
> => (require 'config :reload)
> nil
> => (remove-ns 'config)
> #
> => (require 'config :reload)
> nil
> => (remove-ns 'config)
> nil
>
>
>
> Is this intentional or can it be considered broken?
>
> Best regards,
> Daniel
>

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


Re: Clojure beginner: angst about "doing things right"

2014-09-22 Thread Alex Walker
For a "do it with (map)" mindset, think in terms of list processing or a 
conveyer belt, where a series of pure functions transforms a value in a 
small but significant way.  

1. Imho, the clojure-way is to apply the set of principles outlined by Rich 
and FP using the idioms established by the community.
2. https://gist.github.com/alexpw/e72c998b0d0be0daaaf2

On Monday, September 22, 2014 1:45:23 PM UTC-5, J David Eisenberg wrote:
>
> As part of a larger program, I'm testing a function that will turn a 
> string of days on which a class occurs (such as "MWF") into a list of seven 
> numbers: (1 0 1 0 1 0 0).
> I first translate"TH" (Thursday) to "R" and "SU" (Sunday) to "N" to make 
> things a bit easier.
>
> I came up with the following code:
>
> (defn days-number-maker
>   "Recursively compare first item in days of week with
> first item in string of days. If matching, add a 1,
> else add a zero to the result"
>   [all-days day-string result]
>   (if (empty? all-days) (reverse result)
> (if (= (first all-days) (first day-string))
>   (recur (rest all-days)(rest day-string) (conj result 1))
>   (recur (rest all-days) day-string (conj result 0)
>
> (defn days-to-numbers
>   "Change string like MTTH to (1 1 0 1 0 0 0)"
>   [day-string]
>   (let [days (clojure.string/replace
>(clojure.string/replace day-string #"TH" "R") #"SU" "N")]
> (days-number-maker "MTWRFSN" days (list
>
> The good news: the code works. The bad news: I'm convinced I'm doing it 
> wrong, in the moral purity sense of the word. Something inside of me says, 
> "You could have just used (map...) to do this the *right* way," but I can't 
> see how to do it with (map). So, my two questions are:
>
> 1) Is there such a thing as "the Clojure way," and if so,
> 2) How can I rewrite the code to be more Clojure-ish?
>
>
-- 


This email communication (including any attachments) contains information 
from Answers Corporation or its affiliates that is confidential and may be 
privileged. The information contained herein is intended only for the use 
of the addressee(s) named above. If you are not the intended recipient (or 
the agent responsible to deliver it to the intended recipient), you are 
hereby notified that any dissemination, distribution, use, or copying of 
this communication is strictly prohibited. If you have received this email 
in error, please immediately reply to sender, delete the message and 
destroy all copies of it. If you have questions, please email 
le...@answers.com. 

If you wish to unsubscribe to commercial emails from Answers and its 
affiliates, please go to the Answers Subscription Center 
http://campaigns.answers.com  to opt 
out.  Thank you.

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


Re: Clojure beginner: angst about "doing things right"

2014-09-22 Thread Alex Walker
For a "do it with (map)" mindset, think in terms of list processing or a 
conveyer belt, where a series of pure functions transforms a value in a 
small but significant way.  

1. Imho, the clojure-way is to apply the set of principles outlined by Rich 
and FP using the idioms established by the community.
2. https://gist.github.com/alexpw/e72c998b0d0be0daaaf2

On Monday, September 22, 2014 1:45:23 PM UTC-5, J David Eisenberg wrote:
>
> As part of a larger program, I'm testing a function that will turn a 
> string of days on which a class occurs (such as "MWF") into a list of seven 
> numbers: (1 0 1 0 1 0 0).
> I first translate"TH" (Thursday) to "R" and "SU" (Sunday) to "N" to make 
> things a bit easier.
>
> I came up with the following code:
>
> (defn days-number-maker
>   "Recursively compare first item in days of week with
> first item in string of days. If matching, add a 1,
> else add a zero to the result"
>   [all-days day-string result]
>   (if (empty? all-days) (reverse result)
> (if (= (first all-days) (first day-string))
>   (recur (rest all-days)(rest day-string) (conj result 1))
>   (recur (rest all-days) day-string (conj result 0)
>
> (defn days-to-numbers
>   "Change string like MTTH to (1 1 0 1 0 0 0)"
>   [day-string]
>   (let [days (clojure.string/replace
>(clojure.string/replace day-string #"TH" "R") #"SU" "N")]
> (days-number-maker "MTWRFSN" days (list
>
> The good news: the code works. The bad news: I'm convinced I'm doing it 
> wrong, in the moral purity sense of the word. Something inside of me says, 
> "You could have just used (map...) to do this the *right* way," but I can't 
> see how to do it with (map). So, my two questions are:
>
> 1) Is there such a thing as "the Clojure way," and if so,
> 2) How can I rewrite the code to be more Clojure-ish?
>
>
-- 


This email communication (including any attachments) contains information 
from Answers Corporation or its affiliates that is confidential and may be 
privileged. The information contained herein is intended only for the use 
of the addressee(s) named above. If you are not the intended recipient (or 
the agent responsible to deliver it to the intended recipient), you are 
hereby notified that any dissemination, distribution, use, or copying of 
this communication is strictly prohibited. If you have received this email 
in error, please immediately reply to sender, delete the message and 
destroy all copies of it. If you have questions, please email 
le...@answers.com. 

If you wish to unsubscribe to commercial emails from Answers and its 
affiliates, please go to the Answers Subscription Center 
http://campaigns.answers.com  to opt 
out.  Thank you.

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from 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: ClojureScript 0.0-2341, Improved Analysis & Transducers

2014-09-22 Thread Denis Johnson
Thanks for the update.

Both the previous and this causes the following warnings with core.async:

WARNING: Use of undeclared Var cljs.core.async/do-alts at line 62 
file:../.m2/repository/org/clojure/core.async/0.1.338.0-5c5012-alpha/core.async-0.1.338.0-5c5012-alpha.jar!/cljs/core/async/impl/ioc_helpers.cljs
WARNING: Bad method signature in protocol implementation impl/Handler 
lock-id at line 719 
file:../.m2/repository/org/clojure/core.async/0.1.338.0-5c5012-alpha/core.async-0.1.338.0-5c5012-alpha.jar!/cljs/core/async.cljs
WARNING: Use of undeclared Var cljs.core.async.impl.protocols/lock-id at 
line 722 
file:../.m2/repository/org/clojure/core.async/0.1.338.0-5c5012-alpha/core.async-0.1.338.0-5c5012-alpha.jar!/cljs/core/async.cljs
WARNING: Bad method signature in protocol implementation impl/Handler 
lock-id at line 719 run/compiled/demo/cljs/core/async.cljs
WARNING: Use of undeclared Var cljs.core.async.impl.protocols/lock-id at 
line 722 run/compiled/demo/cljs/core/async.cljs

Cheers Denis


On Friday, September 19, 2014 5:27:28 AM UTC+10, David Nolen wrote:
>
> I just cut 0.0-2342, the only change is a updated dependency on 
> tools.reader 0.8.9 - this fixes an issue where source metadata would 
> leave into the runtime. 
>
> David 
>
> On Thu, Sep 18, 2014 at 8:23 AM, David Nolen  > wrote: 
> > ClojureScript, the Clojure compiler that emits JavaScript source code. 
> > 
> > README and source code: https://github.com/clojure/clojurescript 
> > 
> > New release version: 0.0-2341 
> > 
> > Leiningen dependency information: 
> > 
> > [org.clojure/clojurescript "0.0-2341"] 
> > 
> > This releases comes with considerably better analysis. Vars from other 
> > namespaces are finally also verified. Protocols previously saw very 
> > little analysis support. Protocol method implementations are now 
> > checked for validity against the declared protocol. 
> > 
> > Transducers are also now in sync with Clojure 1.7.0-alpha2 
> > 
> > Feedback welcome! 
> > 
> > ### Enhancements 
> > * transducers 
> > 
> > ### Fixes 
> > * CLJS-704: warn if protocol extended to type multiple times in 
> extend-type 
> > * CLJS-702: warn if protocol doesn't match declared 
> > * CLJS-859: use https for the bootstrap script 
> > * CLJS-855: combinatorial code generation under advanced 
> > * CLJS-858: resolve-existing var does not check vars outside current ns 
> > * CLJS-852: same group-by as Clojure 
> > * CLJS-847: Safari toString fix 
> > * CLJS-846: preserve namespace metadata 
>

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


Re: Clojure beginner: angst about "doing things right"

2014-09-22 Thread john walker
Here's one way you could do part of it:

https://gist.github.com/johnwalker/7fcf1f988cd5e6e21fd5


(let [day->index(into {} (map-indexed (fn [k v] [v k]) "MTWRFSN"))
  ;; So M (Monday) maps to 0, S (Saturday) maps to 5
  initial-state (into [] (repeat 7 0))]
  ;; Create an empty vector of seven zeroes
  (reduce (fn [x i] (assoc x i 1)) initial-state (map day->index "MWF")))
;; Map each day to an index.
;; (day->index \M) is 0
;; so (map day->index "MWF)
;; is (0 2 4)
;; But we want [1 0 1 0 1 0 0]
;; So start with the seven zeroes, and add 1s for each date




I know what you mean by "You could have just used (map ...)". It helps me 
when I think about the number of elements I want (versus what I started 
with), and how independent elements are from one another.

On Monday, September 22, 2014 11:45:23 AM UTC-7, J David Eisenberg wrote:
>
> As part of a larger program, I'm testing a function that will turn a 
> string of days on which a class occurs (such as "MWF") into a list of seven 
> numbers: (1 0 1 0 1 0 0).
> I first translate"TH" (Thursday) to "R" and "SU" (Sunday) to "N" to make 
> things a bit easier.
>
> I came up with the following code:
>
> (defn days-number-maker
>   "Recursively compare first item in days of week with
> first item in string of days. If matching, add a 1,
> else add a zero to the result"
>   [all-days day-string result]
>   (if (empty? all-days) (reverse result)
> (if (= (first all-days) (first day-string))
>   (recur (rest all-days)(rest day-string) (conj result 1))
>   (recur (rest all-days) day-string (conj result 0)
>
> (defn days-to-numbers
>   "Change string like MTTH to (1 1 0 1 0 0 0)"
>   [day-string]
>   (let [days (clojure.string/replace
>(clojure.string/replace day-string #"TH" "R") #"SU" "N")]
> (days-number-maker "MTWRFSN" days (list
>
> The good news: the code works. The bad news: I'm convinced I'm doing it 
> wrong, in the moral purity sense of the word. Something inside of me says, 
> "You could have just used (map...) to do this the *right* way," but I can't 
> see how to do it with (map). So, my two questions are:
>
> 1) Is there such a thing as "the Clojure way," and if so,
> 2) How can I rewrite the code to be more Clojure-ish?
>
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from 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} defun: A beautiful macro to define clojure functions with pattern match.

2014-09-22 Thread Devin Walters
I didn't read it that way.

> On Sep 14, 2014, at 7:45 AM, adrian.med...@mail.yu.edu wrote:
> 
> Friendly advice: when you describe anything you create with adjectives like 
> beautiful, it comes off as unnecessarily arrogant to native English speakers.
> 
> Adrian
> 
>> On Sunday, September 14, 2014 2:47:28 AM UTC-4, dennis wrote:
>> 
>> Hi , i am pleased to introduce defun: a beautiful macro to define clojure 
>> functions with pattern match.
>> 
>> Some examples:
>> 
>> (defun say-hi
>>   ([:dennis] "Hi,good morning, dennis.")
>>   ([:catty] "Hi, catty, what time is it?")
>>   ([:green] "Hi,green, what a good day!")
>>   ([other] (str "Say hi to " other)))
>> 
>> (say-hi :dennis)
>> ;;  "Hi,good morning, dennis."
>> (say-hi :catty)
>> ;;  "Hi, catty, what time is it?"
>> (say-hi :green)
>> ;;  "Hi,green, what a good day!"
>> (say-hi "someone")
>> ;;  "Say hi to someone"
>> 
>> Recursive function? It's all right:
>> 
>> (defun count-down
>>   ([0] (println "Reach zero!"))
>>   ([n] (println n)
>>  (recur (dec n
>> (defun fib
>> ([0] 0)
>> ([1] 1)
>> ([n] (+ (fib (- n 1)) (fib (- n 2)
>> 
>> 
>> Guard functions? it's all right:
>> 
>> (defun valid-geopoint?
>> ([(_ :guard #(and (> % -180) (< % 180)))
>>   (_ :guard #(and (> % -90) (< % 90)))] true)
>> ([_ _] false))
>> 
>> (valid-geopoint? 30 30)
>> ;; true
>> (valid-geopoint? -181 30)
>> ;; false
>> 
>> It's really cool,all the magic are from core.match, much more details please 
>> see 
>> https://github.com/killme2008/defun
>> 
>> 
>> -- 
>> 庄晓丹 
>> Email:killm...@gmail.com xzh...@avos.com
>> Site:   http://fnil.net
>> Twitter:  @killme2008
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> --- 
> You received this message because you are subscribed to the Google Groups 
> "Clojure" group.
> To unsubscribe from 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: ANN: ClojureScript 0.0-2341, Improved Analysis & Transducers

2014-09-22 Thread Kyle Cordes
On Monday, September 22, 2014 9:45:44 PM UTC-5, Denis Johnson wrote:
>
> Thanks for the update.
>
> Both the previous and this causes the following warnings with core.async:
>
> WARNING: Use of undeclared Var cljs.core.async/do-alts at line 62 
> file:../.m2/repository/org/clojure/core.async/0.1.338.0-5c5012-alpha/core.async-0.1.338.0-5c5012-alpha.jar!/cljs/core/async/impl/ioc_helpers.cljs
>
>>
>>

I think perhaps the time has come for a cross-project automated-test server 
for CLJS and the 10-15 most common CLJS libraries. My understanding is at 
the level to understand the need, and I could muster a server but I am 
not "wired in" to the CLJS development community enough to know how to do 
it. Hmmm.

Kyle Cordes


-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from 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: `remove-ns' prevents namespace from being reloaded by `require' in clj 1.5.1 and 1.6

2014-09-22 Thread Laurent PETIT
Hello,

Le mardi 23 septembre 2014, Stuart Sierra  a
écrit :

> I'm not sure I understand what you mean.
>
> `remove-ns` does not remove the namespace from the set of "loaded"
> namespaces kept by `require`.  tools.namespace
>  has a hack
> 
> to work around this.
>

Can this be fixed for clojure 1.7 (integrate clojure.namespace hack into
'remove-ns)? Or is there a reason I can't see right now in favor of the
current behavior?


> But `require ... :reload` should still work.
>
> -S
>
>
> On Monday, September 22, 2014 10:04:49 AM UTC-4, Daniel König wrote:
>>
>> Hi,
>>
>> after removing a namespace with the remove-ns form, I am not able to
>> require it a second time.
>> From what I can tell, I should be able to reload a namespace after
>> removing it.
>> This behaviour was found in Clojure 1.5.1 and Clojure 1.6.
>>
>> Example:
>>
>> => (require 'config :reload)
>> nil
>> => (remove-ns 'config)
>> #
>> => (require 'config :reload)
>> nil
>> => (remove-ns 'config)
>> nil
>>
>>
>>
>> Is this intentional or can it be considered broken?
>>
>> Best regards,
>> Daniel
>>
>


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


-- 
Laurent Petit

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