Re: Clojure on Android

2012-05-26 Thread thomas kalbe

On 25.05.2012 23:45, HelmutKian wrote:
I've recently been on board a project that will targeting Android, and 
I've been given pretty much free reign chose my tools.  I'm an 
experienced Common Lisper and a fairly new Clojure user, but I'd like 
to know about the feasibility of writing real-world Android 
applications in Clojure. --

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 

I collect some of my Android Clojure snippets on go-lambda.blogspot.com.
Clojure on Android works great so far.

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


Re: clojurescript error

2012-05-26 Thread Alexander Kellett
A clean of temp files (namely, rm -rf resources/public/cljs) source tree 
should have fixed it. Just worked for me after upgrading to latest 
ClojureScript.

On Monday, May 14, 2012 3:29:16 AM UTC+2, Murtaza Husain wrote:
>
>  
> I am using Chris Ganger's noir-cljs. 
>
> Any leads on how I could debug it?
>
> Thanks,
> Murtaza
>
> On Sunday, May 13, 2012 7:35:13 PM UTC+5:30, David Nolen wrote:
>>
>> How are you compiling your source?
>>
>> On Sunday, May 13, 2012, Murtaza Husain wrote:
>>
>>> Hi,
>>>
>>> I have an array of maps defined as below -
>>>
>>> (def input-boxes [{:name ":person/first-name" :label-text "Full Name" 
>>> :help-text "Please enter your full name as - First Middle Last"}
>>>  {:name ":person/ejamaat" :label-text "Ejamaat Number" 
>>> :placeholder-text "Ejamaat #"}
>>>  {:name ":person/mobile" :label-text "Mobile Number" 
>>> :placeholder-text "Mobile #"}
>>>  {:name ":person/email" :label-text "Email Address"}
>>>  {:name ":person/watan" :label-text "Watan" 
>>> :placeholder-text "Watan"}]) 
>>>
>>> This is the generated code and error that I see in browser - 
>>>
>>> faiz.client.infoCollection.input_boxes = 
>>> cljs.core.PersistentVector.fromArray([cljs.core.ObjMap.fromObject(["\ufdd0'name",
>>>  
>>> "\ufdd0'label-text", "\ufdd0'help-text"], 
>>> {"\ufdd0'name":":person/first-name", "\ufdd0'label-text":"Full Name", 
>>> "\ufdd0'help-text":"Please enter your full name as - First Middle Last"}), 
>>> cljs.core.ObjMap.fromObject(["\ufdd0'name", "\ufdd0'label-text", 
>>> "\ufdd0'placeholder-text"], {"\ufdd0'name":":person/ejamaat", 
>>> "\ufdd0'label-text":"Ejamaat Number", "\ufdd0'placeholder-text":"Ejamaat 
>>> #"}), 
>>>  Uncaught TypeError: Cannot call method 'fromArray' of undefined
>>>  
>>> Any ideas on what is wrong here?
>>>
>>> Thanks,
>>> Murtaza
>>>
>>> -- 
>>> 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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re:Selecting subsets of maps

2012-05-26 Thread Moritz Ulrich

Interesting problem. This is my (first iteration) of a solution:

--8<---cut here---start->8---
(defn select-in [m keyseq]
  (loop [acc {} [k & ks] (seq keyseq)]
(if k
  (recur
   (if (sequential? k)
 (let [[k ks] k]
   (assoc acc k
  (select-in (get m k) ks)))
 (assoc acc k (get m k)))
   ks)
  acc)))
--8<---cut here---end--->8---

The `keyseq' parameter uses seqs instead of the maps in your example,
but I think the usage is fairly convenient:

--8<---cut here---start->8---
(select-in my-map [:name
   :email
   [:address [:city
  :state]]
   [:spouse [:name
 [:address [:city
:state])
--8<---cut here---end--->8---


One thing to notice is that this function doesn't work as intended on
maps with seqs as keys. It's also not tail-recursive but maps nested so
deep that this becomes a problem are a problem by itself.


Baishampayan Ghose  writes:

> Hi,
>
> I have a problem wherein I need to select subsets of a given map;
> think about select-keys, but with arbitrary nesting.
>
> For example, consider this map -
>
> (def my-map {:name "John Doe"
>:email "j...@doe.com"
>:address {:house "42"
>  :street "Moon St."
>  :city "San Francisco"
>  :state "CA"
>  :zip 76509
>  :mobile "+1"}
>:ssn "123456"
>:spouse {:name "Jane Doe"
> :ssn "654321"
> :relation :wife
> :address {:house "42"
>   :street "Moon St."
>   :city "Atlanta"
>   :state "GA"
>   :zip 76509
>   :mobile "+1"}}})
>
> From the above map, I want to extract this sub-map -
>
> {:spouse {:name "Jane Doe", :address {:state "GA", :city "Atlanta"}},
>  :name "John Doe",
>  :email "j...@doe.com",
>  :address {:state "CA", :city "San Francisco"}}
>
> What would be a good way to express this sub-map so that I can pass it
> on to a function?
>
> I am thinking about something like this -
>
> [:name :email {:address [:city :state]} {:spouse [:name {:address
> [:city :state]}]}]
>
> Example implementations are also welcome.
>
> Regards,
> BG
>
> --
> Baishampayan Ghose
> b.ghose at gmail.com

--
Moritz Ulrich

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


Re: Lambda: A lniux distro for clojurists

2012-05-26 Thread Denis Labaye
Hi,

This is a very interesting idea. It would have been of great use when I
did a Clojure workshop with complete beginners, with all kinds of OSes
(Windows, OSX, ...).

I took the "Completely packaged VirtualBox image" approach, but it is
still a big mess: Not everyone have VirtualBox installed (or the right
version). And not every flavors of the main editors where correctly
configured for Clojure (Emacs, vi).

Being able to just "boot on a live CD", and have a working Clojure
environment would have been great. Also great for distribution: Just
burn it on a lot of cheap Cd's, and much more "down loadable": A Virtual
Box image takes about 2gig, a live CD is 700meg.

Cheers,

Denis

On Thu, May 24, 2012 at 10:11 PM, banseljaj wrote:

> Hello Guys,
>
> I am quite new to clojure, and I am a fan. It's a great thing. One thing
> that seems missing, however, is a single unified way of setting up the
> clojure environment. Which seemed pretty daunting to me at first.
>
> So I have decided to create a Linux Distro specifically for Clojure
> development.
>
> I have been bouncing this idea in #clojure and it got a good response. So
> now I have started the complete development effort.
>
> My plan so far is as follows.
>
> Mission Statement for the Distro
>
> The distro should be able to:
>
>- Connect to internet.
>- Be able to convert itself into An VM/Iso/LiveCD etc
>- Have all IDEs for Clojure installed and preconfigured.
>   - Eclipse
>   - Vim
>   - Emacs
>   - Netbeans
>- Have a ready to play connection to clojure forums and channels
>- Have at-least one book on clojure programming on board
>- Have following clojure specific features
>   - It should have leiningen installed and configured
>   - It should have a local repo of all current clojure plugins
>   - It should have a local "cloud" on which you can deploy web apps
>   easily
>   - it should have REPLlabs on baord and configured
>- Have Clojure specific branding
>
>
>
> The packages that are needed absolutely:
>
>- OpenJDK 1.7.0
>- Leiningen
>- Clojure
>- Eclipse
>- Vim
>- Emacs 24
>- Netbeans
>- Emacs Starter kit
>- CCW plugin for eclipse
>- Firefox/Chrome
>- A local webserver
>- Postgresql
>- LXDE/XFCE
>- Gwibber/Other Social network Client
>- xchat
>- irssi
>- git
>- Regular packages for system functioning.
>
>
> I am still open to ideas. I intend to roll it as a complete distro, so I
> will love any and all input.
>
> For now, the specific things I need input for are:
>
>- Who/How to create the art for branding.
>- Any packages that are missing from the above listing.
>- Any suggestions for the overall functioning.
>
>
> I will soon have an actual website set up.
>
>
> It is my intention to create a fully functional, independent Development
> environment for Functional programmers by release 2. Right now, I am
> working on release 0.0.1.
>
> Looking forward to all input.
>
> regards.
>
> banseljaj
>
>
>  --
> 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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Do you leave a Swank / nREPL in your production servers?

2012-05-26 Thread Denis Labaye
Note also that I could be interesting to plug a swank server in a
regular Java app (mainly for dev). This would allow to manipulate you
live app, and use all the Clojure goodness from the confort of your
REPL:
http://denilab.blogspot.fr/2012/04/injecting-clojure-repl-into-your.html

On Fri, May 25, 2012 at 11:34 PM, Karl Krukow  wrote:

> Thanks Sean for the detailed information. This will be really useful to me.
>
> /Karl
> On 25/05/2012, at 23.30, Sean Corfield wrote:
>
> > On Fri, May 25, 2012 at 1:46 PM, Phil Hagelberg  wrote:
> >> On Fri, May 25, 2012 at 1:41 PM, Karl Krukow 
> wrote:
> >>> If I'm embedding swank clojure server in non-development, the code
> would need to start up swank - how would I do that?
> >> Just add swank as a non-dev dependency. The swank-clojure readme
> >> actually covers how to do embedding.
> >
> > Specifically:
> >
> > Add a dependency on [swank-clojure "1.4.2"]
> >
> > Then in your code:
> >
> > (swank.swank/start-server :host "0.0.0.0" :port 4567) ;; use whatever
> > port you want, default is 4005
> >
> > You can programmatically stop the server with:
> >
> > (swank.swank/stop-server)
> >
> > The :host specifies the IP (or hostname) to listen on so if you want
> > external access you'll need to listen on an IP that is externally
> > accessible. If you listen on "0.0.0.0" then it'll listen on any IP
> > address so you can REPL in from outside as well as directly on server
> > itself (on 127.0.0.1). Our servers have multiple IP addresses and this
> > caught me out at first when working with our data center folks and
> > setting up VPN/DMZ access to the host/port.
> >
> > Another thing that was a bit of a problem for us was that swank.swank
> > does a bunch of stuff at initialization that got in our way (I don't
> > remember details) so we actually resolve the symbols at runtime so
> > swank.swank is only loaded when we actually start the swank server:
> >
> > (defn start-swank
> >  "If a swank port is defined for this environment, attempt to start a
> >   swank server on that port. Will throw an exception if it's already
> >   running on that port etc."
> >  []
> >  (require 'swank.swank)
> >  (when-let [start-server (resolve (symbol "swank.swank/start-server"))]
> >(start-server :host "0.0.0.0" :port (:swank-port @my-settings
> >
> > my-settings is a delayed map containing application configuration data
> > (we delay it because the app needs to bootstrap part way in order to
> > read the configuration which gets stored in the map). We use different
> > swank ports on different machines to avoid confusion when
> > slime-connect'ing in from Emacs.
> > --
> > Sean A Corfield -- (904) 302-SEAN
> > An Architect's View -- http://corfield.org/
> > World Singles, LLC. -- http://worldsingles.com/
> >
> > "Perfection is the enemy of the good."
> > -- Gustave Flaubert, French realist novelist (1821-1880)
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Clojure" group.
> > To post to this group, send email to clojure@googlegroups.com
> > Note that posts from new members are moderated - please be patient with
> your first post.
> > To unsubscribe from this group, send email to
> > clojure+unsubscr...@googlegroups.com
> > For more options, visit this group at
> > http://groups.google.com/group/clojure?hl=en
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To 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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure Pretty Printing with Blogger

2012-05-26 Thread Denis Labaye
Hi,

I don't know google-code-prettify. I am using Emacs with org-mode, it has
native support for prettifying Clojure code when exporting to HTML.
You could also use GitHub's gist https://gist.github.com/, and embed it in
your blog.

Denis

On Fri, May 25, 2012 at 12:07 PM, Jake Johnson wrote:

> Hi, guys. Has anyone had any luck with using 
> google-code-prettifyand
> http://google-code-prettify.googlecode.com/svn/trunk/src/lang-clj.jstogether 
> on blogger? I followed
> http://www.tkglaser.net/2012/03/syntax-highlighting-in-blogger.html,
>  but I can't get Clojure to display correctly, at least yet.
>
> --
> 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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Midje 1.4 released

2012-05-26 Thread Denis Labaye
Great!

On Thu, May 24, 2012 at 9:10 AM, CA  wrote:

> Yeah!
>
> On May 24, 12:29 am, Brian Marick  wrote:
> > Midje is a test framework for Clojure. It supports top-down as well as
> bottom-up testing, encourages readable tests, provides a smooth migration
> path from clojure.test, and supports a balance between abstraction and
> concreteness.
> >
> > Special thanks to Alex Baranosky for all his work on this version.
> >
> > Changes:https://github.com/marick/Midje/wiki/New-in-1.4
> > User documentation:https://github.com/marick/Midje/wiki
> > Repo:https://github.com/marick/Midje
> >
> > -
> > Brian Marick, Artisanal Labrador
> > Contract programming in Ruby and Clojure
> > Occasional consulting on Agilewww.exampler.com,www.twitter.com/marick
>
> --
> 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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure and the Anti-If Campaign

2012-05-26 Thread Mimmo Cosenza
Hi Dominikus,
and thanks for sharing your valuable thought. 
 
I did not read the antiifcampaign, but I remember very well the number of 
ifs code lines 
 were present in java window toolkit (1995), just because they did not add 
NullLayout class to polymorphically manage the absence of a layout manager. 
So I should say: I agree by principle. 

Conditions and polymorphism are orthogonal each other, at least with an OO 
approach. Less ifs you have, more clear is your model. No ifs, and you 
reach the perfection of a model. But the perfection is not pragmatic. Few 
ifs, its human. No if its divine. And I'm little bit less than human, so I 
prefere to stay with few ifs.

Anyway, very nice post.

Mimmo
 
On Thursday, May 24, 2012 11:57:47 AM UTC+2, Dominikus wrote:
>
> Three weeks ago I stumbled across the Anti-If Campaign (
> http://www.antiifcampaign.com/).
>
> An instant later I realized that one could easily re-implement "if" in 
> Clojure with maps. More interestingly, polymorphic functions can be easily 
> motivated with the help of maps. And this naturally leads to multimethods.
>
> If you like, enjoy reading my blogpost on "The root of polymorphism: The 
> Anti-If Campaign". It might be an interesting read for Clojure enthusiasts.
>
>
> http://denkspuren.blogspot.de/2012/05/root-of-polymorphism-anti-if-campaign.html
>  
>
> Cheers,
>
> Dominikus
>
>
>

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

Re: Lambda: A lniux distro for clojurists

2012-05-26 Thread Islon Scherer
Why not create a shell script?

On May 26, 9:32 am, Denis Labaye  wrote:
> Hi,
>
> This is a very interesting idea. It would have been of great use when I
> did a Clojure workshop with complete beginners, with all kinds of OSes
> (Windows, OSX, ...).
>
> I took the "Completely packaged VirtualBox image" approach, but it is
> still a big mess: Not everyone have VirtualBox installed (or the right
> version). And not every flavors of the main editors where correctly
> configured for Clojure (Emacs, vi).
>
> Being able to just "boot on a live CD", and have a working Clojure
> environment would have been great. Also great for distribution: Just
> burn it on a lot of cheap Cd's, and much more "down loadable": A Virtual
> Box image takes about 2gig, a live CD is 700meg.
>
> Cheers,
>
> Denis
>
> On Thu, May 24, 2012 at 10:11 PM, banseljaj wrote:
>
>
>
>
>
>
>
> > Hello Guys,
>
> > I am quite new to clojure, and I am a fan. It's a great thing. One thing
> > that seems missing, however, is a single unified way of setting up the
> > clojure environment. Which seemed pretty daunting to me at first.
>
> > So I have decided to create a Linux Distro specifically for Clojure
> > development.
>
> > I have been bouncing this idea in #clojure and it got a good response. So
> > now I have started the complete development effort.
>
> > My plan so far is as follows.
>
> > Mission Statement for the Distro
>
> > The distro should be able to:
>
> >    - Connect to internet.
> >    - Be able to convert itself into An VM/Iso/LiveCD etc
> >    - Have all IDEs for Clojure installed and preconfigured.
> >       - Eclipse
> >       - Vim
> >       - Emacs
> >       - Netbeans
> >    - Have a ready to play connection to clojure forums and channels
> >    - Have at-least one book on clojure programming on board
> >    - Have following clojure specific features
> >       - It should have leiningen installed and configured
> >       - It should have a local repo of all current clojure plugins
> >       - It should have a local "cloud" on which you can deploy web apps
> >       easily
> >       - it should have REPLlabs on baord and configured
> >    - Have Clojure specific branding
>
> > The packages that are needed absolutely:
>
> >    - OpenJDK 1.7.0
> >    - Leiningen
> >    - Clojure
> >    - Eclipse
> >    - Vim
> >    - Emacs 24
> >    - Netbeans
> >    - Emacs Starter kit
> >    - CCW plugin for eclipse
> >    - Firefox/Chrome
> >    - A local webserver
> >    - Postgresql
> >    - LXDE/XFCE
> >    - Gwibber/Other Social network Client
> >    - xchat
> >    - irssi
> >    - git
> >    - Regular packages for system functioning.
>
> > I am still open to ideas. I intend to roll it as a complete distro, so I
> > will love any and all input.
>
> > For now, the specific things I need input for are:
>
> >    - Who/How to create the art for branding.
> >    - Any packages that are missing from the above listing.
> >    - Any suggestions for the overall functioning.
>
> > I will soon have an actual website set up.
>
> > It is my intention to create a fully functional, independent Development
> > environment for Functional programmers by release 2. Right now, I am
> > working on release 0.0.1.
>
> > Looking forward to all input.
>
> > regards.
>
> > banseljaj
>
> >  --
> > 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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Lambda: A lniux distro for clojurists

2012-05-26 Thread Sergey Didenko
What about packaging Emacs with a few different configs? For example
Ergoemacs + dark background settings.

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


Re: Clojure Pretty Printing with Blogger

2012-05-26 Thread Jake Johnson
Thanks! I didn't realize org-mode would prettify Clojure code when exported
to html (I generally use org-mode without exporting). Using org-mode, would
my best option just be to type it up, export to html, then copy and paste
the resulting html into my blog post?

On Sat, May 26, 2012 at 10:46 AM, Denis Labaye wrote:

> Hi,
>
> I don't know google-code-prettify. I am using Emacs with org-mode, it has
> native support for prettifying Clojure code when exporting to HTML.
> You could also use GitHub's gist https://gist.github.com/, and embed it
> in your blog.
>
> Denis
>
> On Fri, May 25, 2012 at 12:07 PM, Jake Johnson wrote:
>
>> Hi, guys. Has anyone had any luck with using 
>> google-code-prettifyand
>> http://google-code-prettify.googlecode.com/svn/trunk/src/lang-clj.jstogether 
>> on blogger? I followed
>> http://www.tkglaser.net/2012/03/syntax-highlighting-in-blogger.html,
>>  but I can't get Clojure to display correctly, at least yet.
>>
>>  --
>> 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 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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure Pretty Printing with Blogger

2012-05-26 Thread eniotna
Hi

C-c C-e b for the HTML export and open into the browser to display the
result.

Then copy paste the html source yes.

Antoine
On May 26, 2012 11:42 PM, "Jake Johnson"  wrote:

> Thanks! I didn't realize org-mode would prettify Clojure code when
> exported to html (I generally use org-mode without exporting). Using
> org-mode, would my best option just be to type it up, export to html, then
> copy and paste the resulting html into my blog post?
>
> On Sat, May 26, 2012 at 10:46 AM, Denis Labaye wrote:
>
>> Hi,
>>
>> I don't know google-code-prettify. I am using Emacs with org-mode, it has
>> native support for prettifying Clojure code when exporting to HTML.
>> You could also use GitHub's gist https://gist.github.com/, and embed it
>> in your blog.
>>
>> Denis
>>
>> On Fri, May 25, 2012 at 12:07 PM, Jake Johnson 
>> wrote:
>>
>>> Hi, guys. Has anyone had any luck with using 
>>> google-code-prettifyand
>>> http://google-code-prettify.googlecode.com/svn/trunk/src/lang-clj.jstogether
>>>  on blogger? I followed
>>> http://www.tkglaser.net/2012/03/syntax-highlighting-in-blogger.html,
>>>  but I can't get Clojure to display correctly, at least yet.
>>>
>>>  --
>>> 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 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 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 post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Re: Clojure Pretty Printing with Blogger

2012-05-26 Thread Moritz Ulrich
If you don't want to create a whole org-document just for a single
export, you can use htmlize-{region,buffer} directly. That's the same
command org uses.

On Sat, May 26, 2012 at 11:46 PM, eniotna  wrote:
> Hi
>
> C-c C-e b for the HTML export and open into the browser to display the
> result.
>
> Then copy paste the html source yes.
>
> Antoine
>
> On May 26, 2012 11:42 PM, "Jake Johnson"  wrote:
>>
>> Thanks! I didn't realize org-mode would prettify Clojure code when
>> exported to html (I generally use org-mode without exporting). Using
>> org-mode, would my best option just be to type it up, export to html, then
>> copy and paste the resulting html into my blog post?
>>
>> On Sat, May 26, 2012 at 10:46 AM, Denis Labaye 
>> wrote:
>>>
>>> Hi,
>>>
>>> I don't know google-code-prettify. I am using Emacs with org-mode, it has
>>> native support for prettifying Clojure code when exporting to HTML.
>>> You could also use GitHub's gist https://gist.github.com/, and embed it
>>> in your blog.
>>>
>>> Denis
>>>
>>> On Fri, May 25, 2012 at 12:07 PM, Jake Johnson 
>>> wrote:

 Hi, guys. Has anyone had any luck with using google-code-prettify and
 http://google-code-prettify.googlecode.com/svn/trunk/src/lang-clj.js
 together on blogger? I followed
 http://www.tkglaser.net/2012/03/syntax-highlighting-in-blogger.html , but I
 can't get Clojure to display correctly, at least yet.

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



-- 
Moritz Ulrich

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


Why does (send a f) hang in this code, if f returns an agent?

2012-05-26 Thread Alex Coventry
I was messing with the example at clojure.org/agents to get it to log which 
agents called which, and finally came up with 

  (use 'clojure.pprint)
  
  (defn relay [x i agidx]
(when (:next x)
  (send (:next x) relay i (:idx x)))   
(when (and (zero? i) (:report-queue x))
  (.put (:report-queue x) i))
(assoc x :calls (conj (:calls x) [i agidx]))
  )
  
  (defn run [m n]
(let [q (new java.util.concurrent.SynchronousQueue)
  hd (reduce (fn [next _]
   (agent {:next next :calls [] :idx _}))
 (agent {:report-queue q :calls [] :idx -1})
 (range (dec m)))]
  (doseq [i (reverse (range n))]
(send hd relay i nil))
  (.take q)
  (pprint hd)
  ))
  
  (time (run 10 10))
  
This code works, but if I replace the last line of the relay function with 
"(agent (assoc x :calls (conj (:calls x) [i agidx])))", execution hangs.  I 
now realize it was wrong-headed to wrap the result up in another agent, but 
I am curious about what causes it to hang if you do so, rather than return 
an error.

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

Re: Clojure Pretty Printing with Blogger

2012-05-26 Thread Jake Johnson
Thanks again, guys! Much appreciated.

On Sat, May 26, 2012 at 6:07 PM, Moritz Ulrich  wrote:

> If you don't want to create a whole org-document just for a single
> export, you can use htmlize-{region,buffer} directly. That's the same
> command org uses.
>
> On Sat, May 26, 2012 at 11:46 PM, eniotna  wrote:
> > Hi
> >
> > C-c C-e b for the HTML export and open into the browser to display the
> > result.
> >
> > Then copy paste the html source yes.
> >
> > Antoine
> >
> > On May 26, 2012 11:42 PM, "Jake Johnson" 
> wrote:
> >>
> >> Thanks! I didn't realize org-mode would prettify Clojure code when
> >> exported to html (I generally use org-mode without exporting). Using
> >> org-mode, would my best option just be to type it up, export to html,
> then
> >> copy and paste the resulting html into my blog post?
> >>
> >> On Sat, May 26, 2012 at 10:46 AM, Denis Labaye 
> >> wrote:
> >>>
> >>> Hi,
> >>>
> >>> I don't know google-code-prettify. I am using Emacs with org-mode, it
> has
> >>> native support for prettifying Clojure code when exporting to HTML.
> >>> You could also use GitHub's gist https://gist.github.com/, and embed
> it
> >>> in your blog.
> >>>
> >>> Denis
> >>>
> >>> On Fri, May 25, 2012 at 12:07 PM, Jake Johnson <
> kognizant@gmail.com>
> >>> wrote:
> 
>  Hi, guys. Has anyone had any luck with using google-code-prettify and
>  http://google-code-prettify.googlecode.com/svn/trunk/src/lang-clj.js
>  together on blogger? I followed
>  http://www.tkglaser.net/2012/03/syntax-highlighting-in-blogger.html, but 
>  I
>  can't get Clojure to display correctly, at least yet.
> 
>  --
>  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 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 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 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
>
>
>
> --
> Moritz Ulrich
>
> --
> 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 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

Deserialization of a Record

2012-05-26 Thread ChrisR
I have a problem deserializing a record from within a swing application.
I wrote the minimal amount of code required to highlight the problem i'm 
having below.
(if unfamiliar with seesaw, this is just creating a JButton which 
deserializes the
record in the file "/tmp/point" on-click)

(ns babel.records
  (:require (seesaw (core :refer (alert frame button listen))
(mig :refer (mig-panel)

(defrecord Point [x y])

(comment
  "Serialization and deserialization from a REPL works fine."
  
  (spit "/tmp/point" (binding [*print-dup* true] (pr-str (->Point 1 2
  "/tmp/point" => #babel.records.Point[1, 2]
  
  (read-string (slurp "/tmp/point"))
  => #babel.records.Point{:x 1, :y 2}
  )

(defn framework []
  (let [b (button :text "Deserialize")]
(listen b :action (fn [e] (alert (read-string (slurp "/tmp/point")
(frame :content (mig-panel :constraints ["" "" ""]
   :items [[b]])
  :size [323 :by 200]
  :visible? true)))

;; Clicking the button throws the following error:
;; Exception in thread "AWT-EventQueue-0" 
java.security.PrivilegedActionException: 
java.security.PrivilegedActionException: java.lang.ClassNotFoundException: 
babel.records.Point

It looks to me that the class/record can't be seen from the EDT, is there a 
solution here?

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

Re: Deserialization of a Record

2012-05-26 Thread ChrisR
As an update to this, I can get deserialization working, so long as I 
(compile 'babel.records) within the file itself. 

It seems to me that having a raw (compile 'babel.records) type form at the 
start of each namespace containing defrecords I need to serialize would not 
be ideal, are there general recommendations for doing this kind of thing?  

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

[PATCH] RFC: Add Functions `tabify` And `untabify`

2012-05-26 Thread OGINO Masanori
Hello.

I wrote functions for converting tabs from/to spaces.  They are not
used anytime, so they may be irrelevant to include core.  Anyway I'd
like to show them and hear your opinions.

I want to use untabify in clojure.repl for formatting docstrings
correctly (I'll post about that later), so it's not very important
to include them in clojure.string (by adding it as private function in
clojure.repl or defining it by letfn).

It's my first contribution (I hope), so I'm anxious to make a ticket
in JIRA immediately.  Any suggestions would be appreciated.

Regards,
OGINO Masanori

Signed-off-by: OGINO Masanori 
---
 src/clj/clojure/string.clj   |   28 
 test/clojure/test_clojure/string.clj |   19 +++
 2 files changed, 47 insertions(+)

diff --git a/src/clj/clojure/string.clj b/src/clj/clojure/string.clj
index 188b518..8f5ca0a 100644
--- a/src/clj/clojure/string.clj
+++ b/src/clj/clojure/string.clj
@@ -166,6 +166,34 @@ Design notes for clojure.string:
   [^CharSequence s]
   (.. s toString toLowerCase))
 
+(defn ^String tabify
+  "Converts all n spaces (\\space, U+0020) at the beginning of lines
+  to a tab (\\t, U+0009).  By default, 8 spaces are used."
+  {:added "1.5"}
+  ([^CharSequence s]
+ (tabify s 8))
+  ([^CharSequence s n]
+ (join
+   (map (fn [[_ indent body eol]]
+  (str (replace (str indent)
+(join (repeat n \space)) "\t")
+   body eol))
+(re-seq #"(?m)^([ \t]+)?([^\n]*)(\n)?" s)
+
+(defn ^String untabify
+  "Converts all tabs (\\t, U+0009) at the beginning of lines to n
+  spaces (\\space, U+0020).  By default, 8 spaces are used."
+  {:added "1.5"}
+  ([^CharSequence s]
+ (untabify s 8))
+  ([^CharSequence s n]
+ (join
+   (map (fn [[_ indent body eol]]
+  (str (replace (str indent)
+"\t" (join (repeat n \space)))
+   body eol))
+(re-seq #"(?m)^([ \t]+)?([^\n]*)(\n)?" s)
+
 (defn split
   "Splits string on a regular expression.  Optional argument limit is
   the maximum number of splits. Not lazy. Returns vector of the splits."
diff --git a/test/clojure/test_clojure/string.clj 
b/test/clojure/test_clojure/string.clj
index d6f6469..3bdde54 100644
--- a/test/clojure/test_clojure/string.clj
+++ b/test/clojure/test_clojure/string.clj
@@ -118,3 +118,22 @@
 (is (vector? result)))
   (is (= (list "foo") (s/split-lines "foo"
 
+(deftest t-tabify
+  (is (= "a" (s/tabify "a")))
+  (is (= "  " (s/tabify "  ")))
+  (is (= "\t" (s/tabify "")))
+  (is (= "\t " (s/tabify " ")))
+  (is (= "\ta" (s/tabify "a")))
+  (is (= "\t\n\t" (s/tabify "\n")))
+  (is (= "\t\n\t\n" (s/tabify "\n\n")))
+  (is (= "\t" (s/tabify "  " 2
+
+(deftest t-untabify
+  (is (= "a" (s/untabify "a")))
+  (is (= "  " (s/untabify "  ")))
+  (is (= "" (s/untabify "\t")))
+  (is (= " " (s/untabify " \t")))
+  (is (= "a\t" (s/untabify "\ta\t")))
+  (is (= "\n" (s/untabify "\t\n\t")))
+  (is (= "\n\n" (s/untabify "\t\n\t\n")))
+  (is (= "  " (s/untabify "\t" 2
-- 
1.7.9.5

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


Re: [PATCH] RFC: Add Functions `tabify` And `untabify`

2012-05-26 Thread OGINO Masanori
What I mean in "they are not used anytime" is "they are _not always_
used."... I'm sorry.

--
OGINO Masanori 
http://twitter.com/omasanori

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


Re: Parallel doseq?

2012-05-26 Thread Cedric Greevey
I noticed with the working pdoseq I posted earlier that sometimes the
threads on one core get ahead of those on the others, for some reason,
and then that core is idle for the rest of a job -- Windows, at least,
doesn't seem to reassign one or more threads to the freed core. So I
wrote this version:

(defmacro pdoseq
  "Bindings as for for, but parallel execution as per pmap, pcalls,
pvalues; returns
   nil."
  [seq-exprs & body]
  `(let [procs# (+ 2 (.availableProcessors (Runtime/getRuntime)))
 calls# (for ~seq-exprs (fn [] ~@body))
 chunks# (atom [nil (partition 100 calls#)])
 threads# (for [i# (range procs#)]
(Thread.
  #(loop []
 (let [chunk# (first
(swap! chunks# (fn [[_# [a# &
b#]]] [a# b#])))]
   (when chunk#
 (doall
   (map (fn [x#] (x#)) chunk#))
 (recur))]
 (doseq [t# threads#]
   (.start t#))
 (doseq [t# threads#]
   (.join t#

This one replaces the interleaving with a job queue, which each thread
atomically takes from. The input items are chunked into hundreds in
the code above, but that number can easily be changed (or even made
into a parameter of the macro). I think this should divide the work up
more evenly among the available cores until nearly the end (if there
are thousands or more of calls in calls#) when there will eventually
be no chunks left unassigned and worker threads becoming idle.

In case anyone might find this useful, I'm relinquishing any copyright
in either version and placing both into the public domain for others
to freely reuse.

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