Re: IDE agnostic question on user assistance (emacs/vimClojure users help appreciated too !)

2010-07-21 Thread Aaron Cohen
On Wed, Jul 21, 2010 at 9:33 AM, Meikel Brandmeyer  wrote:

> Hi,
>
> On Jul 21, 1:35 pm, Jeff Rose  wrote:
>
> > Really, there isn't a way to start processes from VIM?  How about just
> > opening a temporary buffer for the output of the nailgun server, and
> > then start it with a bang!?
>
> I was a but unclear on what I mean with background: I can start
> processes from Vim. That's not the problem. But then Vim waits for
> them to complete. And no. Adding & doesn't help, because it doesn't
> work in Windows. So you fire up your server and have a waiting Vim
> which cannot be used anymore. Ah, the attainments of single-threaded
> applications. There is certainly no race condition. Bleh. :(
>
> If this was not the case I could offer such a starter command.
> Although I doubt it has much value, because Vim's started from the
> graphical user interface don't know your project directory. So
> starting at plugin load would not work. So you need another command
> (maybe key bindings) to start the server after changing the vim cwd
> (or providing it as an argument). Complexity creeps in for a non-
> issue.


Apologies if you know all this Meikel, but have you seen
http://vim.wikia.com/wiki/Execute_external_programs_asynchronously_under_Windows
?

--Aaron

-- 
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: IDE agnostic question on user assistance (emacs/vimClojure users help appreciated too !)

2010-07-21 Thread j-g-faustus
On Jul 20, 10:15 am, Laurent PETIT  wrote:
> Oh, maybe I understand: by "partial drafts", you mean "pseudo-code",
> directly written in clojure, is it this ?

It could be pseudo-code or partial implementations or code that is
more or less complete but won't compile because the functions or libs
it is using aren't written yet. Or a number of other things that might
cause compilation to fail.

The non-compiling code tends to be syntactically correct, at least
enough to get the Enclojure paren-matching, bulk formatting and code
navigator to work - these are all things I want to help me quickly
navigate the drafts.


> If there was a shortcut key to quickly wrap/unwrap a top level defn with
> (comment), and if the keyboard shortcut for "evaluate top level form in the
> REPL" would be smart enough to detect top level comment and send to the REPL
> the unwrapped form, would it help you ?
> That way, your files would visually show the "pseudo-code" parts (those
> within comments), and your namespaces will remain in a loadable shape,
> eventually relieving you from manually load your project "piece by piece"
> every time you must restart a REPL ?

Actually, it's an interesting idea.

If I were to think aloud on a possible feature in a future IDE, it
could go something like this:

- Some special markup for pseudo-code. Not (comment) as it is already
used for comments, but perhaps something like (pseudo) or (draft). It
would act as a comment from the compiler's perspective but the IDE
could treat it differently.
Or perhaps a keyword argument to comment, ignored by the compiler but
read by the IDE - like (comment :pseudo ).

- The contents of (pseudo) would be parsed and displayed in the code
navigator window (I assume CCW has one as well?) as a distinct group
or marked in some other way, so you could at a glance see which
functions/vars are implemented and which ones are still at the draft
stage.
It would be a code-level TODO-list of sorts.

It would have the advantage over what I am doing in Enclojure today
that I could load the non-draft functions without resorting to
"evaluate expression", and the navigator window would explicitly show
me what remains to be implemented. Very handy for large files.

I can't see the immediate need to send pseudo-code to the REPL - it's
in the pseudo-tag because it doesn't work, isn't it? (Copy/paste works
fine for those rare occasions where I might want to do so anyway.)
I would probably edit it in the editor, move it out of the pseudo-tag
when it is ready for testing and evaluate it then.

I guess something like this would take a few iterations to get right,
but I imagine I would find it very useful.


Regards
jf

-- 
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: Two convenience methods

2010-07-21 Thread B Smith-Mannschott
On Wed, Jul 21, 2010 at 23:45, Travis Hoffman
 wrote:
...
> The second function is suggested as an addition to clojure.set. The
> "disjoint?" function decides if two sets have no elements in common.
> This can easily be done using:
>
>  (not (nil? (intersection s1 s2)))
>
> but this implementation should be more efficient (I think) and is more
> readable, imho:
>
> (defn disjoint?
>  "Is set1 disjoint from set2?"
>  {:added "1.3" :tag Boolean}
>  [set1 set2]
>  (if (<= (count set1) (count set2))
>    (recur set2 set1)
>    (not-any? (fn [item] (contains? item set1)) set2)))

so, when set1 and set2 are the same size, we recur, swapping the order
of the two arguments, which means set2 and set1 are the same size, so
we recur, swapping the two arguments, which means ...

  (if (< (count set1) (count set2))
(recur set2 set1)
...)

would be better, no?

// ben

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


Re: gobble up a collection 2 at a time

2010-07-21 Thread David Cabana
Here's my take:

(defn mmap [f coll]
  (->> coll
   (partition 2)
   (map (fn [[x y]] (f x y)

For instance:
user> (mmap + (range 8))
(1 5 9 13)
user> (mmap * (range 8))
(0 6 20 42)

You probably want to think about whether you'll see input sequences
with an odd number of terms, and how best to handle them.

-- 
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: Literate Clojure - a good lead ...

2010-07-21 Thread Tim Daly



Antony Blakey wrote:

On 22/07/2010, at 3:08 AM, Tim Daly wrote:

  

"Language integration" is a false goal. It is technically possible to
call functions in any language from latex but unnecessary in general.
It is technically possible to generate latex from any language.



Have you read the paper? Being able to automatically embed the output of 
examples is a big win IMO.
  
Yes, I read the paper. You can call external routines to generate output 
into latex

in many systems and languages. There are many such examples:

Here you can create live 3D rendering in a pdf using latex:
http://meshlabstuff.blogspot.com/2009/03/creating-interactive-3d-objects-inside.html

Here you can render images into latex
http://www.mayer.dial.pipex.com/tex.htm

Here you can create latex from javascript:
http://code.google.com/p/jstexrender/

PDF with animations from latex:
http://www.uoregon.edu/~noeckel/PDFmovie.html

Automatic latex generation from Maple:
http://www.math.tamu.edu/~boas/courses/math696/converting-Maple-code-into-LaTeX.html

And, of course, the Haskell-in-Latex:
http://yav.purely-functional.net/haskell_latex.html

I have dozens more, since I tend to collect them. Axiom can even
generate latex (or fortran or mathml or html) automatically.
The technology isn't the point, though.

The point is that you're writing a document that happens to include code.

If you were going to write a PROGRAM you wouldn't start with latex as the
primary tool even though it is turing complete and can implement scheme.
Since the GOAL of literate programming is to write a DOCUMENT,
the primary tool is one that is designed to express documents.

I would love to see Clojure embrace literate programming. I believe that
a book that explained all of the details of why Clojure chose agents, refs,
immutable data structures, the Java integration strategy and the constraints
it imposes, the choice of lazy functions, the REPL, the AOT techniques,
the use of time and state and many other choices would make most of the
questions/comments/debates on this list pointless. People could just read
a chapter on fast-arithmetic and see the choices made. And, oh-by-the-way,
the code to implement those choices is in the book.

It would also make it easier to see when and why changes need to be made
to keep up with technology. The 32 element tree structure is almost 
certainly

a function of todays cache-line sizes. What happens when the technology
moves to light-busses and the cache-line is now 4k? Will it be meaningful
to have a 4k-per-level tree structure? What are the tradeoffs and why were
they made? Rich knows.

Instead we will continue to have a stream of people who are learning Clojure
being taught "in an oral tradition" by helpful people on the mailing 
list. And we
will have limited opportunity to contribute to the core code because 
there is a

very steep learning curve to swallow all of that code when you have to guess
what the design decisions were. It is a modern day version of the 
pre-printing

press, medieval guild-worker technology.

Clojure is moving away from the "old lisp way" of doing things but it is
continuing the tradition of "tiny-little-files-in-a-file-system 
hierarchy" from

the PDP-11/40 4k-max-file-size C programming days with make-ant-lein,
stuff-on-the-path, 60s unix techniques and mindset.

Literate programming would put it all into a book and let the machine
handle the details without the programmer knowing or caring. The book
is completely unconstrained in size since you would never print it. The
namespace issue disappears since you can simply use (hidden) section
names automatically. Tutorials become test cases as well as an
opportunity to show detailed examples. References to published papers
to support the design choices would be "expected", as in any professional
piece of technical writing.

The real benefit is in the long term. Clojure could be read and taught
without pain to a whole new generation without the original authors.
It is like Clojure discovered the printing press.

Tim Daly

--
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: gobble up a collection 2 at a time

2010-07-21 Thread Wilson MacGyver
you have to partition it first.

user=> (partition 2 [1 2 3 4 5 6 7 8])
((1 2) (3 4) (5 6) (7 8))


let's say we want to add the numbers.

user=> (map #(apply + %) (partition 2 [1 2 3 4 5 6 7 8]))
(3 7 11 15)



On Wed, Jul 21, 2010 at 10:20 PM, Glen Rubin  wrote:
> Hi!  I want to process a collection 2 elements at a time using map.
>
> My function accepts 2 parameters (a,b) and returns a result (c):
>
> (myfcn [a b])
>
>  => c
>
> so I want to iterate myfcn over a collection and create a new sequence
>
> for example let's say myfcn sums a and b, then i would like to do
> something like this:
>
> (map myfcn '(1 2 3 4 5 6 7 8)
>
> => 3 7 11 15
>
> accept i get the error that myfcn is being passed the wrong number of
> arguments, since map is passing them in 1 at a time.  How do I get map
> to pass in 2 at a time?
>
> thx!
>
> --
> 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



-- 
Omnem crede diem tibi diluxisse supremum.

-- 
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: gobble up a collection 2 at a time

2010-07-21 Thread jim
Use partition:

(map (apply myfcn) (partition 2 [1 2 3 4 5 6 7 8]))

Or something like that. Not at a REPL so that's from memory.
Experiment with partition at the repl and it'll become clear.

Jim

On Jul 21, 9:20 pm, Glen Rubin  wrote:
> Hi!  I want to process a collection 2 elements at a time using map.
>
> My function accepts 2 parameters (a,b) and returns a result (c):
>
> (myfcn [a b])
>
>  => c
>
> so I want to iterate myfcn over a collection and create a new sequence
>
> for example let's say myfcn sums a and b, then i would like to do
> something like this:
>
> (map myfcn '(1 2 3 4 5 6 7 8)
>
> => 3 7 11 15
>
> accept i get the error that myfcn is being passed the wrong number of
> arguments, since map is passing them in 1 at a time.  How do I get map
> to pass in 2 at a time?
>
> thx!

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


gobble up a collection 2 at a time

2010-07-21 Thread Glen Rubin
Hi!  I want to process a collection 2 elements at a time using map.

My function accepts 2 parameters (a,b) and returns a result (c):

(myfcn [a b])

 => c

so I want to iterate myfcn over a collection and create a new sequence

for example let's say myfcn sums a and b, then i would like to do
something like this:

(map myfcn '(1 2 3 4 5 6 7 8)

=> 3 7 11 15

accept i get the error that myfcn is being passed the wrong number of
arguments, since map is passing them in 1 at a time.  How do I get map
to pass in 2 at a time?

thx!

-- 
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: Literate Clojure - a good lead ...

2010-07-21 Thread martin_clausen
A good example of this for a non-trivial app is here:

http://genprog.adaptive.cs.unm.edu/asm/instructions.html

/mac

On Jul 21, 8:54 am, Tassilo Horn  wrote:
> On Wednesday 21 July 2010 06:32:02 Mark Engelberg wrote:
>
> Hi Mark,
>
> > I would definitely welcome a literate Clojure tool.
>
> You might want to have a look at Emacs' org-mode [1].  It has a facility
> called Babel [2] that allows for literate programming in all the
> languages listed at [3], Clojure being one of them, and support for new
> languages is being added frequently.
>
> Currently it is moved from the contribution directory to the org core,
> and the documentation is being updated or written at all.
>
> Bye,
> Tassilo
> __
> [1]http://orgmode.org/
> [2]http://orgmode.org/manual/Working-With-Source-Code.html#Working-With-...
> [3]http://orgmode.org/manual/Languages.html#Languages

-- 
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: BUG: Clojure hierarchies (affects 1.2-beta1)

2010-07-21 Thread Michał Marczyk
Made a ticket for this here (including the simple diagnosis):

https://www.assembla.com/spaces/clojure/support/tickets/406-typo-in-underive-causes-breaking-in-the-resulting-hierarchy

No patch, since my CA wasn't ack'd yet...

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: Two convenience methods

2010-07-21 Thread Frederick Polgardy
Ok you said this too. :) But the non-booleanness of (some ...) isn't that 
important. The result of (some ...) is truthy, and can be used in any boolean 
context.

-Fred

--
Science answers questions; philosophy questions answers.

On Jul 21, 2010, at 8:07 PM, Frederick Polgardy wrote:

> http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/some
> 
> --
> Science answers questions; philosophy questions answers.
> 
> On Jul 21, 2010, at 4:45 PM, Travis Hoffman wrote:
> 
>> (defn any?
>> "Returns true if (pred x) is logically true for one x in coll, else
>> false."
>> {:added "1.3" :tag Boolean}
>> [pred coll]
>> (when (seq coll)
>>   (or (pred (first coll)) (recur pred (next coll)
> 

-- 
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: Two convenience methods

2010-07-21 Thread Frederick Polgardy
Oops, you already said that, my bad. :)

--
Science answers questions; philosophy questions answers.

On Jul 21, 2010, at 8:13 PM, Frederick Polgardy wrote:

> Or [using clojure.set] (empty? (intersection s1 s2)).
> 
> --
> Science answers questions; philosophy questions answers.
> 
> On Jul 21, 2010, at 4:45 PM, Travis Hoffman wrote:
> 
>> The second function is suggested as an addition to clojure.set. The
>> "disjoint?" function decides if two sets have no elements in common.
>> This can easily be done using:
>> 
>> (not (nil? (intersection s1 s2)))
>> 
>> but this implementation should be more efficient (I think) and is more
>> readable, imho:
>> 
>> (defn disjoint?
>> "Is set1 disjoint from set2?"
>> {:added "1.3" :tag Boolean}
>> [set1 set2]
>> (if (<= (count set1) (count set2))
>>   (recur set2 set1)
>>   (not-any? (fn [item] (contains? item set1)) set2)))
> 

-- 
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: Two convenience methods

2010-07-21 Thread Frederick Polgardy
Or [using clojure.set] (empty? (intersection s1 s2)).

--
Science answers questions; philosophy questions answers.

On Jul 21, 2010, at 4:45 PM, Travis Hoffman wrote:

> The second function is suggested as an addition to clojure.set. The
> "disjoint?" function decides if two sets have no elements in common.
> This can easily be done using:
> 
>  (not (nil? (intersection s1 s2)))
> 
> but this implementation should be more efficient (I think) and is more
> readable, imho:
> 
> (defn disjoint?
>  "Is set1 disjoint from set2?"
>  {:added "1.3" :tag Boolean}
>  [set1 set2]
>  (if (<= (count set1) (count set2))
>(recur set2 set1)
>(not-any? (fn [item] (contains? item set1)) set2)))

-- 
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: bug: clojure.walk removes all the metadata

2010-07-21 Thread Pedro Teixeira
On Jul 21, 9:59 pm, Pedro Teixeira  wrote:
> On Jun 22, 6:23 pm, Krešimir Šojat  wrote:
>
> > While traversing the data structure both prewalk and postwalk remove
> > all the metadata:
>
> > user=> (require '[clojure.walk :as w])
> > nil
> > user=> (def data {:a ^{:a :this-is-a} [1 2 3]})
> > #'user/data
> > user=> (meta (:a data))
> > {:a :this-is-a}
> > user=> (meta (:a (w/postwalk identity data)))
> > nil
> > user=> (meta (:a (w/prewalk identity data)))
> > nil
>
> This is indeed annoying and not expected, anyone has already a patch
> for this?
>

into preserves the metadata:
=>(meta (:a (into {} {:a ^{:id 1} {}} )))
{:id 1}

There is some commented out code there:
http://github.com/clojure/clojure/blob/master/src/clj/clojure/walk.clj#L69

can anyone give a hint on how to change the walk function to preserve
metatada?
or otherwise, give an argument why it does not make sense to preserve
it?



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


BUG: Clojure hierarchies (affects 1.2-beta1)

2010-07-21 Thread David Nolen
(derive ::bar ::foo)
(underive ::bar ::foo)
(derive ::bar ::foo)

results in a NullPointerException.

Also any further attempts to use derive, say:

(derive ::b ::a)

also results in a NullPointerException.

-- 
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: Two convenience methods

2010-07-21 Thread Frederick Polgardy
http://richhickey.github.com/clojure/clojure.core-api.html#clojure.core/some

--
Science answers questions; philosophy questions answers.

On Jul 21, 2010, at 4:45 PM, Travis Hoffman wrote:

> (defn any?
>  "Returns true if (pred x) is logically true for one x in coll, else
> false."
>  {:added "1.3" :tag Boolean}
>  [pred coll]
>  (when (seq coll)
>(or (pred (first coll)) (recur pred (next coll)

-- 
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: bug: clojure.walk removes all the metadata

2010-07-21 Thread Pedro Teixeira
On Jun 22, 6:23 pm, Krešimir Šojat  wrote:
> While traversing the data structure both prewalk and postwalk remove
> all the metadata:
>
> user=> (require '[clojure.walk :as w])
> nil
> user=> (def data {:a ^{:a :this-is-a} [1 2 3]})
> #'user/data
> user=> (meta (:a data))
> {:a :this-is-a}
> user=> (meta (:a (w/postwalk identity data)))
> nil
> user=> (meta (:a (w/prewalk identity data)))
> nil


This is indeed annoying and not expected, anyone has already a patch
for this?



cheers,
Pedro

-- 
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: Literate Clojure - a good lead ...

2010-07-21 Thread Antony Blakey

On 22/07/2010, at 3:08 AM, Tim Daly wrote:

> "Language integration" is a false goal. It is technically possible to
> call functions in any language from latex but unnecessary in general.
> It is technically possible to generate latex from any language.

Have you read the paper? Being able to automatically embed the output of 
examples is a big win IMO.

> Symbol resolution is also rarely an issue in literate programs.
> Your prose is intended to explain "why" a code chunks exists,
> not "how" a code chunk works. If you explain the problem you
> are trying to solve and the issues of various approaches you considered
> then I can usually understand the solution.

Symbol resolution allows the environment to link symbols and their occurrences, 
and the same with hyperlinked output.

Antony Blakey
-
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787

All that is required for evil to triumph is that good men do nothing.


-- 
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: Literate Clojure - a good lead ...

2010-07-21 Thread Mark Engelberg
On Wed, Jul 21, 2010 at 3:10 PM, Mark Fredrickson
 wrote:
> I've been playing around with a Emacs mode (more properly looking at
> existing multi-major-mode work). I'm open to ideas on how to make it
> play better with a REPL. As always, any form can be sent via C-C C-C.
> What more did you have in mind?

Thanks for making progress on this!  I'll take a look at it.

I would probably want:
1. Paren-matching and indenting to work properly in clojure blocks
(and ability to reformat whole file), without screwing up the text
blocks.  Similarly, quotes and parentheses in the text area shouldn't
screw up the formatting of the code blocks.
2. C-C C-K to compile all the code in the file, with stacktraces
reporting errors at a sensible line number within the file.
3. A way to AOT-compile the project that understands how to find the
clojure blocks, (perhaps a lein plugin?).
4. A keystroke combination to do the latex processing (I don't need it
to happen every time I compile).

-- 
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: Literate Clojure - a good lead ...

2010-07-21 Thread Mark Fredrickson

> I'd be perfectly happy with a LaTeX-based solution, although I
> understand the appeal of something more "within Clojure".

I've been playing with a Clojure solution:

http://github.com/markmfredrickson/changeling

I just pushed a version to clojars as well.

> As a first approximation, literate programming needs to make it easy
> to enter English text with code snippets that run.  Haskell does this
> by assuming that in a file ending in .lhs (as opposed to .hs), by
> default, a line is plain English text unless specifically marked as
> code (instead of the other way around).

This is how changeling works. Clojure code is delineated in ... blocks. Everything else is implemented as macros and functions
(REPL style output, context aware formatting for Markdown & LaTex,
etc.); therefore, extendable by users. You do have to set the output
context yourself (see the README), but I've got plans to make it
figure that out automatically for well named files (e.g.
file.tex.changeling).

>
> This is a good start, but Knuth's conception of literate programming
> usually supports breaking code into very small hyperlinked chunks,
> cross-indexing up the wazoo, and language-aware formatting and
> indexing.

Changeling passes on that. Now and forever.

> And honestly, I find none of this is much use without an
> editor/compiler/debugger that understands this format.  So in my mind,
> that would be the real challenge.  Rather than just make tools that
> tangle/weave Clojure/LaTeX, I need to be able to easily edit and then
> compile that to the REPL in Emacs/Enclojure/etc.  [Note to self:  Go
> look at that orgmode link after writing this email]

Perhaps you could jury rig something to automatically compile to LaTeX
everytime you update the file. For example, using

http://github.com/mynyml/watchr

>
> In any case, any of these tools, even the most basic, if integrated
> with the rest of the Clojure edit/compile/eval/debug process in some
> editor (I've been primarily using Emacs but am gradually starting to
> prefer Enclojure), would be something I would likely use.

I've been playing around with a Emacs mode (more properly looking at
existing multi-major-mode work). I'm open to ideas on how to make it
play better with a REPL. As always, any form can be sent via C-C C-C.
What more did you have in mind?

-M

-- 
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-contrib replace-first-str

2010-07-21 Thread jandot
Thanks Stuart. Got it working now.

jan.

On Jul 21, 2:28 pm, Stuart Halloway  wrote:
> Hi Jan,
>
> These functions in contrib are deprecated (and will be marked so as soon as 
> we have time to make a pass through contrib).
>
> Please use the functions in clojure.string.
>
> Stuart Halloway
> Clojure/corehttp://clojure.com
>
>
>
> > Hi,
>
> > I'm using replace-str and replace-first-str (from clojure-contrib
> > 1.2.0-beta1), and it seems that these do not have the same
> > functionality contrary to their descriptions.The following code will
> > work with the regular (replace-str), but (replace-first-str) returns
> > an error:
>
> > user=> (replace-str "a" "f" "abcabc")
> > "fbcfbc"
> > user=> (replace-first-str "a" "f" "abcabc")
> > java.lang.ClassCastException: java.lang.String cannot be cast to
> > java.util.regex.Pattern (NO_SOURCE_FILE:0)
>
> > Is this the expected behaviour?
>
> > jan.
>
> > --
> > 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


Two convenience methods

2010-07-21 Thread Travis Hoffman
I've found two convenience methods to be of use to me in my project,
and I'm not certain where I ought to share them. So, I thought I'd
share them here, for your consideration. Sorry, I'm a bit of a n00b to
Clojure. :-)

The first I would suggest for inclusion in core.clj; it is very
similar in behavior to "some", but returns a boolean like "every?".

(defn any?
  "Returns true if (pred x) is logically true for one x in coll, else
false."
  {:added "1.3" :tag Boolean}
  [pred coll]
  (when (seq coll)
(or (pred (first coll)) (recur pred (next coll)

The second function is suggested as an addition to clojure.set. The
"disjoint?" function decides if two sets have no elements in common.
This can easily be done using:

  (not (nil? (intersection s1 s2)))

but this implementation should be more efficient (I think) and is more
readable, imho:

(defn disjoint?
  "Is set1 disjoint from set2?"
  {:added "1.3" :tag Boolean}
  [set1 set2]
  (if (<= (count set1) (count set2))
(recur set2 set1)
(not-any? (fn [item] (contains? item set1)) set2)))

Feel free to use these, or, how best should I submit these?

Cheers,
Travis

-- 
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 Map function possible bug.

2010-07-21 Thread Ruben
Thanks for your response guys.

Ruben

On Jul 21, 9:30 am, Stuart Halloway  wrote:
> Hi Ruben,
>
> What you are missing is thatmapis the wrong function to use here.Mapis lazy, 
> and combiningmapwith something side-effecty like println will lead to 
> confusion.
>
> doseq will give you what you want.
>
> Stu
>
> Stuart Halloway
> Clojure/corehttp://clojure.com
>
>
>
> > Hi all,
>
> > when I execute the following code:
>
> > (def users (ref []))
>
> > ;works
> > (defn print-users []
> >  (with-query-results res ["select id,username,password from users" ]
>
> >        (dorun
> >            (dosync (ref-set users  res )  )
> >    )
> >  )
> > )
>
> > and then execute (map#(println %) @users)  i get back this:
>
> > ({:id 1, :username rpierich, :password test}
> > {:id 2, :username ruthpierich, :password test}
> > nil {:id 3, :username ruthpierich, :password test}
> > nil nil)
>
> > when i perform a @users i get:
>
> > ({:id 1, :username "rpierich", :password "test"} {:id 2, :username
> > "ruthpierich", :password "test"} {:id 3, :username
> > "ruthpierich", :password "test"})
>
> > Is this abugwithmapor since it adds on those nils or am i missing
> > something in the call tomap?
>
> > Cheers,
> > Ruben
>
> > --
> > 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: randomizing a vector

2010-07-21 Thread Ryan Waters
I'm currently using clojure 1.1 and wasn't aware of shuffle in the
contrib libraries.

It felt like a wheel reinvention ... I should have looked harder!

Thank you.


On Wed, Jul 21, 2010 at 12:51 PM, Randy Hudson  wrote:
> Clojure 1.2 has a shuffle function. If you're using 1.1, you can just
> cop the 1.2 implementation.
>
> On Jul 21, 1:18 pm, Ryan Waters  wrote:
>> http://gist.github.com/484747
>>
>> - - -
>>
>> My sad little program has a number of issues and I would welcome
>> suggestions on any aspect of it.  I come from an imperative
>> programming background and clojure is my first experience with a
>> functional or lisp language.
>>
>> I'd like to take a list of things (really, a vector) and randomly add
>> items of that list to another list.  I chose to work with vectors
>> because clojure is efficient at adding things their ends and because I
>> can address their consistent ordering with an index.
>>
>> Issues:
>>
>> 1) Idiomatic: please point out anything that looks generally awkward
>> or otherwise less than ideal for clojure (and suggest an alternative)
>> : )  For example, in my loop I rebind symbols to themselves and have
>> received mixed advice on IRC as to whether it's appropriate to do
>> that.
>>
>> 2) Transients: For speed and because I don't care about the
>> intermediate values of the vectors, I'd like to use them.  I was able
>> to easily work with the transient vector 'random-ips' but receive an
>> error when trying to wrap the vector 'ordered-ips' in a transient:
>> "Exception in thread "main" java.lang.ClassCastException:
>> clojure.lang.PersistentVector$TransientVector cannot be cast to
>> clojure.lang.IPersistentVector (gen_ips.clj:36)"
>>
>> 3) Overall speed: it's abysmal but I don't blame Clojure.  It's either
>> because I'm Doing It Wrong or what I'm doing is simply expensive in a
>> big O notation sort of way.  I'm trying to randomly order 1.1 million
>> strings.
>>
>> 4) Clojure side-gripe: I wish it were easier to mix clojure's
>> different 'types': vectors, lazy sequences, etc.  It's probably an
>> ignorance thing on my part but, for what I know right now, I find
>> using different macros with all the different return types
>> problematic.
>>
>> - - -
>>
>> Thanks in advance to addressing one or more of these issues!
>>
>> - Ryan
>
> --
> 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: Aleph and Conjure

2010-07-21 Thread Zach Tellman
To clarify, I didn't mean gary's last snippet.  I meant this could
work with the linked Ring middleware:

(defn aleph-to-ring-handler [req]
  (respond! req (ring-handler req)))

as would the variation David's been using for his "hello world"
benchmarks:

(defn aleph-to-ring-handler [req]
  (future
(respond! req (ring-handler req)))

On Jul 21, 12:06 pm, Zach Tellman  wrote:
> On Jul 21, 11:51 am, David Nolen  wrote:
>
> > On Wed, Jul 21, 2010 at 2:42 PM, Zach Tellman  wrote:
> > > Both of those seem to be about persisting data across requests.  I
> > > apologize if I'm being dense, but how does the threading model affect
> > > how they work?
>
> > They wrap the handler, that is they expect to see the request and the
> > response. That's not possible with Aleph since Aleph uses respond!, the
> > handler will return nil. Now that fn's can have metadata seems like this
> > could be worked around pretty easily.
>
> Okay, I see.  Yes, if you try to decouple the request and response
> downstream from that middleware, it won't work.  But if they're
> decoupled upstream (which is true of every code snippet in this
> thread), it should work fine.  Clearly this is something that you have
> to pay attention to, but I don't think it's too taxing.

-- 
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: Aleph and Conjure

2010-07-21 Thread Zach Tellman
On Jul 21, 11:51 am, David Nolen  wrote:
> On Wed, Jul 21, 2010 at 2:42 PM, Zach Tellman  wrote:
> > Both of those seem to be about persisting data across requests.  I
> > apologize if I'm being dense, but how does the threading model affect
> > how they work?
>
> They wrap the handler, that is they expect to see the request and the
> response. That's not possible with Aleph since Aleph uses respond!, the
> handler will return nil. Now that fn's can have metadata seems like this
> could be worked around pretty easily.

Okay, I see.  Yes, if you try to decouple the request and response
downstream from that middleware, it won't work.  But if they're
decoupled upstream (which is true of every code snippet in this
thread), it should work fine.  Clearly this is something that you have
to pay attention to, but I don't think it's too taxing.

-- 
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: Aleph and Conjure

2010-07-21 Thread gary b
On Jul 21, 11:42 am, Zach Tellman  wrote:
> Both of those seem to be about persisting data across requests.  I
> apologize if I'm being dense, but how does the threading model affect
> how they work?

The flash and session middleware functions update the response
returned from the handler function.  The the updated response is
returned from the middleware and is eventually passed an adapter where
it is written to the network.

If the handler calls Aleph's respond! function, then these middleware
functions never get a chance to update the response.

If the middleware functions are aware of respond! function, then they
can update the response in a wrapper around the original response
function.  For example:

(handler (assoc req :respond! (fn [resp]  ((:respond! req) (do-
something resp))


-- 
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: Aleph and Conjure

2010-07-21 Thread David Nolen
On Wed, Jul 21, 2010 at 2:42 PM, Zach Tellman  wrote:

> Both of those seem to be about persisting data across requests.  I
> apologize if I'm being dense, but how does the threading model affect
> how they work?


They wrap the handler, that is they expect to see the request and the
response. That's not possible with Aleph since Aleph uses respond!, the
handler will return nil. Now that fn's can have metadata seems like this
could be worked around pretty easily.

-- 
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: Aleph and Conjure

2010-07-21 Thread Zach Tellman
Both of those seem to be about persisting data across requests.  I
apologize if I'm being dense, but how does the threading model affect
how they work?

On Jul 21, 11:28 am, gary b  wrote:
> On Jul 21, 10:40 am, Zach Tellman  wrote:
>
> > I don't think anything in the Ring utilities are thread-aware, so they're
> > all okay to use.  
>
> The flash and session middleware in Ring core are two examples where
> Ring assumes the thread per request model.
>
> http://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middle...
>
> http://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middle...

-- 
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: Why does using a dynamic binding make a function impure?

2010-07-21 Thread Daniel Werner
On 20 July 2010 11:50, Paul Richards  wrote:
> So back to my example:
>
> (def forty-two 42)
>
> (defn func [] (* forty-two forty-two))
>
> (defn other-func [] (binding [forty-two 6] (func)))
>
>
> "func" is impure, and "other-func" is pure.  It's really nothing to do
> with whether the "binding" keyword is used in the function...  I think
> I took the sentence from the book too literally.

Technically, a function that depends on impure functions cannot ever
be pure. I other-func's case it seems obvious what should happen: func
depends on forty-two, and other-func supplies a fixed value for
forty-two, so other-func will always return the same result, right?

Actually, there this assumption can bite you in several instances:
1. If func were to execute in another thread for some reason, it would
see forty-two as 42 because (binding) doesn't cross thread boundaries.

2. If func were memoized, some other part of the code could already
have called func without rebinding forty-two, or rebinding it to
completely different value. This would make func always yield the
cached value, completely ignoring any (binding) forms.

3. If func returned a lazy-seq of values, e.g. by using standard seq
functions like map, any calculations not immediately realized in
(binding)'s dynamic scope will see 42, not 6.

Re-binding Vars is a tricky topic. I haven't written a lot of
non-trivial Clojure code so far, but I've yet to come across a use
case for (binding) which doesn't suffer from these issues :-)

--
Daniel

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


Re: Implementing a protocol with using a base implementation?

2010-07-21 Thread Toni Batchelli
Hi Meikel,

This is awesome! You just did a big chunk of what I was about to try
to do :). Sorry for the late response, I've been off the grid for a
few days...

With your second proposed solution, the defrecord-with-defaults macro,
 one can achieve very good performance while keeping some of the
features that implementation inheritance provides. I'll look into your
macro more closely and see if I can make it a seamless substitute for
defmacro.

Toni.

On Sat, Jul 17, 2010 at 4:02 AM, Meikel Brandmeyer  wrote:
> Hi,
>
> one way to do that is using extend.
>
> (def defaults
>  {fn1 (fn ...)
>   fn2 (fn ...)
>   fn3 (fn ...)})
>
> (defrecord R1 [...])
> (def R1-fns
>  {fn1 (fn ...)})
>
> (defrecord R2 [...])
> (def R2-fns
>  {fn2 (fn ...)
>   fn3 (fn ...)})
>
> (extend YourProtocol
>  R1 (merge defaults R1-fns)
>  R2 (merge defaults R2-fns))
>
> Another way is the following macro:
>
> (defmacro defrecord-with-defaults
>  [record fields & protocol-default-fns]
>  (let [process-protocol
>        (fn [[protocol defaults fns]]
>          (let [defaults (when defaults
>                           (->> defaults
>                             resolve
>                             var-get
>                             (map (fn [[k f]]
>                                    (vector
>                                      k (cons (symbol (name k)) (next f)
>                             (into {})))]
>            (list* protocol
>                   (->> fns
>                     (map #(array-map (-> % first name keyword) %))
>                     (apply merge defaults)
>                     (map second)
>        split-protocols
>        (fn split-protocols
>          [p-d-fs]
>          (lazy-seq
>            (when-let [[p d & fs] (seq p-d-fs)]
>              (let [[fs next-p-d-fs] (split-with (complement symbol?) fs)]
>                (cons [p d fs] (split-protocols next-p-d-fs))]
>    `(defrecord ~record ~fields
>       ~@(mapcat process-protocol (split-protocols protocol-default-fns)
>
> Usage:
>
> (def foo-defaults
>  `{:bar (fn ([this# that#] nil))
>    :baz (fn [this# that#] nil)})
>
> (defrecord-with-defaults R [a b]
>  Foo foo-defaults
>  (bar [this that] nil)
>  Frob nil
>  (frobnicator [this] nil))
>
> Note: you have to syntax-quote the functions in the default map (as for 
> definline). And you can have only one arity per function. Here the 
> corresponding expansion:
>
> (clojure.core/defrecord FooImpl1 [a b]
>  Foo
>  (bar [this that] nil)
>  (baz [this__711__auto__ that__712__auto__] nil)
>  Frob
>  (frobnicator [this] nil))
>
> 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



-- 
Antoni Batchelli
- twitter: @tbatchelli , @disclojure
--- email: tbatche...@gmail.com
- web: tbatchelli.org , disclojure.org

-- 
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: Aleph and Conjure

2010-07-21 Thread gary b
On Jul 21, 10:40 am, Zach Tellman  wrote:
> I don't think anything in the Ring utilities are thread-aware, so they're
> all okay to use.  

The flash and session middleware in Ring core are two examples where
Ring assumes the thread per request model.

http://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/session.clj

http://github.com/mmcgrana/ring/blob/master/ring-core/src/ring/middleware/flash.clj

-- 
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: Aleph and Conjure

2010-07-21 Thread Zach Tellman
Also, I've just created a mailing list for Aleph at
http://groups.google.com/group/aleph-lib, since it seems like that
might reduce the clutter here.

On Jul 21, 10:40 am, Zach Tellman  wrote:
> I don't really understand what's being debated here.  Aleph is fully
> Ring-compliant in every way but its threading model.  I don't think
> anything in the Ring utilities are thread-aware, so they're all okay
> to use.  I'm not very familiar with Compojure, but as long as you're
> willing to make an explicit decision as to where its handler function
> is executed, I'd imagine it would work fine as well.  It doesn't make
> sense to create an "adapter" that uses a specific threading model all
> the time; the fact that you have a choice is what makes Aleph
> different from ring-netty-adapter.
>
> Also, please try to remember that Aleph was originally written to
> raise the question of how to write asynchronous network applications
> in Clojure, not to answer it.  I'm working on some ideas in a separate
> branch that I think are a pretty good approach, but I fully expect
> there will be further discussions and changes once that's done.
>
> Zach
>
> On Jul 21, 8:15 am, Marko Kocić  wrote:
>
>
>
> > On Jul 21, 4:38 pm, Janico Greifenberg  wrote:
>
> > > On Wed, Jul 21, 2010 at 4:11 PM, Marko Kocić  
> > > wrote:
> > > > Something like ring-aleph-adapter, however trivial it might be to
> > > > implement, will help in seamlessly switching existing applications to
> > > > aleph/netty.
>
> > > But why would that be useful? Maybe I'm missing something here, but I
> > > thought the idea behind aleph was to experiment with an asynchronous
> > > API. To get full ring compatibility, you would need to synchronize the
> > > response again.
>
> > Ring API seems to me minimalistic enough that everything could be made
> > to conform to it without sacrificing any functionality.
>
> > Having aleph-adapter would be useful in two ways. One is that it would
> > be
> > possible to use all  of the ring goodies and addons like compojure
> > routes
> > and stuff out of the box, while keeping being semi asynchronous.
>
> > While ring-netty-adapter and ring-jetty-adapter are blocking the
> > thread
> > during the whole execution of handler function, while the adapter will
> > allow
> > to do processing async and only require io! in the end, when actual
> > result
> > is returned. Something similar to previous example someone already
> > posted like:
>
> > (defn aleph-to-ring-handler [req]
> >   (respond! req (ring-handler req)))
>
> > ring-handler could take a long time to compute, but thread will not be
> > blocked until it is finished.
>
> > Of course, I would also like to see how it could be changed (api-wise)
> > to
> > allow sending chunks of data to the response stream when needed, and
> > not
> > only in the end of the handler.
>
> > Api for aleph and ring could look the same, while the only difference
> > wold be
> > async versus sync behaviour.
>
> > > If you want to use netty instead of jetty or tomcat etc., you could
> > > try the ring-netty-adapter
> > > (http://github.com/datskos/ring-netty-adapter).
>
> > I haven't looked at the details yet, but it seems (at a glance) like a
> > blocking
> > adapter?
>
> > > --http://jgre.org

-- 
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: Leiningen 1.2.0 released!

2010-07-21 Thread Phil Hagelberg
On Tue, Jul 20, 2010 at 2:43 PM, Daniel Gagnon  wrote:
>> Mostly we need volunteers to port the changes from the bash script to the
>> batch file and test the changes. Also I don't think the self-install feature
>> will ever work with lein.bat due to the lack of a way to download files. We
>> may switch to a powershell script to work around this limitation; I don't
>> know enough about Windows to say if that's a good idea.
>
> Bummer, I know nothing about batch files...
> As for the self install, what about writing the downloader in Java and
> invoking it from the batch file?

Sure, but by the time we can run the Java we don't need the
self-install functionality any more. =)

> Or using izPack which is the most popular next-next-finish installer for
> Java? It would be very idiomatic for Windows.

Sure, that could work. Please chime in on the Leiningen mailing list
if you'd like to help out with this once the batch file is updated.

-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: Literate Clojure - a good lead ...

2010-07-21 Thread Mark Engelberg
I'd be perfectly happy with a LaTeX-based solution, although I
understand the appeal of something more "within Clojure".

As a first approximation, literate programming needs to make it easy
to enter English text with code snippets that run.  Haskell does this
by assuming that in a file ending in .lhs (as opposed to .hs), by
default, a line is plain English text unless specifically marked as
code (instead of the other way around).

This is a good start, but Knuth's conception of literate programming
usually supports breaking code into very small hyperlinked chunks,
cross-indexing up the wazoo, and language-aware formatting and
indexing.

And honestly, I find none of this is much use without an
editor/compiler/debugger that understands this format.  So in my mind,
that would be the real challenge.  Rather than just make tools that
tangle/weave Clojure/LaTeX, I need to be able to easily edit and then
compile that to the REPL in Emacs/Enclojure/etc.  [Note to self:  Go
look at that orgmode link after writing this email]

In the rare cases where I need to write something literate without
explicit tool support, I use funnelweb.

To me, the downside of literate programming is that it makes it much
harder to refactor.  I have a vague idea that the holy grail of
literate programming would be to have two editing windows side by
side: one shows you where you are in the tangled code and one shows
you where you are in the weaved book.  You can put the focus on the
code-centric view or the literate-centric view, and as you move the
cursor in one window, the view in the other window jumps around.  So
it would be equally easy to edit in either view.

I've heard that Leo is the existing tool that comes closest to this
idea, although the one time I tried it, I felt like it was only giving
me the ability to look at my code in super-small chunks, and I
couldn't figure out how to get the "big picture" view where I see
everything on one page.

In any case, any of these tools, even the most basic, if integrated
with the rest of the Clojure edit/compile/eval/debug process in some
editor (I've been primarily using Emacs but am gradually starting to
prefer Enclojure), would be something I would likely use.

-- 
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: randomizing a vector

2010-07-21 Thread Randy Hudson
Clojure 1.2 has a shuffle function. If you're using 1.1, you can just
cop the 1.2 implementation.

On Jul 21, 1:18 pm, Ryan Waters  wrote:
> http://gist.github.com/484747
>
> - - -
>
> My sad little program has a number of issues and I would welcome
> suggestions on any aspect of it.  I come from an imperative
> programming background and clojure is my first experience with a
> functional or lisp language.
>
> I'd like to take a list of things (really, a vector) and randomly add
> items of that list to another list.  I chose to work with vectors
> because clojure is efficient at adding things their ends and because I
> can address their consistent ordering with an index.
>
> Issues:
>
> 1) Idiomatic: please point out anything that looks generally awkward
> or otherwise less than ideal for clojure (and suggest an alternative)
> : )  For example, in my loop I rebind symbols to themselves and have
> received mixed advice on IRC as to whether it's appropriate to do
> that.
>
> 2) Transients: For speed and because I don't care about the
> intermediate values of the vectors, I'd like to use them.  I was able
> to easily work with the transient vector 'random-ips' but receive an
> error when trying to wrap the vector 'ordered-ips' in a transient:
> "Exception in thread "main" java.lang.ClassCastException:
> clojure.lang.PersistentVector$TransientVector cannot be cast to
> clojure.lang.IPersistentVector (gen_ips.clj:36)"
>
> 3) Overall speed: it's abysmal but I don't blame Clojure.  It's either
> because I'm Doing It Wrong or what I'm doing is simply expensive in a
> big O notation sort of way.  I'm trying to randomly order 1.1 million
> strings.
>
> 4) Clojure side-gripe: I wish it were easier to mix clojure's
> different 'types': vectors, lazy sequences, etc.  It's probably an
> ignorance thing on my part but, for what I know right now, I find
> using different macros with all the different return types
> problematic.
>
> - - -
>
> Thanks in advance to addressing one or more of these issues!
>
> - Ryan

-- 
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: randomizing a vector

2010-07-21 Thread Michael Gardner
On Jul 21, 2010, at 12:44 PM, Michał Marczyk wrote:

> The biggest problem with the code is that it reconstructs the entire
> `ordered-ips` vector minus the last entry picked at each iteration. It
> would be simpler and *much* more performant to do
> 
> (shuffle ordered-ips)
> 
> Also note that Clojure 1.2 provides an `rand-nth` function for doing
> 
> (let [i (count xs)] (get xs (rand-int i)))

I believe shuffle is only in clojure.core as of 1.2. Before that, you'd find it 
in clojure.contrib.seq.

-- 
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: randomizing a vector

2010-07-21 Thread Michał Marczyk
The biggest problem with the code is that it reconstructs the entire
`ordered-ips` vector minus the last entry picked at each iteration. It
would be simpler and *much* more performant to do

(shuffle ordered-ips)

Also note that Clojure 1.2 provides an `rand-nth` function for doing

(let [i (count xs)] (get xs (rand-int i)))

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: Aleph and Conjure

2010-07-21 Thread Zach Tellman
I don't really understand what's being debated here.  Aleph is fully
Ring-compliant in every way but its threading model.  I don't think
anything in the Ring utilities are thread-aware, so they're all okay
to use.  I'm not very familiar with Compojure, but as long as you're
willing to make an explicit decision as to where its handler function
is executed, I'd imagine it would work fine as well.  It doesn't make
sense to create an "adapter" that uses a specific threading model all
the time; the fact that you have a choice is what makes Aleph
different from ring-netty-adapter.

Also, please try to remember that Aleph was originally written to
raise the question of how to write asynchronous network applications
in Clojure, not to answer it.  I'm working on some ideas in a separate
branch that I think are a pretty good approach, but I fully expect
there will be further discussions and changes once that's done.

Zach

On Jul 21, 8:15 am, Marko Kocić  wrote:
> On Jul 21, 4:38 pm, Janico Greifenberg  wrote:
>
> > On Wed, Jul 21, 2010 at 4:11 PM, Marko Kocić  wrote:
> > > Something like ring-aleph-adapter, however trivial it might be to
> > > implement, will help in seamlessly switching existing applications to
> > > aleph/netty.
>
> > But why would that be useful? Maybe I'm missing something here, but I
> > thought the idea behind aleph was to experiment with an asynchronous
> > API. To get full ring compatibility, you would need to synchronize the
> > response again.
>
> Ring API seems to me minimalistic enough that everything could be made
> to conform to it without sacrificing any functionality.
>
> Having aleph-adapter would be useful in two ways. One is that it would
> be
> possible to use all  of the ring goodies and addons like compojure
> routes
> and stuff out of the box, while keeping being semi asynchronous.
>
> While ring-netty-adapter and ring-jetty-adapter are blocking the
> thread
> during the whole execution of handler function, while the adapter will
> allow
> to do processing async and only require io! in the end, when actual
> result
> is returned. Something similar to previous example someone already
> posted like:
>
> (defn aleph-to-ring-handler [req]
>   (respond! req (ring-handler req)))
>
> ring-handler could take a long time to compute, but thread will not be
> blocked until it is finished.
>
> Of course, I would also like to see how it could be changed (api-wise)
> to
> allow sending chunks of data to the response stream when needed, and
> not
> only in the end of the handler.
>
> Api for aleph and ring could look the same, while the only difference
> wold be
> async versus sync behaviour.
>
> > If you want to use netty instead of jetty or tomcat etc., you could
> > try the ring-netty-adapter
> > (http://github.com/datskos/ring-netty-adapter).
>
> I haven't looked at the details yet, but it seems (at a glance) like a
> blocking
> adapter?
>
>
>
> > --http://jgre.org

-- 
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: Literate Clojure - a good lead ...

2010-07-21 Thread Tim Daly



Antony Blakey wrote:

On 21/07/2010, at 10:29 PM, Tim Daly wrote:

  

The PLT Scheme mechanism mentioned above is a good idea
but it has a niche quality to it.

Latex is an industry standard publication language. Many
books and technical papers, especially in mathematics,
use it. Some conferences require it. All publishers support
it and it is widely used.



Going from the PLT form to Latex is possible. Why use Latex when you can use 
Clojure?


The essence of literate programming is writing for humans.
My main example is "Lisp In Small Pieces" which is a full lisp with
a compiler written as a readable book. So the primary focus is the
text, not the code. "Clojure in Small Pieces" would be fantastic.

It is always possible to go from a "program documentation" language
to latex since latex is just a document markup language. The problem is
the mindset that this is "program documentation" rather than a book
for humans to read, cover to cover. Wouldn't it be nice to read a book
that, oh-by-the-way, has the actual source code not only explained but
motivated?

I've been doing literate programming in Axiom for about 10 years now.
I've looked at a couple dozen possible tools and techniques ranging from
"use good variable names makes the code self-documenting" to
"embed the code in a special purpose tool". Programmers tend to like
things that "work from the code and comments" so they don't have to
write actual prose (e.g. javadoc, doxygen, etc). However, writing for
humans requires a completely different mindset, at least in my experience.


The essence of the PLT model is the language integration that allows symbol 
resolution by reusing the language mechanism for the documentation.
  

"Language integration" is a false goal. It is technically possible to
call functions in any language from latex but unnecessary in general.
It is technically possible to generate latex from any language.

Symbol resolution is also rarely an issue in literate programs.
Your prose is intended to explain "why" a code chunks exists,
not "how" a code chunk works. If you explain the problem you
are trying to solve and the issues of various approaches you considered
then I can usually understand the solution.

Axiom has all of the function and variable definitions and uses
cross-referenced in the index. Making these references hyperlink
in the generated pdf is trivial. Again, the problem is not a question
of technology as in the PLT Scheme approach but one of mindset.

Choosing the right approach matters. It is technically possible to
write clojure code in Microsoft word but utterly painful since MSWord
does not have a programming focus. It is possible to write a book in
PLT Scheme but painful for the same reason.

If your intention is to write a literate program, which as Knuth defined it,
to be a piece of literature, use a tool designed for literature.

I want to see a chapter in a "Clojure in Small Pieces" that explains WHY
Rich chose his data structures, why immutability is important, then why
he chose to use 32-bit wide trees, THEN show me the code. In essence
I want what Rich does not currently write, which is the agony of choice,
the ecstasy of insight, and the tragedy of implementation details. Make
me weep at the beauty of the chosen solution. Literature!

Thus I advocate the primacy of latex over that of the implementation
language magic.

Tim Daly


P.S. The clojure team needs a job opening for "Senior Editor" :-)

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


randomizing a vector

2010-07-21 Thread Ryan Waters
http://gist.github.com/484747

- - -

My sad little program has a number of issues and I would welcome
suggestions on any aspect of it.  I come from an imperative
programming background and clojure is my first experience with a
functional or lisp language.

I'd like to take a list of things (really, a vector) and randomly add
items of that list to another list.  I chose to work with vectors
because clojure is efficient at adding things their ends and because I
can address their consistent ordering with an index.

Issues:

1) Idiomatic: please point out anything that looks generally awkward
or otherwise less than ideal for clojure (and suggest an alternative)
: )  For example, in my loop I rebind symbols to themselves and have
received mixed advice on IRC as to whether it's appropriate to do
that.

2) Transients: For speed and because I don't care about the
intermediate values of the vectors, I'd like to use them.  I was able
to easily work with the transient vector 'random-ips' but receive an
error when trying to wrap the vector 'ordered-ips' in a transient:
"Exception in thread "main" java.lang.ClassCastException:
clojure.lang.PersistentVector$TransientVector cannot be cast to
clojure.lang.IPersistentVector (gen_ips.clj:36)"

3) Overall speed: it's abysmal but I don't blame Clojure.  It's either
because I'm Doing It Wrong or what I'm doing is simply expensive in a
big O notation sort of way.  I'm trying to randomly order 1.1 million
strings.

4) Clojure side-gripe: I wish it were easier to mix clojure's
different 'types': vectors, lazy sequences, etc.  It's probably an
ignorance thing on my part but, for what I know right now, I find
using different macros with all the different return types
problematic.

- - -

Thanks in advance to addressing one or more of these issues!

- Ryan

-- 
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: Aleph and Conjure

2010-07-21 Thread Marko Kocić


On Jul 21, 4:38 pm, Janico Greifenberg  wrote:
> On Wed, Jul 21, 2010 at 4:11 PM, Marko Kocić  wrote:
> > Something like ring-aleph-adapter, however trivial it might be to
> > implement, will help in seamlessly switching existing applications to
> > aleph/netty.
>
> But why would that be useful? Maybe I'm missing something here, but I
> thought the idea behind aleph was to experiment with an asynchronous
> API. To get full ring compatibility, you would need to synchronize the
> response again.

Ring API seems to me minimalistic enough that everything could be made
to conform to it without sacrificing any functionality.

Having aleph-adapter would be useful in two ways. One is that it would
be
possible to use all  of the ring goodies and addons like compojure
routes
and stuff out of the box, while keeping being semi asynchronous.

While ring-netty-adapter and ring-jetty-adapter are blocking the
thread
during the whole execution of handler function, while the adapter will
allow
to do processing async and only require io! in the end, when actual
result
is returned. Something similar to previous example someone already
posted like:

(defn aleph-to-ring-handler [req]
  (respond! req (ring-handler req)))

ring-handler could take a long time to compute, but thread will not be
blocked until it is finished.

Of course, I would also like to see how it could be changed (api-wise)
to
allow sending chunks of data to the response stream when needed, and
not
only in the end of the handler.

Api for aleph and ring could look the same, while the only difference
wold be
async versus sync behaviour.

> If you want to use netty instead of jetty or tomcat etc., you could
> try the ring-netty-adapter
> (http://github.com/datskos/ring-netty-adapter).

I haven't looked at the details yet, but it seems (at a glance) like a
blocking
adapter?

> --http://jgre.org

-- 
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: Installing emacs using leiningen on Windows Vista

2010-07-21 Thread leonelag
> . And cygwin uses ':' as a CLASSPATH
> separator, so correct these too at the bottom of the script.

Hm, Classpath is tricky to set up correctly in cygwin.

The JVM executable in Windows expects your classpath to be separated
with a semicolon, so even if you're on cygwin, you should use that.


On Jul 20, 5:47 am, eGlyph  wrote:
> > The above is the content of my class path. Is there anything wrong?
>
> It seems your clojure.jar isn't in the classpath. It's tweaked in the
> first lines of the script. And cygwin uses ':' as a CLASSPATH
> separator, so correct these too at the bottom of the script.

-- 
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: Slime, debug-repl & clojure debugging toolkit

2010-07-21 Thread George Jahad
Karl, I use the debug-repl all the time and don't see errors like
this.

You can use the standard debug-repl from with slime's *inferior-lisp*
buffer.  Try it from there and see what you get.  If that fails, try
it from outside of emacs entirely in a regular command line repl and
see if it behaves differently there.

Let me know how it goes.

Thanks,
g

On Jul 21, 7:02 am, Ramakrishnan Muthukrishnan 
wrote:
> On Wed, Jul 21, 2010 at 6:04 PM, Krukow  wrote:
> >  0: com.trifork.intrafoo.clj.extract_contacts
> > $extract_all.invoke(NO_SOURCE_FILE:1)
> >      Locals:
> >        pref = /Users/krukow/workspaces/trifork/intrafoo_clj/
> > contactdata/
> >        cli = org.apache.commons.httpclient.httpcli...@6078b973
> >        cs = ["411719" "413255" "413279"
>
> > In the repl I can hit ENTER:
>
> I don't seem to get this problem.
>
> user> (defn foobar []
>         (let [a 10
>               b 20]
>           (swank.core/break)
>           (* a b)))
> #'user/foobar
> user>  (foobar)
>
> (I switch back to slime-repl and hit enter, this drops me into the repl.
> nil
> user> a
> 10
> user> b
> 20
>
> --
>   Ramakrishnan

-- 
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: Aleph and Conjure

2010-07-21 Thread Janico Greifenberg
On Wed, Jul 21, 2010 at 4:11 PM, Marko Kocić  wrote:
> Something like ring-aleph-adapter, however trivial it might be to
> implement, will help in seamlessly switching existing applications to
> aleph/netty.

But why would that be useful? Maybe I'm missing something here, but I
thought the idea behind aleph was to experiment with an asynchronous
API. To get full ring compatibility, you would need to synchronize the
response again.

If you want to use netty instead of jetty or tomcat etc., you could
try the ring-netty-adapter
(http://github.com/datskos/ring-netty-adapter).

-- 
http://jgre.org

-- 
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: alter atom while iterating

2010-07-21 Thread Meikel Brandmeyer
Hi,

> user=> (let [rs2 (r 2 true)
>              rs3 (r 3 true)]
>          (for [r2 rs2
>                r3 rs3]
>            [r2 r3]))

Note: this of course holds the head of the sequences. If this is not
desired, you will have to bite the bullet and pay the cost of multiple
calls to the seq generating functions.

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: Aleph and Conjure

2010-07-21 Thread gary b
On Jul 21, 7:11 am, Marko Kocić  wrote:
> Something like ring-aleph-adapter, however trivial it might be to
> implement, will help in seamlessly switching existing applications to
> aleph/netty.

There is a Ring adapter for Netty: http://github.com/datskos/ring-netty-adapter.

-- 
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: alter atom while iterating

2010-07-21 Thread Meikel Brandmeyer
Hi,

On Jul 21, 4:00 pm, ka  wrote:

> 1:13 user=> (def k (for [a (r 2 true)] a) )
> Called (r 2)
> #'user/k
>
> Why do you think for doesn't have 'lazy-for' semantics already?

Because then the above would look like:

user=> (def l (hypothetical-lazy-for [a (r 2 true)] a))
#'user/l
user=>

Compare:

user=> (def k (concat (r 2 true) (r 3 true)))
Called (r 2)
Called (r 3)
#'user/k

vs.

user=> (def k (lazy-cat (r 2 true) (r 3 true)))
#'user/k

> Also this thread has given me the insight that 'for' is not meant for
> Cartesian products of two seqs (contrary to what I thought) -

You are right in so far as for is not meant for cartesian products
exclusively. But a cartesian product is one case, which can be covered
by for. But for is much more general than that.

Try this:

user=> (let [rs2 (r 2 true)
 rs3 (r 3 true)]
 (for [r2 rs2
   r3 rs3]
   [r2 r3]))
Called (r 2)
Called (r 3)
Realizing elem 0
Realizing elem 0
Realizing elem 1
Realizing elem 2
Realizing elem 1
([:a :a] [:a :a] [:a :a] [:a :a] [:a :a] [:a :a])

If your input sequences are independent of each other, and they come
from a (possibly expensive) function call, use let in the above
fashion.

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: Aleph and Conjure

2010-07-21 Thread Marko Kocić
> Clojure, because of the JVM, doesn't tie your hands this way. If you want to
> do everything evented go ahead. Do everything with threads? Go ahead. Want
> to mix the two designs together like Aleph? Sure. All while not losing the
> elegant brevity of a Node.js app.

Something like ring-aleph-adapter, however trivial it might be to
implement, will help in seamlessly switching existing applications to
aleph/netty.

> I like JavaScript, and I like Node.js. But I think Clojure opens up some new
> avenues to explore when building web applications.

-- 
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: Slime, debug-repl & clojure debugging toolkit

2010-07-21 Thread Ramakrishnan Muthukrishnan
On Wed, Jul 21, 2010 at 6:04 PM, Krukow  wrote:
>  0: com.trifork.intrafoo.clj.extract_contacts
> $extract_all.invoke(NO_SOURCE_FILE:1)
>      Locals:
>        pref = /Users/krukow/workspaces/trifork/intrafoo_clj/
> contactdata/
>        cli = org.apache.commons.httpclient.httpcli...@6078b973
>        cs = ["411719" "413255" "413279"
>
> In the repl I can hit ENTER:

I don't seem to get this problem.

user> (defn foobar []
(let [a 10
  b 20]
  (swank.core/break)
  (* a b)))
#'user/foobar
user>  (foobar)

(I switch back to slime-repl and hit enter, this drops me into the repl.
nil
user> a
10
user> b
20

-- 
  Ramakrishnan

-- 
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: alter atom while iterating

2010-07-21 Thread ka
@Meikal,

Hi, I get what you mean. Consider the following func -

(defn r
  [n lazy?]
  (.println System/out (str "Called (r " n ")"))
  (let [r-lazy-seq (fn r-lazy-seq [i n]
 (lazy-seq
   (when (< i n)
 (.println System/out (str "Realizing elem "
i))
 (cons :a (r-lazy-seq (inc i) n)
zzz (r-lazy-seq 0 n)]
(if lazy? zzz (doall zzz


1:13 user=> (def k (for [a (r 2 true)] a) )
Called (r 2)
#'user/k

1:14 user=> (def k (for [a (r 2 false)] a) )
Called (r 2)
Realizing elem 0
Realizing elem 1
#'user/k

Why do you think for doesn't have 'lazy-for' semantics already?

Also this thread has given me the insight that 'for' is not meant for
Cartesian products of two seqs (contrary to what I thought) -

1:40 user=> (use '[clojure.contrib.combinatorics])
nil
1:41 user=> (cartesian-product (r 2 true) (r 3 true))
Called (r 2)
Called (r 3)
Realizing elem 0
Realizing elem 0
Realizing elem 1
Realizing elem 2
Realizing elem 1
((:a :a) (:a :a) (:a :a) (:a :a) (:a :a) (:a :a))

1:42 user=> (for [a (r 2 true) b (r 3 true)] [a b])
Called (r 2)
Realizing elem 0
Called (r 3)
Realizing elem 0
Realizing elem 1
Realizing elem 2
Realizing elem 1
Called (r 3)
Realizing elem 0
Realizing elem 1
Realizing elem 2
([:a :a] [:a :a] [:a :a] [:a :a] [:a :a] [:a :a])

- Thanks

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


Re: Literate Clojure - a good lead ...

2010-07-21 Thread Antony Blakey

On 21/07/2010, at 10:29 PM, Tim Daly wrote:

> The PLT Scheme mechanism mentioned above is a good idea
> but it has a niche quality to it.
> 
> Latex is an industry standard publication language. Many
> books and technical papers, especially in mathematics,
> use it. Some conferences require it. All publishers support
> it and it is widely used.

Going from the PLT form to Latex is possible. Why use Latex when you can use 
Clojure?

The essence of the PLT model is the language integration that allows symbol 
resolution by reusing the language mechanism for the documentation.

Antony Blakey
-
CTO, Linkuistics Pty Ltd
Ph: 0438 840 787

The fact that an opinion has been widely held is no evidence whatever that it 
is not utterly absurd.
  -- Bertrand Russell


-- 
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: IDE agnostic question on user assistance (emacs/vimClojure users help appreciated too !)

2010-07-21 Thread Meikel Brandmeyer
Hi,

On Jul 21, 1:35 pm, Jeff Rose  wrote:

> Really, there isn't a way to start processes from VIM?  How about just
> opening a temporary buffer for the output of the nailgun server, and
> then start it with a bang!?

I was a but unclear on what I mean with background: I can start
processes from Vim. That's not the problem. But then Vim waits for
them to complete. And no. Adding & doesn't help, because it doesn't
work in Windows. So you fire up your server and have a waiting Vim
which cannot be used anymore. Ah, the attainments of single-threaded
applications. There is certainly no race condition. Bleh. :(

If this was not the case I could offer such a starter command.
Although I doubt it has much value, because Vim's started from the
graphical user interface don't know your project directory. So
starting at plugin load would not work. So you need another command
(maybe key bindings) to start the server after changing the vim cwd
(or providing it as an argument). Complexity creeps in for a non-
issue.

> Having it start automatically would be very nice because now you
> have to have multiple terminals open and run multiple commands
> to just pop open a clojure file with a repl.

This is a gross exaggeration. You can just as well send the process
into the background with shell job control. Then you don't block a the
terminal and still have control over the server process. Which you
don't have with the fire-and-forgot processes started from Vim. And
even if you don't use the job control, you can minimise the window.
This terminal is certainly not an issue.

You should be more concerned about the integration of your VCS system.
There you run several commands more than once all during your
development work. Not only one in the morning.

Believe me: This is a non-issue. I will include such functionality
only if someone provides me a working, portable patch. Otherwise
things stay as they are.

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: Clojure Map function possible bug.

2010-07-21 Thread Stuart Halloway
Hi Ruben,

What you are missing is that map is the wrong function to use here. Map is 
lazy, and combining map with something side-effecty like println will lead to 
confusion.

doseq will give you what you want.

Stu

Stuart Halloway
Clojure/core
http://clojure.com

> Hi all,
> 
> when I execute the following code:
> 
> (def users (ref []))
> 
> ;works
> (defn print-users []
>  (with-query-results res ["select id,username,password from users" ]
> 
>(dorun
>   (dosync (ref-set users  res )  )
>   )
>  )
> )
> 
> 
> and then execute (map #(println %) @users)  i get back this:
> 
> ({:id 1, :username rpierich, :password test}
> {:id 2, :username ruthpierich, :password test}
> nil {:id 3, :username ruthpierich, :password test}
> nil nil)
> 
> when i perform a @users i get:
> 
> ({:id 1, :username "rpierich", :password "test"} {:id 2, :username
> "ruthpierich", :password "test"} {:id 3, :username
> "ruthpierich", :password "test"})
> 
> 
> Is this a bug with map or since it adds on those nils or am i missing
> something in the call to map?
> 
> Cheers,
> Ruben
> 
> -- 
> 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-contrib replace-first-str

2010-07-21 Thread Stuart Halloway
Hi Jan,

These functions in contrib are deprecated (and will be marked so as soon as we 
have time to make a pass through contrib).

Please use the functions in clojure.string. 

Stuart Halloway
Clojure/core
http://clojure.com

> Hi,
> 
> I'm using replace-str and replace-first-str (from clojure-contrib
> 1.2.0-beta1), and it seems that these do not have the same
> functionality contrary to their descriptions.The following code will
> work with the regular (replace-str), but (replace-first-str) returns
> an error:
> 
> user=> (replace-str "a" "f" "abcabc")
> "fbcfbc"
> user=> (replace-first-str "a" "f" "abcabc")
> java.lang.ClassCastException: java.lang.String cannot be cast to
> java.util.regex.Pattern (NO_SOURCE_FILE:0)
> 
> Is this the expected behaviour?
> 
> jan.
> 
> -- 
> 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: Aleph and Conjure

2010-07-21 Thread David Nolen
On Tue, Jul 20, 2010 at 10:38 PM, Victor S  wrote:

> Thank you all for the input, it has made me understand some new
> things.
>
> I find node.js push for NIO as the de-facto mode of existence for web
> apps interesting, and I was trying to have my cake and eat it too.
> JS programming just doesn't look all that appealing.
>
> - V
>

Node.js's push for NIO is because it's single threaded (because JavaScript
is single threaded). If everything wasn't NIO, Node.js would perform
terribly. In fact it's not recommended for users of Node.js to do anything
CPU heavy inside a Node.js process as that will destroy overall server perf.
You have to offload that work to a WebWorker (and setup some callbacks). If
you're trying to build a Node.js app that takes advantage of multiple cores
you need to create as many Node.js processes as you have cores.
Communicating across processes for even something as simple as a counter
will incur more callback complexity as well as overhead (or you can avoid
IPC and use an in-memory store like MongoDB, and just pay the overhead of
communicating to the DB).

So while I find Node.js intriguing for simple projects, I'm looking forward
to seeing how that community builds around these issues in larger software
endeavors.

Clojure, because of the JVM, doesn't tie your hands this way. If you want to
do everything evented go ahead. Do everything with threads? Go ahead. Want
to mix the two designs together like Aleph? Sure. All while not losing the
elegant brevity of a Node.js app.

I like JavaScript, and I like Node.js. But I think Clojure opens up some new
avenues to explore when building web applications.

-- 
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: Literate Clojure - a good lead ...

2010-07-21 Thread Tim Daly

The PLT Scheme mechanism mentioned above is a good idea
but it has a niche quality to it.

Latex is an industry standard publication language. Many
books and technical papers, especially in mathematics,
use it. Some conferences require it. All publishers support
it and it is widely used.

Traditional literate programming uses two functions
 weave foo -- extract the latex document from foo
tangle foo -- extract the source code from foo

The weave function looks for special markers in the source
code. In "noweb" it looks for <>= to mark the
definition and <> to mark the use. It turns out
that it is trivial to write latex macros to set these
boundaries, e.g.

\begin{chunk}{any string}
\end{chunk}

marks the definition of code and

\thechunk{any string}

marks the use of code.

Using the above macros you no longer need the 'weave'
function.

So what about tangle? Well, the tangle function just looks
for the code chunk definitions and stores them in a hash
table indexed by "any string". The code is extracted from
the hash table when requested by 'thechunk' markers. So it
is trivial to write a lisp function TANGLE to scan 'foo'
and output the source.

Thus you can write straight latex files, surround your code
with standard latex syntax, and run a trivial lisp function
to extract your code. Latex file markup is very similar to
html markup but wildly more powerful.

Bingo, you have literate programming with no external tools at all.

I can supply the latex macros and the (common)-lisp code to
implement the above techniques.

Tim Daly

Tassilo Horn wrote:

On Wednesday 21 July 2010 06:32:02 Mark Engelberg wrote:

Hi Mark,

  

I would definitely welcome a literate Clojure tool.



You might want to have a look at Emacs' org-mode [1].  It has a facility
called Babel [2] that allows for literate programming in all the
languages listed at [3], Clojure being one of them, and support for new
languages is being added frequently.

Currently it is moved from the contribution directory to the org core,
and the documentation is being updated or written at all.

Bye,
Tassilo
__
[1] http://orgmode.org/
[2] 
http://orgmode.org/manual/Working-With-Source-Code.html#Working-With-Source-Code
[3] http://orgmode.org/manual/Languages.html#Languages

  


--
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 Map function possible bug.

2010-07-21 Thread Laurent PETIT
2010/7/21 Ruben 

> Hi all,
>
> when I execute the following code:
>
> (def users (ref []))
>
> ;works
> (defn print-users []
>  (with-query-results res ["select id,username,password from users" ]
>
>(dorun
>(dosync (ref-set users  res )  )
>)
>  )
> )
>
>
> and then execute (map #(println %) @users)  i get back this:
>
> ({:id 1, :username rpierich, :password test}
> {:id 2, :username ruthpierich, :password test}
> nil {:id 3, :username ruthpierich, :password test}
> nil nil)
>
> when i perform a @users i get:
>
> ({:id 1, :username "rpierich", :password "test"} {:id 2, :username
> "ruthpierich", :password "test"} {:id 3, :username
> "ruthpierich", :password "test"})
>
>
> Is this a bug with map or since it adds on those nils or am i missing
> something in the call to map?
>
>
C'mon, did you really thing that such a bug could be there in map and seen
by nobody ? :-) There's more than one or two persons that use clojure, these
days :-D

The nils are the values of the map, the *return* values from the three
consecutive calls to println

-- 
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: Slime, debug-repl & clojure debugging toolkit

2010-07-21 Thread Krukow
On Jul 21, 8:47 am, Ramakrishnan Muthukrishnan 
wrote:
> On Wed, Jul 21, 2010 at 11:52 AM, Krukow  wrote:
>
> > I am interested in getting the combination of Emacs+slime+swank-
> > clojure, alex-and-georges.debug-repl and clojure debugging toolkit to
> > work together.
>
> debug-repl is kind of integrated already into swank by Hugo Duncan.
>
> > user> (let [c 1
> >        d 2]
> >    (defn a [b c]
> >      (debug-repl)
> >      d))
> >  (a "foo" "bar")
> > dr-1-1001 => 2
> > user>
>
> Just put (swank.core/break) instead of (debug-repl)
>
> 
>
> --
>   Ramakrishnan

Thanks. That works :)

However, I did find a bug with that.

It seems to require that print-dup is defined on all locals.

For example, consider:

(defn extract-all []
  (let [cs (parse/get-contactids)
cli (:client (get-client {:username "kkr" :password "hidden"}))
pref "/Users/krukow/workspaces/trifork/intrafoo_clj/contactdata/"]
(println "storing...")
(swank.core/break)
(store-all cs cli pref)))

Now I run:
com.trifork.intrafoo.clj.extract-contacts> (extract-all)
storing...

and I get:

  0: com.trifork.intrafoo.clj.extract_contacts
$extract_all.invoke(NO_SOURCE_FILE:1)
  Locals:
pref = /Users/krukow/workspaces/trifork/intrafoo_clj/
contactdata/
cli = org.apache.commons.httpclient.httpcli...@6078b973
cs = ["411719" "413255" "413279"

In the repl I can hit ENTER:

nil
com.trifork.intrafoo.clj.extract-contacts>

Now typing pref gives an error:

Can't embed object in code, maybe print-dup not defined:
org.apache.commons.httpclient.httpcli...@6078b973
  [Thrown class java.lang.RuntimeException]

Restarts:
 0: [QUIT] Quit to the SLIME top level
 1: [ABORT] ABORT to SLIME level 0

Backtrace:
  0: clojure.lang.Compiler$ObjExpr.emitValue(Compiler.java:3871)
  1: clojure.lang.Compiler$ObjExpr.emitConstants(Compiler.java:3909)
  2: clojure.lang.Compiler$ObjExpr.compile(Compiler.java:3450)

Have you encountered something like this?

/Karl

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


Clojure Map function possible bug.

2010-07-21 Thread Ruben
Hi all,

when I execute the following code:

(def users (ref []))

;works
(defn print-users []
  (with-query-results res ["select id,username,password from users" ]

(dorun
(dosync (ref-set users  res )  )
)
  )
)


and then execute (map #(println %) @users)  i get back this:

({:id 1, :username rpierich, :password test}
{:id 2, :username ruthpierich, :password test}
nil {:id 3, :username ruthpierich, :password test}
nil nil)

when i perform a @users i get:

({:id 1, :username "rpierich", :password "test"} {:id 2, :username
"ruthpierich", :password "test"} {:id 3, :username
"ruthpierich", :password "test"})


Is this a bug with map or since it adds on those nils or am i missing
something in the call to map?

Cheers,
Ruben

-- 
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: Complex type in clojure

2010-07-21 Thread Travis Hoffman
I'm still working on it. I was waiting for 1.2 to branch, and to for
some other changes to the basic types to happen. Really, I just need a
little free time and a kick-in-the-pants!

I'll try to get it done this week.

-Travis

On Jul 20, 11:09 am, Mike Benfield  wrote:
> The lack of complex numbers is keeping me on the fence about Clojure.
> I could (and partially have) implement them in Clojure itself, but
> this is not as satisfying as having them built in with reader syntax
> and so on. I don't have the will right now to learn enough about
> Clojure internals and how to contribute to do that.
>
> It's quite strange to me that after 15 years and with all the gunk in
> Java's libraries, Java doesn't come with complex numbers.
>
> Anyway, I just wondered if anyone is still working on this?
>
> Mike

-- 
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: Aleph and Conjure

2010-07-21 Thread Victor S
Thank you all for the input, it has made me understand some new
things.

I find node.js push for NIO as the de-facto mode of existence for web
apps interesting, and I was trying to have my cake and eat it too.
JS programming just doesn't look all that appealing.

- V

On Jul 20, 1:46 pm, Peter Schuller 
wrote:
> > If a web app does have a large number of concurrent requests, then you
> > need a model where requests share threads. A full blown event based
> > programming model is not required for thread sharing.
>
> Of course you can mix asynch and threaded at your leasure, with
> appropriate interfaces in between; but it still boils down to limiting
> the thread-wise concurrency and relying on evented I/O for the bits
> that require that particular form of scalability.
>
> Don't get me wrong, I really dislike writing callback based asynch I/O
> code, but since the OP specifically asked for a comparison with
> node.js it's relevant to point out that no, clojure doesn't inherently
> get you massive concurrency even if you can most definitely do
> threading/asynch mixing with clojure like with most languages.
>
> --
> / Peter Schuller

-- 
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: Complex type in clojure

2010-07-21 Thread Travis Hoffman
I'm still working on it. I've been waiting for the 1.2 release to
branch, and also for the other work on the basic types to settle down.
Also, I need a little free time. I'll try to get back to it this week.

-Travis

On Jul 20, 11:09 am, Mike Benfield  wrote:
> The lack of complex numbers is keeping me on the fence about Clojure.
> I could (and partially have) implement them in Clojure itself, but
> this is not as satisfying as having them built in with reader syntax
> and so on. I don't have the will right now to learn enough about
> Clojure internals and how to contribute to do that.
>
> It's quite strange to me that after 15 years and with all the gunk in
> Java's libraries, Java doesn't come with complex numbers.
>
> Anyway, I just wondered if anyone is still working on this?
>
> Mike

-- 
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: Leiningen 1.2.0 released!

2010-07-21 Thread Daniel Gagnon
On Tue, Jul 20, 2010 at 9:51 AM, Phil Hagelberg  wrote:

> On Mon, Jul 19, 2010 at 3:00 PM, Daniel Gagnon 
> wrote:
> > By the way, what's left to do for the Windows support to stop being
> > experimental?
>
> Mostly we need volunteers to port the changes from the bash script to the
> batch file and test the changes. Also I don't think the self-install feature
> will ever work with lein.bat due to the lack of a way to download files. We
> may switch to a powershell script to work around this limitation; I don't
> know enough about Windows to say if that's a good idea.
>
>
>
Bummer, I know nothing about batch files...

As for the self install, what about writing the downloader in Java and
invoking it from the batch file?

Or using izPack which is the most popular next-next-finish installer for
Java? It would be very idiomatic for Windows.

-- 
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: IDE agnostic question on user assistance (emacs/vimClojure users help appreciated too !)

2010-07-21 Thread Jeff Rose
On Jul 19, 8:19 pm, Meikel Brandmeyer  wrote:

> Starting the server is up to the user. Rule 1: Vim is not an IDE. There is a 
> plethora of tools for handling classpaths questions. I personally use gradle; 
> before that I used simple shell scripts with project relative CLASSPATH and 
> that's it. ant+ivy, maven, leiningen, … all will they do a sufficient job. 
> Vim is an editor. It has no business with Java classpaths. (For eclipse this 
> is different: eclipse is expected to handle the classpath, no?) Besides that, 
> you cannot portable start a background process from inside vim. (At least I'm 
> not aware of how to do that)

Really, there isn't a way to start processes from VIM?  How about just
opening a temporary buffer for the output of the nailgun server, and
then start it with a bang!?

How about offering a variable that we can set in our .vimrc files with
a command to run on plugin load?  That way I can start with "lein
nailgun", you gravy, shellscripts, or whatever.  Having it start
automatically would be very nice because now you have to have multiple
terminals open and run multiple commands to just pop open a clojure
file with a repl.

-Jeff

-- 
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: Memoizing tree recursive calls

2010-07-21 Thread Mike Meyer
On Tue, 20 Jul 2010 13:11:12 -0700 (PDT)
Aravindh Johendran  wrote:

> If we have tree recursive procedure such as the follows, how can we
> use memoize it so that it automatically caches the values it has
> already computed .

[example elided]


> Maybe memoize should go the same way as the contrib trace package -
> i.e, have special macros. "Functional" memoizing can only cover so
> much .

You mean something like defn-memo, which is already defined in the
clojure.contrib.def package, and seems to do exactly what you want?

 http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.

O< ascii ribbon campaign - stop html mail - www.asciiribbon.org

-- 
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: Aleph and Conjure

2010-07-21 Thread Jeff Rose
While Aleph's event model is slightly different from what Ring was
originally designed for (the servlet API), I think it would be really
easy to use with Ring.  In Aleph you explicitly respond to a request,
while in Ring you return a response map.  Unless I'm missing out on
something, you can hookup the two approximately like this:

(defn aleph-to-ring-handler [req]
  (respond! req (ring-handler req)))

Where respond! is the aleph function to send a response matching a
given request.

That said, I think Aleph is less than a month old and it is changing
lots, so you probably don't want to use it for anything less than R&D
right now.  Checkout ztellman's client branch to see where it's going
currently.

-Jeff

On Jul 20, 4:17 am, gary b  wrote:
> Conjure cannot be used with Aleph.  Conjure is based on Ring.  Ring
> does not currently support the evented programming model used by
> Aleph.
>
> You can build a scalable app with Conjure on Jetty.  You don't need an
> evented server like Aleph or node.js to build a scalable app.
>
> On Jul 18, 5:26 pm, Victor S  wrote:
>
>
>
> > Can conjure be used to build web app over aleph? Or what does it take
> > to build highly scalable web apps in clojure similar to node.js and
> > express.js?

-- 
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: Leiningen 1.2.0 released!

2010-07-21 Thread Jeff Rose
Absolutely!  Leiningen and its plugin system are wonderful in their
simplicity.  Thanks a lot.

-Jeff

On Jul 20, 6:55 pm, Brian Carper  wrote:
> On Jul 18, 5:17 pm, defn  wrote:
>
> > I think I speak for everyone when I say: "thank you".
>
> inc
>
> --Brian

-- 
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: terracotta?

2010-07-21 Thread Paul Stadig
There are agents, atoms, vars, seqs, and lisp macros all of which may make
Clojure a more appealing alternative to Java for use with Terracotta.

My goal was to get Clojure working with Terracotta, period. Most of the work
I did was actually focused on vars so that you could define a function and
have it available throughout the cluster, but eventually I did want to see
the STM working in Terracotta. Performance doesn't always matter all the
time for every problem, but its good to keep in mind what you are saying
when making decisions where performance does matter.

On Jul 20, 2010 8:46 PM, "peter veentjer"  wrote:

Hi Chas,

if you want to 'spawn' independent processes over different machines,
terracotta could be an option. But as soon as these processes are
going to share state, it gets a lot more complicated since a scalar
clock MVCC based stm is not going to be scalable over different
machines.

Afaik the focus of Paul was on distributing the Clojure STM using
terracotta.


On Jul 20, 5:47 am, Chas Emerick  wrote:
> I can't respond to that, but pres...
> >>> is athttp://github.com/pjstadig/tim-clojure-1.0.0andittries to be

> >>> a Clojure
> >>> 1.0.0 compatible TIM, which shows how its a bit out-of-date.
>
> >>> I am very...

-- 
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: Congomongo question - how to update all records?

2010-07-21 Thread Meikel Brandmeyer
Hi,

> > So, is there some sort of recipe for updating all records without
> > first loading them all into memory?

Maybe you can first do your doall but only retrieve the ids. Then
later on you can retrieve the entry by id and update it. Something
like this:

(defn update-db!
  []
  (doseq [id (doall (fetch :table :only [:id]))]
(let [entry (fetch-one :table :where {:id id})]
  (update! :table entry (assoc entry :col 0)

My congomongo-fu is a bit rusty, but I hope it comes close.

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: Congomongo question - how to update all records?

2010-07-21 Thread Mark Engelberg
So does no one here use congomongo?

On Sat, Jul 10, 2010 at 1:17 PM, Mark Engelberg
 wrote:
> Let's say I have a table called :table, and a column called :col, and
> I want to go through all the records in the table and set the :col
> value to 0.  I had been doing it like this:
> (defn update-db! []
>  (doseq [entry (fetch :table)]
>    (update! :table entry (assoc entry :col 0
>
> but the other day I noticed that this was mysteriously skipping over
> certain records, and not everything was getting updated.  So I
> switched to this:
>
> (defn update-db! []
>  (doseq [entry (doall (fetch :table))]
>    (update! :table entry (assoc entry :col 0
>
> which worked just fine.  I speculate that somehow the update process
> screws with whatever iteration process that fetch uses to deliver the
> records lazily.  However, now my update process is limited by the
> number of records I can hold in memory.
>
> So, is there some sort of recipe for updating all records without
> first loading them all into memory?
>

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