Re: Can anyone create a simpler version of prime factors in Clojure?

2010-06-12 Thread Steve Purcell
On 11 Jun 2010, at 20:35, Russell Christopher wrote:

> didn't need the assoc in my previous try
> 
> (defn of [n]
>   (letfn [(f [res k]
>  (if (= 0 (rem (:n res) k))
>{:n (/ (:n res) k) :fs (conj (:fs res) k)}
>res))]
> (:fs (reduce f  {:n n :fs []} (range 2 n)


The two give different answers. Given n=144, your version produces [2 3 4 6] 
and Uncle Bob's produces [2 2 2 2 3 3].

-Steve

-- 
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: ICFP 2009 / ICFP 2010

2010-06-12 Thread Craig Andera
> There's one question that came up when I implemented this. Is there a
> way to get the name of a clojure function, when all I have is the
> function object? Is it stored alongside the function? I didn't see any
> metadata or anything. Would I really have to reverse lookup the name
> in some namespace maps?

Functions don't have to have names:

(fn [] (println "I'm anonymous!"))

If you have a symbol you can get the name, though:

(name '<) => "<"

or

(str '<) => "<"

The former will print only the name. The latter will print the
namespace, too, if the symbol has one.

Does that help?

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


Re: ICFP 2009 / ICFP 2010

2010-06-12 Thread Michał Marczyk
On 12 June 2010 04:51, Eugen Dück  wrote:
> I put the first part of my implementation online:
> http://read-eval-puke.blogspot.com/2010/06/icfp-2009-orbit-binary-file-reader.html
> so anyone who's interested do have a look.

Interesting, thanks!

> There's one question that came up when I implemented this. Is there a
> way to get the name of a clojure function, when all I have is the
> function object? Is it stored alongside the function? I didn't see any
> metadata or anything. Would I really have to reverse lookup the name
> in some namespace maps?

In 1.2, defn-created functions have :name metadata. I mean the fns
themselves, not only the Vars. In 1.1, functions can't have metadata
attached to them, so if you're planning to use that, this won't help.
At any rate, for whichever reason, fn-created functions currently have
no :name metadata even if explicitly given a name, e.g. (meta (fn foo
[] :foo)) => nil.

Still, one can interrogate a function to find out its name in the
following super-clumsy way (not to say there isn't a better way --
just my first shot):

(defn fn-name [the-fn]
  (->> (.toString the-fn)
(.split #"\$")
next
second
(.split #"_")
first))

(fn-name (fn foo [] :foo))
; => "foo"
(fn-name (fn [] :foo))
; => "fn" ; generic response for anonymous fns

I wonder if perhaps the reflection api might provide a cleaner way to
get at this information...

Sincerely,
Michał

-- 
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: Reduce a function over more than one sequence (like map)

2010-06-12 Thread Jürgen Hötzel
2010/6/11 Nathan Sorenson :
> Is there a way to fold over multiple sequences, in the same way that
> 'map' can apply a multi-parameter function over several seqs? In other
> words, is there a function like this:

There is no need for a special purpose reduce* function.
Using destructing binding as Sean explains and creating an
intermediate lazy sequence of key/value pairs, this leads to short and
concise code:

(reduce (fn [m [k v]] (assoc m k v)) {} (map vector [:one :another]
(iterate inc 1)))

A good example of Alan J. Perlis quote and  Clojure rationale:

"It is better to have 100 functions operate on one data structure than
to have 10 functions operate on 10 data structures."

Jürgen

-- 
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: Interface to integrate transactions with Clojure transactions

2010-06-12 Thread Daniel Werner
On Jun 11, 11:41 pm, Chris Kent  wrote:
> Is this what you're thinking of?
>
> http://groups.google.com/group/clojure/browse_thread/thread/aa22a7095...
>
> I'm not sure what happened, it sounded promising but I've not seen it
> mentioned again since this thread went quiet.

This is exactly what I was thinking of, thanks for digging it up. It's
a pity that the original author didn't follow through with it, but
luckily he published the preliminary code (hope that URL works for
everyone):

http://clojure.googlegroups.com/web/external_transactions.patch?hl=en&gda=-S5y8U0AAADrLV-d6p24hYFcam_S99IgyJE26GXST0R-7SyR1V01WgTsgF1Et-2mKd4f9I_2PzGxx-qQneGAYu2No43QZpeq5Tb_vjspK02CR95VRrtmeQ&gsc=RG-y6gsAAAB4ToW0PqQMv0ZY_YCRY_xk

It definitely would be great if somebody with the required JTA
knowledge were to pick this up. (Unfortunately, I'm not Java-savvy
enough yet to be of much help.)

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


Mac Emacs users: which version do you prefer (Aquamacs, Carbon Emacs, other?)

2010-06-12 Thread Thomas Kjeldahl Nilsson
What are the major differences in the different distributions,
particularly for Clojure development?

I've got everything (Slime, Paredit, Clojure-mode etc) set up in
Carbon emacs and it works great, just curious if there are any
substantials gains to be had in Aquamacs or other alternative
distributions. :)


Regards,
Thomas Kjeldahl Nilsson
http://kjeldahlnilsson.net

-- 
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: Mac Emacs users: which version do you prefer (Aquamacs, Carbon Emacs, other?)

2010-06-12 Thread Moritz Ulrich
I prefer the native Emacs.app compiled from source.

Aquamacs integrates nice, but it changes many emacs keybinding
per-default and makes it hard to change them, which is a no-go for me.
Also, if you have a nicely-configurated Emacs.app instance running,
you can switch easily to other "standard" emacs versions, which you
can't so easily with Aquamacs.

On Sat, Jun 12, 2010 at 2:25 PM, Thomas Kjeldahl Nilsson
 wrote:
> What are the major differences in the different distributions,
> particularly for Clojure development?
>
> I've got everything (Slime, Paredit, Clojure-mode etc) set up in
> Carbon emacs and it works great, just curious if there are any
> substantials gains to be had in Aquamacs or other alternative
> distributions. :)
>
>
> Regards,
> Thomas Kjeldahl Nilsson
> http://kjeldahlnilsson.net
>
> --
> 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
Programmer, Student, Almost normal Guy

http://www.google.com/profiles/ulrich.moritz

-- 
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: ANN: Conjure 0.6 Released

2010-06-12 Thread James Reeves
On 11 June 2010 22:52, Matt  wrote:
> I have thought about much of what you posted. My replies are below.
>
> 1. I have looked at stronger integration of ring and Conjure, but the
> latest version of Ring was a big change from the previous version and
> I wanted to get a new version of Conjure out. When I wrote the code
> handling parameters, cookies and sessions, Ring did not.

I was in much the same position as you a few months ago. Refactoring
Compojure to use the Ring libraries took a lot of work, so I have an
idea of the amount of effort involved :)

> I would much rather rely on Ring for those areas, however, I'm
> not sure if cookies and sessions will integrate with Conjure.
> I'll take a look at it.

If they don't, let me know. I know the session handling is a little
opinionated, although libraries like Sandbar have been developed to
give Ring cookies a more stateful feel.

> 2. I've looked at Leiningen in the past, and decided it was too much
> work to switch over and didn't really gain me anything since Conjure
> isn't a library. The only way Leiningen would help is in removing the
> jars from the lib directory. I may update lancet to pull jars from
> clojars, but I think someone would kill me for that. :)

But is there any advantage to having all the code in a framework
structure? Ruby on Rails itself keeps its core libraries in gems.

Perhaps you could package Conjure as a normal jar, and then write a
"conjure" shell script that would create a project skeleton and
downloads all the right jar files. This is probably the nearest
Clojure equivalent to the way RoR handles it.

Another idea is to write a conjure Leiningen plugin. Then developers
could create a project using Leiningen, and then use "lein conjure" to
generate all the directory paths, etc. e.g.

$ lein new my-project
$ cd my-project
$ vim project.clj  # add conjure deps
$ lein deps
$ lein conjure skeleton
... generates conjure skeleton ...
$ lein conjure server
... starts conjure server ...

I honestly think the biggest disadvantage of Conjure right now is that
it doesn't behave like a normal Clojure library. Other than that, it
looks pretty good!

RoR started off with much the same structure as Conjure, but has been
slowly moving away from it. RoR 3 is now basically just a bunch of
libraries and a script that generates a very thin directory structure.

> 3. You're the third person this week to mention something about making
> Conjure apps into a war file. I'm making this highest priority. I'm
> not sure if I need to rearrange the directory structure. I don't have
> much experience with war files. I guess I will soon.

I believe there's a leiningen-war project on GitHub that generates war
files for a Leiningen project. You may want to take a look at that.

> 5. I'll check out clout, but I have the routing like I want it. I've
> made it flexible enough to use the Rails like routing (older version)
> and still allow people to create their own routing. Actually, looking
> at clout just now, I think I can just drop it in.

If there's any problem with dropping it in, let me know. I tried to
make it as straightforward as possible, but I might not have thought
of everything :)

- James

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


Re: Can anyone create a simpler version of prime factors in Clojure?

2010-06-12 Thread Russell Christopher
You're right. Hope I haven't offended with the fail, I thought I had tested
it - by iterating over a range and comparing it to Uncle Bob's but obviously
I didn't do that right and then realized that factorization is likely not
O(n) anyway. I'll probably take more time next time.

Regards,
Russell

On Sat, Jun 12, 2010 at 5:11 AM, Steve Purcell  wrote:

> On 11 Jun 2010, at 20:35, Russell Christopher wrote:
>
> > didn't need the assoc in my previous try
> >
> > (defn of [n]
> >   (letfn [(f [res k]
> >  (if (= 0 (rem (:n res) k))
> >{:n (/ (:n res) k) :fs (conj (:fs res) k)}
> >res))]
> > (:fs (reduce f  {:n n :fs []} (range 2 n)
>
>
> The two give different answers. Given n=144, your version produces [2 3 4
> 6] and Uncle Bob's produces [2 2 2 2 3 3].
>
> -Steve
>
> --
> 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

Protocol type hints - Java interface

2010-06-12 Thread David McNeil
As near as I can tell the protocol type hints are not used in the
resulting Java interface. For example:

(ns demo.impl.boat)

(defprotocol Boat
  (go [boat ^int distance]))

Leads to:

javap -classpath target/classes demo.impl.boat.Boat
public interface demo.impl.boat.Boat{
public abstract java.lang.Object go(java.lang.Object);
}

The argument that I hinted to be an "int" appears in the interface as
an "Object". This becomes an issue if I try to use the interface for
Java interop (as the definition of an API for Java callers to use).
Currently I am working around this with gen-interface.

Does anyone know if there are long term plans to use the hints to type
the values in the interface? Or maybe I am just doing something wrong?

Thanks.
-David McNeil

-- 
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: ANN: Robert Hooke

2010-06-12 Thread Phil Hagelberg
On Fri, Jun 11, 2010 at 10:29 AM, Tom Faulhaber  wrote:
> Nice! I think this kind of functionality should end up getting
> promoted. I have also written this a couple of times and thought about
> generalizing it. I'm glad you did.

Cool.

I'm not sure how broadly-applicable it is--you want it when you're
building programs that are designed to be extensible with plugins like
Leiningen (or Emacs; it's inspired in part by defadvice), but I'd be
reluctant to suggest it for projects where you have control over the
whole thing. I'd also be reluctant to have it promoted in such a way
that I couldn't fix bugs or make further improvements to it anymore.
But on the other hand it's only 30 lines or so; there's probably not a
whole lot more I'll do with it.

> This could also serve as the basis for some nice tracing functionality
> (esp. combined the clojure.contrib.logging). You'd want to wrap the
> hook function with a macro that also captured the function name and
> maybe arglist metadata.

Anything that the current c.c.trace lib doesn't have?

-Phil

-- 
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: Protocol type hints - Java interface

2010-06-12 Thread David Nolen
On Sat, Jun 12, 2010 at 11:21 AM, David McNeil wrote:

> As near as I can tell the protocol type hints are not used in the
> resulting Java interface. For example:
>
> (ns demo.impl.boat)
>
> (defprotocol Boat
>  (go [boat ^int distance]))


You can't put type hints on protocol methods, at least as far as I could
tell. You can however put type hints on methods defined with definterface.
Your deftype or defrecord can them implement those methods. It's important
to understand that this defines *methods* not functions. This is less than
ideal but is important if you need the performance of Java methods and the
ability to look up instance data very quickly (without going through
keywords or field access). So you get perf at the cost of idiomatic code.

Depending on your use case you could alternatively define *functions* using
the new statics feature of the prim branch. This will lead to much more
idiomatic code that has very, very good perf. I would take this route as
long as the speed of accessing some instance data is also not a concern.

An example here of type-hinting methods with definterface
http://gist.github.com/420036.

David

-- 
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: Mac Emacs users: which version do you prefer (Aquamacs, Carbon Emacs, other?)

2010-06-12 Thread David Nolen
Carbon Emacs is great, I used it for years. However it will no longer be
supported. I've since switched over to the Cocoa 23 port. It's lacking in
some niceties but it's totally usable.

On Sat, Jun 12, 2010 at 8:25 AM, Thomas Kjeldahl Nilsson <
tho...@kjeldahlnilsson.net> wrote:

> What are the major differences in the different distributions,
> particularly for Clojure development?
>
> I've got everything (Slime, Paredit, Clojure-mode etc) set up in
> Carbon emacs and it works great, just curious if there are any
> substantials gains to be had in Aquamacs or other alternative
> distributions. :)
>
>
> Regards,
> Thomas Kjeldahl Nilsson
> http://kjeldahlnilsson.net
>
> --
> 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: Protocol type hints - Java interface

2010-06-12 Thread David McNeil
David - Thanks for the tips on definterface and the new statics
feature. I will need to look into these because I am not familiar with
either. What is the difference between gen-interface and definterface?

Thanks.
-David McNeil

-- 
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: Can anyone create a simpler version of prime factors in Clojure?

2010-06-12 Thread Steve Purcell
On 12 Jun 2010, at 16:18, Russell Christopher wrote:

> You're right. Hope I haven't offended with the fail, I thought I had tested 
> it - by iterating over a range and comparing it to Uncle Bob's but obviously 
> I didn't do that right and then realized that factorization is likely not 
> O(n) anyway. I'll probably take more time next time.


No offense was caused.  I thought I'd tinker with the code, aiming to replace 
the :n & :fs with destructuring, and then got distracted by the pedantic matter 
of correctness. :-)

-Steve

-- 
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: Protocol type hints - Java interface

2010-06-12 Thread Meikel Brandmeyer
Hi,

Am 12.06.2010 um 18:09 schrieb David McNeil:

> What is the difference between gen-interface and definterface?


definterface is a convenience function which just calls gen-interface and 
imports the resulting interface.

Sincerely
Meikel

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


Re: Can anyone create a simpler version of prime factors in Clojure?

2010-06-12 Thread Russell Christopher
I focused more on idiom than correctness (obviously). Took a risk with not
much effort except to see if I could do any better with a toy problem. The
answer was no, Uncle Bob's is "idiomatic" modulo some minor things.

On Sat, Jun 12, 2010 at 12:59 PM, Steve Purcell  wrote:

> On 12 Jun 2010, at 16:18, Russell Christopher wrote:
>
> > You're right. Hope I haven't offended with the fail, I thought I had
> tested it - by iterating over a range and comparing it to Uncle Bob's but
> obviously I didn't do that right and then realized that factorization is
> likely not O(n) anyway. I'll probably take more time next time.
>
>
> No offense was caused.  I thought I'd tinker with the code, aiming to
> replace the :n & :fs with destructuring, and then got distracted by the
> pedantic matter of correctness. :-)
>
> -Steve
>
> --
> 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: Protocol type hints - Java interface

2010-06-12 Thread David Nolen
Here is a gist of what statics look like: http://gist.github.com/432465

David

On Sat, Jun 12, 2010 at 12:09 PM, David McNeil wrote:

> David - Thanks for the tips on definterface and the new statics
> feature. I will need to look into these because I am not familiar with
> either. What is the difference between gen-interface and definterface?
>
> Thanks.
> -David McNeil
>
> --
> 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

Using PRXML lib

2010-06-12 Thread Emeka
Hello All,

Could someone direct me on how to write the output of prxml form to a file?

Regards,
Emeka

-- 
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: Reduce a function over more than one sequence (like map)

2010-06-12 Thread Nathan Sorenson
Thanks for the replies. Indeed, I have been approaching the issue with
destructuring, as suggested. It still seems to me that reduce* is
consistent with the behaviour of map, in that it is polyvariadic and
doesn't require packing arguments into and out of a single sequence.
However, its good to know the destructuring approach is more or less
the obvious way to go about things, and I am not overlooking an
idiomatic approach.

On Jun 12, 3:53 am, Jürgen Hötzel  wrote:
> 2010/6/11 Nathan Sorenson :
>
> > Is there a way to fold over multiple sequences, in the same way that
> > 'map' can apply a multi-parameter function over several seqs? In other
> > words, is there a function like this:
>
> There is no need for a special purpose reduce* function.
> Using destructing binding as Sean explains and creating an
> intermediate lazy sequence of key/value pairs, this leads to short and
> concise code:
>
> (reduce (fn [m [k v]] (assoc m k v)) {} (map vector [:one :another]
> (iterate inc 1)))
>
> A good example of Alan J. Perlis quote and  Clojure rationale:
>
> "It is better to have 100 functions operate on one data structure than
> to have 10 functions operate on 10 data structures."
>
> Jürgen

-- 
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: Using PRXML lib

2010-06-12 Thread Moritz Ulrich
You can use (with-out-str &body) to capture the output or prxml to a
string and write that string to a file.

On Sat, Jun 12, 2010 at 8:53 PM, Emeka  wrote:
> Could someone direct me on how to write the output of prxml form to a file?



-- 
Moritz Ulrich
Programmer, Student, Almost normal Guy

http://www.google.com/profiles/ulrich.moritz

-- 
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: Using PRXML lib

2010-06-12 Thread Emeka
Hello Moritz,

prxml form prints on the console, my aim is to redirect it to print to a
file. I have not been able to achieve this. I have looked at the prxml lib
code, it prints to *out*, it returns nil. My interest is on capturing the
output of prxml and writing it to a file.

Regards,
Emeka

On Sat, Jun 12, 2010 at 8:23 PM, Moritz Ulrich  wrote:

> You can use (with-out-str &body) to capture the output or prxml to a
> string and write that string to a file.
>
> On Sat, Jun 12, 2010 at 8:53 PM, Emeka  wrote:
> > Could someone direct me on how to write the output of prxml form to a
> file?
>
>
>
> --
> Moritz Ulrich
> Programmer, Student, Almost normal Guy
>
> http://www.google.com/profiles/ulrich.moritz
>
> --
> 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

agents sending-off to other agents blocks?

2010-06-12 Thread Dan Larkin
Hey all,

I've cooked up this example code to demonstrate a point:

(send-off
 (agent nil)
 (fn [_]
   (send-off
(agent nil)
(fn [_]
  (println "Hey!")))
   (Thread/sleep 4000))) ; "Hey!" isn't printed for 4 seconds (when the outer 
agent finishes).

Which is that actions sent to an agent from another agent won't be started 
until the first agent returns from its current action.

Does anyone have insight as to the reasoning here? Is it a bug? If it's 
intended behavior is there something I can do to circumvent it?


Dan

-- 
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: Using PRXML lib

2010-06-12 Thread Emeka
Thanks, it worked :(

On Sat, Jun 12, 2010 at 8:23 PM, Moritz Ulrich  wrote:

> You can use (with-out-str &body) to capture the output or prxml to a
> string and write that string to a file.
>
> On Sat, Jun 12, 2010 at 8:53 PM, Emeka  wrote:
> > Could someone direct me on how to write the output of prxml form to a
> file?
>
>
>
> --
> Moritz Ulrich
> Programmer, Student, Almost normal Guy
>
> http://www.google.com/profiles/ulrich.moritz
>
> --
> 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: agents sending-off to other agents blocks?

2010-06-12 Thread Moritz Ulrich
I'm not sure why it's doing this, but I read about this in the api
documentation - It's intended

On Sat, Jun 12, 2010 at 9:41 PM, Dan Larkin  wrote:
> Hey all,
>
> I've cooked up this example code to demonstrate a point:
>
> (send-off
>  (agent nil)
>  (fn [_]
>   (send-off
>    (agent nil)
>    (fn [_]
>      (println "Hey!")))
>   (Thread/sleep 4000))) ; "Hey!" isn't printed for 4 seconds (when the outer 
> agent finishes).
>
> Which is that actions sent to an agent from another agent won't be started 
> until the first agent returns from its current action.
>
> Does anyone have insight as to the reasoning here? Is it a bug? If it's 
> intended behavior is there something I can do to circumvent it?
>
>
> Dan
>
> --
> 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
Programmer, Student, Almost normal Guy

http://www.google.com/profiles/ulrich.moritz

-- 
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: agents sending-off to other agents blocks?

2010-06-12 Thread Moritz Ulrich
Sorry for the second mail, but here is the passage from clojure.org
which mentions the behavior you've seen:

"5. If during the function execution any other dispatches are made
(directly or indirectly), they will be held until after the state of
the Agent has been changed."


Maybe it's done to prevent problems when the function the
currently-active agent sent to another agent depends on the value of
the original agent.

On Sat, Jun 12, 2010 at 9:43 PM, Moritz Ulrich
 wrote:
> I'm not sure why it's doing this, but I read about this in the api
> documentation - It's intended
>
> On Sat, Jun 12, 2010 at 9:41 PM, Dan Larkin  wrote:
>> Hey all,
>>
>> I've cooked up this example code to demonstrate a point:
>>
>> (send-off
>>  (agent nil)
>>  (fn [_]
>>   (send-off
>>    (agent nil)
>>    (fn [_]
>>      (println "Hey!")))
>>   (Thread/sleep 4000))) ; "Hey!" isn't printed for 4 seconds (when the outer 
>> agent finishes).
>>
>> Which is that actions sent to an agent from another agent won't be started 
>> until the first agent returns from its current action.
>>
>> Does anyone have insight as to the reasoning here? Is it a bug? If it's 
>> intended behavior is there something I can do to circumvent it?
>>
>>
>> Dan
>>
>> --
>> 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
> Programmer, Student, Almost normal Guy
>
> http://www.google.com/profiles/ulrich.moritz
>



-- 
Moritz Ulrich
Programmer, Student, Almost normal Guy

http://www.google.com/profiles/ulrich.moritz

-- 
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: agents sending-off to other agents blocks?

2010-06-12 Thread Dan Larkin
Thanks for finding that Moritz :)

I am not using the value from the current agent in the new agent though, so 
this dispatch delay is a little annoying.

I suppose I can use a future instead of an agent, though it doesn't have all 
the nice properties that agents do (once action a time).

Maybe I'll write a function that pulls from a BlockingQueue and run it on a 
Thread.

Anyway, thanks again.

Dan


On Jun 12, 2010, at 3:46 PM, Moritz Ulrich wrote:

> Sorry for the second mail, but here is the passage from clojure.org
> which mentions the behavior you've seen:
> 
> "5. If during the function execution any other dispatches are made
> (directly or indirectly), they will be held until after the state of
> the Agent has been changed."
> 
> 
> Maybe it's done to prevent problems when the function the
> currently-active agent sent to another agent depends on the value of
> the original agent.
> 
> On Sat, Jun 12, 2010 at 9:43 PM, Moritz Ulrich
>  wrote:
>> I'm not sure why it's doing this, but I read about this in the api
>> documentation - It's intended
>> 
>> On Sat, Jun 12, 2010 at 9:41 PM, Dan Larkin  wrote:
>>> Hey all,
>>> 
>>> I've cooked up this example code to demonstrate a point:
>>> 
>>> (send-off
>>>  (agent nil)
>>>  (fn [_]
>>>   (send-off
>>>(agent nil)
>>>(fn [_]
>>>  (println "Hey!")))
>>>   (Thread/sleep 4000))) ; "Hey!" isn't printed for 4 seconds (when the 
>>> outer agent finishes).
>>> 
>>> Which is that actions sent to an agent from another agent won't be started 
>>> until the first agent returns from its current action.
>>> 
>>> Does anyone have insight as to the reasoning here? Is it a bug? If it's 
>>> intended behavior is there something I can do to circumvent it?
>>> 
>>> 
>>> Dan
>>> 
>>> --
>>> 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
>> Programmer, Student, Almost normal Guy
>> 
>> http://www.google.com/profiles/ulrich.moritz
>> 
> 
> 
> 
> -- 
> Moritz Ulrich
> Programmer, Student, Almost normal Guy
> 
> http://www.google.com/profiles/ulrich.moritz
> 
> -- 
> 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: Mac Emacs users: which version do you prefer (Aquamacs, Carbon Emacs, other?)

2010-06-12 Thread Phil Hagelberg
On Sat, Jun 12, 2010 at 5:25 AM, Thomas Kjeldahl Nilsson
 wrote:
> What are the major differences in the different distributions,
> particularly for Clojure development?
>
> I've got everything (Slime, Paredit, Clojure-mode etc) set up in
> Carbon emacs and it works great, just curious if there are any
> substantials gains to be had in Aquamacs or other alternative
> distributions. :)

Carbon Emacs is pretty outdated; it's based on Emacs 22. (c. 2007)
Aquamacs messes up a lot of the defaults and isn't portable, so most
elisp library authors can't test on it or help you debug problems
you're having with it. I recommend the Cocoa build of GNU Emacs:
http://emacsformacosx.com has prebuilt binaries.

-Phil

-- 
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: Mac Emacs users: which version do you prefer (Aquamacs, Carbon Emacs, other?)

2010-06-12 Thread Steven E. Harris
Moritz Ulrich  writes:

> Aquamacs integrates nice, but it changes many emacs keybinding
> per-default and makes it hard to change them, which is a no-go for me.

Here's what I use (so far) to beat it back into shape:

(cua-mode 0)
(transient-mark-mode 1)
(pending-delete-mode 1)

;; I'm not ready to accept the separation of the Emacs kill ring and
;; the system clipboard.
(osx-key-mode 0)

;; Revert the binding for `recentf-open-files' defined in
;; 
/Applications/Aquamacs.app/Contents/Resources/lisp/aquamacs/macosx/aquamacs-menu.el:
(global-set-key "\C-x\ \C-r" 'find-file-read-only)

-- 
Steven E. Harris

-- 
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: Using PRXML lib

2010-06-12 Thread James Reeves
You can also change the binding of *out* to point directly to your file writer.

- James

On 12 June 2010 20:43, Emeka  wrote:
> Thanks, it worked :(
>
> On Sat, Jun 12, 2010 at 8:23 PM, Moritz Ulrich
>  wrote:
>>
>> You can use (with-out-str &body) to capture the output or prxml to a
>> string and write that string to a file.
>>
>> On Sat, Jun 12, 2010 at 8:53 PM, Emeka  wrote:
>> > Could someone direct me on how to write the output of prxml form to a
>> > file?
>>
>>
>>
>> --
>> Moritz Ulrich
>> Programmer, Student, Almost normal Guy
>>
>> http://www.google.com/profiles/ulrich.moritz
>>
>> --
>> 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: Mac Emacs users: which version do you prefer (Aquamacs, Carbon Emacs, other?)

2010-06-12 Thread Rob Lachlan
I agree that the cocoa builds are the nicest.  But there is one
problem that I've had with them: I wasn't able to successfully install
swank-clojure through elpa from within that emacs.  Curiously, I was
able to install it through elpa in aquamacs, and then I had no problem
using swank-clojure from within the cocoa (emacsforosx.com) emacs.

I'm at a loss to account for this, and I don't have the emacs-fu to
debug this.

All that aside, yeah the cocoa (emacsforosx.com) builds are very nice,
minimalist and very functional.

On Jun 12, 3:31 pm, Phil Hagelberg  wrote:
> On Sat, Jun 12, 2010 at 5:25 AM, Thomas Kjeldahl Nilsson
>
>  wrote:
> > What are the major differences in the different distributions,
> > particularly for Clojure development?
>
> > I've got everything (Slime, Paredit, Clojure-mode etc) set up in
> > Carbon emacs and it works great, just curious if there are any
> > substantials gains to be had in Aquamacs or other alternative
> > distributions. :)
>
> Carbon Emacs is pretty outdated; it's based on Emacs 22. (c. 2007)
> Aquamacs messes up a lot of the defaults and isn't portable, so most
> elisp library authors can't test on it or help you debug problems
> you're having with it. I recommend the Cocoa build of GNU 
> Emacs:http://emacsformacosx.comhas prebuilt binaries.
>
> -Phil

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