Hi Conrad,
Here is my take: https://gist.github.com/792959
Since I despise indices I wrote the core algorithm without them. That gave
me a maze generation code which can create a maze in any kind of graph. This
would be fun to run it on the utah teapot for example :-)
Christophe
On Thu, Jan 20,
Ken Wesson writes:
> On Sat, Jan 22, 2011 at 11:26 AM, Eric Schulte wrote:
>> Nice concise example,
>
> Thanks.
>
>> A while back I implemented something similar; a propagator system using
>> agents fed with `send', coming in at a slightly more verbose ~35 lines
>> of code.
>>
>> http://cs.unm.e
Thanks,it is an issue.
On Jan 24, 1:09 pm, David wrote:
> Line 86 of core.clj is:
>
> (list 'cadr caddr)
>
> and should be:
>
> (list 'caddr caddr)
>
> On Jan 23, 9:45 pm, dennis wrote:
>
> > I have implemented a simple interpreter in clojure,it is just
> > transformed from the i
Hi,
Yes,i have seen the rscheme.
cscheme is just an exercise,it is not practical at all.
On Jan 24, 1:44 pm, Andrzej wrote:
> Hi,
>
> You may want to see if there is anything of interest for you
> there:http://clojure.wikidot.com/scheme-interpreter-in-clojure
>
> It has its own reader that atte
Dear all ,
how to get api download/generate for various lib such as contrib , enlive
,etc.
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 mod
You can download Clojure 1.2 by going to http://clojure.org/, clicking the
"Download" link, and then clicking the "Clojure 1.2" and "Clojure Contrib
1.2" links.
Bill
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email
Hi,
just a quick one:
(mapcat #([% 1]) [1 3 5])
gives an exception (wrong argument)
(mapcat (fn [a] [a 1]) [1 3 5])
works though...
What did I get wrong?
Thx
Las
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email
Hi,
On 24 Jan., 13:59, László Török wrote:
> just a quick one:
>
> (mapcat #([% 1]) [1 3 5])
>
> gives an exception (wrong argument)
>
> (mapcat (fn [a] [a 1]) [1 3 5])
>
> works though...
>
> What did I get wrong?
#([% 1]) is equivalent to (fn [a] ([a 1])). Note the extra parens. You
want #(ve
That a problem people find often.
The thing is #(%) not the same as (fn [x] x) its more like (fn [x]
(x)).
So if you write #([x]) is (fn [x] ([x])) witch throws an error. You
would have to write #(vec %).
On Jan 24, 1:59 pm, László Török wrote:
> Hi,
>
> just a quick one:
>
> (mapcat #([% 1]) [
Thanks! :)
2011/1/24 Nick Zbinden
> That a problem people find often.
>
> The thing is #(%) not the same as (fn [x] x) its more like (fn [x]
> (x)).
>
> So if you write #([x]) is (fn [x] ([x])) witch throws an error. You
> would have to write #(vec %).
>
> On Jan 24, 1:59 pm, László Török wrote
On Mon, Jan 24, 2011 at 3:22 AM, Eric Schulte wrote:
> Ken Wesson writes:
>> Why (fn [_] value) instead of (constantly value)? OK, actually
>> (constantly value) is textually longer, but I'd argue it might be
>> clearer. And it works; (constantly foo) accepts all arities. It's
>> something like (
sorry , i want the documentation .which are the functions available ...
etc?
--
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
On Jan 23, 2011, at 10:56 PM, Ken Wesson wrote:
> I've managed to make this more efficient, by making each agent send
> process a larger portion of the job than one single item:
>
> (defn eager-pmap [f & colls]
> (let [cores (.. Runtime getRuntime availableProcessors)
>agents (cycle (for
If you go to http://clojure.org/ and look at the links on the left-hand side
of the page, you will find information about the language and the APIs. In
particular, the "API" link on the left-hand side of the page takes you to
information about all the core and contrib functions in the 1.2 rele
The following code doesn't catch the exception thrown like I think it
should. Any recommendations appreciated.
https://gist.github.com/793340
Thank you,
Ryan
- - - -
(ns my-ns
(:use [clj-time.core :only [date-time]]))
(defn my-date-time
"same as clj-time.core date-time but returns nil on
On Mon, Jan 24, 2011 at 5:50 PM, dennis wrote:
> Hi,
> Yes,i have seen the rscheme.
>
> cscheme is just an exercise,it is not practical at all.
So was rscheme. :-) In many respects your implementation is more
complete than mine.
Cheers,
Andrzej
--
You received this message because you are sub
On Mon, Jan 24, 2011 at 10:16 AM, Abraham wrote:
> sorry , i want the documentation .which are the functions available ...
> etc?
For clojure.contrib? There's documentation on the web at
http://clojure.github.com/clojure-contrib/ and though I don't see a
download link you could always use wge
On Jan 19, 2011, at 11:32 AM, Miki wrote:
> I'd appreciate some comments about need functionality, bugs, code reviews and
> such.
Thanks for this useful library. Some suggestions:
-I'd rather (copy-tree src dest) worked like "cp -R src dest" (including when
dest doesn't exist) rather than "cp
> This is much faster than either of the other eager-pmaps I posted to
> this thread, and yet it's only using 60% CPU on my dual-core box. That
> means there's still another x1.6 or so speedup possible(!) but I'm not
> sure how.
>
Could -server make a difference here?
--
You received this messag
On Sun, Jan 23, 2011 at 7:57 PM, Ken Wesson wrote:
>> Which tempts me to ask why you decided to bring it up again? :)
> Because the topic arose again.
Because _you_ brought the topic up again.
Did you expect a different outcome this time?
You know what they say about madness (doing the same thi
>> That would be a great application for this system. Each cell of the
>> spreadsheet could be a cell, and each formula could be a propagator.
>> I've implemented this and it seems to work well, I've committed this to
>> the repo above, and posted the spreadsheet code with example usage into
>> a
On Mon, Jan 24, 2011 at 10:29 AM, Michael Gardner wrote:
> Thanks for the work, Ken.
You're welcome.
> Clojure's multi-threaded performance can be mysterious indeed
I think that may be generally true of multi-processing of every kind. :)
> Anyway, for now I will probably just stick with pmap +
how to get api docs for libraries such as enlive , etc?
--
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 p
On Mon, Jan 24, 2011 at 11:05 AM, Armando Blancas
wrote:
>> This is much faster than either of the other eager-pmaps I posted to
>> this thread, and yet it's only using 60% CPU on my dual-core box. That
>> means there's still another x1.6 or so speedup possible(!) but I'm not
>> sure how.
>>
>
> C
I don't think there is a catch-all mechanism for downloading documentation
for all libraries accessible by or written in Clojure. Perhaps you could
try going to the website for each library you are interested in and looking
for links with names like "Download" and "Documentation". That often w
On Mon, Jan 24, 2011 at 10:32 AM, Ryan Waters wrote:
> The following code doesn't catch the exception thrown like I think it
> should. Any recommendations appreciated.
>
> https://gist.github.com/793340
>
> Thank you,
> Ryan
>
> - - - -
>
> (ns my-ns
> (:use [clj-time.core :only [date-time]]))
>
On Mon, Jan 24, 2011 at 11:14 AM, Sean Corfield wrote:
> On Sun, Jan 23, 2011 at 7:57 PM, Ken Wesson wrote:
>>> Which tempts me to ask why you decided to bring it up again? :)
>> Because the topic arose again.
>
> Because _you_ brought the topic up again.
>
> Did you expect a different outcome th
Arguably it should be neither of these, but instead a macro of some
kind. The solution that would make it "impossible" to get this wrong
would be something like:
(defmacro primitives [& specs]
`(list
~@(for [s specs]
(if (coll? s)
`(list '~(first s) ~(second s))
`(li
Thank you Ken - I should have checked for Exception; not sure why I
didn't. Your other explanations were helpful too.
--
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 n
I noticed that in 'with-open' macro the .close() method is called
without wrapping in another try-catch block. Exceptions raised in the
finally block prevails over the exception raised in the try block. Is
this intended behavior or I am missing something?
Is there an alternative where the exceptio
I'd like to propose different implementation of defnk, attached below.
Defnk2 translates keyword arguments to positional arguments at compile
time, and is therefore about 36x faster on my machine.
(defn expand-keyword-call [name pos kw-defaults args]
(if (< (count args) (count pos))
(throw (
On Mon, Jan 24, 2011 at 2:19 PM, Ryan Waters wrote:
> Thank you Ken - I should have checked for Exception; not sure why I
> didn't. Your other explanations were helpful too.
You're welcome.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to
2011/1/24 Shantanu Kumar :
> I noticed that in 'with-open' macro the .close() method is called
> without wrapping in another try-catch block. Exceptions raised in the
> finally block prevails over the exception raised in the try block. Is
> this intended behavior or I am missing something?
>
> Is t
On Jan 24, 2011, at 1:54 PM, Laurent PETIT wrote:
> That's interesting. Indeed, it seems to me that the .close() call
> should be wrapped by a try / catch with an empty catch.
Why would client code want an exception thrown by .close() to get swallowed? Is
that not unexpected behavior in most cas
Just wrap it if you are paranoid about exception on close
(try (with-open [x y]
(throw (Exception. "lololol")))
(catch Exception e (println (.getMessage e
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send
On Jan 25, 1:26 am, dysinger wrote:
> Just wrap it if you are paranoid about exception on close
>
> (try (with-open [x y]
> (throw (Exception. "lololol")))
> (catch Exception e (println (.getMessage e
The problem is that exception thrown by .close() overshadows any
return va
No need for wget etc,
For core you can download from,
https://github.com/clojure/clojure/tree/gh-pages
For contrib,
https://github.com/clojure/clojure-contrib/tree/gh-pages
Just click on download...
Regards...
--
Nurullah Akkaya
http://nakkaya.com
On Mon, Jan 24, 2011 at 5:55 PM, Ken Wesso
On Mon, Jan 24, 2011 at 3:58 PM, Nurullah Akkaya wrote:
> No need for wget etc,
>
> For core you can download from,
>
> https://github.com/clojure/clojure/tree/gh-pages
>
> For contrib,
>
> https://github.com/clojure/clojure-contrib/tree/gh-pages
>
> Just click on download...
Perhaps the page htt
(try (with-open [x y] ... )
(catch Exception)) ;; <- catches any exception from with-open macro
I don't think you are correct.
--
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 t
On Mon, Jan 24, 2011 at 4:07 PM, dysinger wrote:
>
> (try (with-open [x y] ... )
> (catch Exception)) ;; <- catches any exception from with-open macro
>
> I don't think you are correct.
He is. Close exceptions lose any other exception or return value:
user=> (defprotocol Closeable (close [
On Jan 25, 2:07 am, dysinger wrote:
> (try (with-open [x y] ... )
> (catch Exception)) ;; <- catches any exception from with-open macro
>
> I don't think you are correct.
Maybe this is subjective, but I am rarely interested in knowing what
exception does .close() throw - I would like it i
Yes. you are correct and I agree that you would lose the original exception
or return type. I was just saying you could catch the exception of the IO
close if needed.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email
On Mon, 24 Jan 2011 13:30:49 -0800 (PST)
Shantanu Kumar wrote:
>
>
> On Jan 25, 2:07 am, dysinger wrote:
> > (try (with-open [x y] ... )
> > (catch Exception)) ;; <- catches any exception from with-open
> > macro
> >
> > I don't think you are correct.
>
> Maybe this is subjective, but
On Mon, Jan 24, 2011 at 2:27 PM, Shantanu Kumar
wrote:
> I noticed that in 'with-open' macro the .close() method is called
> without wrapping in another try-catch block. Exceptions raised in the
> finally block prevails over the exception raised in the try block. Is
> this intended behavior or I a
On Jan 25, 2:47 am, Aaron Cohen wrote:
> On Mon, Jan 24, 2011 at 2:27 PM, Shantanu Kumar
>
> wrote:
> > I noticed that in 'with-open' macro the .close() method is called
> > without wrapping in another try-catch block. Exceptions raised in the
> > finally block prevails over the exception raise
Yes, you're right Shantanu.
apache commons io and spring framework, to name 2 things I know for
sure, are doing what you say: they swallow any exception that could be
thrown within the finally block, for the reasons you mention.
Of course, with-open allowing to do several binding, the
try/swallow
> First, Sonatype's validation of -sources.jar and -javadoc.jar aren't as
> stringent as you might expect. That is, the OSS/central repos' validation
> routines appear to check for the existence of those artifacts corresponding
> to a given jar artifact, but they aren't inspected for completene
On Monday, January 24, 2011 12:59:09 PM UTC, Las wrote:
>
> What did I get wrong?
>
I believe #([% 1]) is equivalent to (fn [a] ([a 1])), not (fn [a] [a 1]) .
Thus, for #([% 1]) , [% 1] is called as a function. Vectors are functions
that take an index and return the vector's value at that inde
To build a browse-able API for clojure projects, you can use autodoc:
http://tomfaulhaber.github.com/autodoc/
On 1/24/11, .Bill Smith wrote:
> You can download Clojure 1.2 by going to http://clojure.org/, clicking the
> "Download" link, and then clicking the "Clojure 1.2" and "Clojure Contrib
> 1
I personally find clojure docs (http://clojuredocs.org/) to be the best
source of core/contrib documentation.
~Adam~
--
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
> apache commons io and spring framework, to name 2 things I know for
> sure, are doing what you say: they swallow any exception that could be
> thrown within the finally block, for the reasons you mention.
True, but if the body doesn't throw an exception, but the close does,
I wouldn't want the
2011/1/24 David Powell :
>
>> apache commons io and spring framework, to name 2 things I know for
>> sure, are doing what you say: they swallow any exception that could be
>> thrown within the finally block, for the reasons you mention.
>
> True, but if the body doesn't throw an exception, but the
> apache commons io and spring framework, to name 2 things I know for
> sure, are doing what you say: they swallow any exception that could be
> thrown within the finally block, for the reasons you mention.
True, but if the body doesn't throw an exception, but the close does,
I wouldn't want the
2011/1/25 Laurent PETIT :
> 2011/1/24 David Powell :
>>
>>> apache commons io and spring framework, to name 2 things I know for
>>> sure, are doing what you say: they swallow any exception that could be
>>> thrown within the finally block, for the reasons you mention.
>>
>> True, but if the body do
Hello.
If you have REPL, you can get any documentation via "doc" and
"find-doc" functions.
(doc reduce) ; print the documentation of reduce
(find-doc "append") ; search documentations including word "append"
"doc" function can be used with almost all things documented:
variable, function, namesp
On Jan 24, 3:05 pm, Laurent PETIT wrote:
> 2011/1/24 David Powell :
>
>
>
> >> apache commons io and spring framework, to name 2 things I know for
> >> sure, are doing what you say: they swallow any exception that could be
> >> thrown within the finally block, for the reasons you mention.
>
> > Tr
2011/1/24 Laurent PETIT :
> Yes, you're right Shantanu.
>
> apache commons io and spring framework, to name 2 things I know for
> sure, are doing what you say: they swallow any exception that could be
> thrown within the finally block, for the reasons you mention.
for the record, references:
apach
>
> -I'd rather (copy-tree src dest) worked like "cp -R src dest" (including
> when dest doesn't exist) rather than "cp -R src/* dest/".
>
> I agree, working on that.
> -It would be nice if functions that create files or dirs (like mkdir and
> touch) returned the new object's path, to allow ch
2011/1/25 Alan :
> On Jan 24, 3:05 pm, Laurent PETIT wrote:
>> 2011/1/24 David Powell :
>>
>>
>>
>> >> apache commons io and spring framework, to name 2 things I know for
>> >> sure, are doing what you say: they swallow any exception that could be
>> >> thrown within the finally block, for the rea
Are we generally agreed that we want to preserve the body exception,
if any, else the close exception, if any, else the body return value?
Then, without further ado:
(defmacro with-open2 [binding-exprs & body]
(if (> (count binding-exprs) 2)
`(with-open2 ~(vec (take 2 binding-exprs))
> apache commons io and spring framework, to name 2 things I know for
> sure, are doing what you say: they swallow any exception that could be
> thrown within the finally block, for the reasons you mention.
True, but if the body doesn't throw an exception, but the close does,
I wouldn't want the
On Jan 22, 5:13 pm, Stuart Halloway wrote:
> Please don't. It has already been discussed and declined. The metadata
> is uglier because we want doing this to be slightly ugly..
> >> The Clojure/core team is led by its technical advisors, Rich Hickey and
> >> myself. In this particula
On Mon, Jan 24, 2011 at 4:54 PM, Shantanu Kumar
wrote:
>
>
> On Jan 25, 2:47 am, Aaron Cohen wrote:
>> On Mon, Jan 24, 2011 at 2:27 PM, Shantanu Kumar
>>
>> wrote:
>> > I noticed that in 'with-open' macro the .close() method is called
>> > without wrapping in another try-catch block. Exceptions
2011/1/25 Ken Wesson :
> Are we generally agreed that we want to preserve the body exception,
> if any, else the close exception, if any, else the body return value?
>
> Then, without further ado:
>
> (defmacro with-open2 [binding-exprs & body]
> (if (> (count binding-exprs) 2)
> `(with-open2 ~
On Mon, Jan 24, 2011 at 7:26 PM, Aaron Cohen wrote:
> The inner exception to me should clearly be caught and not rethrown.
> So I would really expect to see two printouts when this is run, once
> for doit and once for close.
Neither would I. I think you've misunderstood something, though.
> Why
On Mon, Jan 24, 2011 at 7:32 PM, Laurent PETIT wrote:
> 2011/1/25 Ken Wesson :
>> Are we generally agreed that we want to preserve the body exception,
>> if any, else the close exception, if any, else the body return value?
>>
>> Then, without further ado:
>>
>> (defmacro with-open2 [binding-exprs
Thanks, Ken. Much more productive than all this philosophy about what
"makes sense" the rest of us are discussing; I'd vote for this patch
if you put it in JIRA.
On Jan 24, 3:59 pm, Ken Wesson wrote:
> Are we generally agreed that we want to preserve the body exception,
> if any, else the close e
2011/1/25 Ken Wesson :
> On Mon, Jan 24, 2011 at 7:32 PM, Laurent PETIT
> wrote:
>> 2011/1/25 Ken Wesson :
>>> Are we generally agreed that we want to preserve the body exception,
>>> if any, else the close exception, if any, else the body return value?
>>>
>>> Then, without further ado:
>>>
>>>
On Mon, Jan 24, 2011 at 7:40 PM, Alan wrote:
> Thanks, Ken. Much more productive than all this philosophy about what
> "makes sense" the rest of us are discussing; I'd vote for this patch
> if you put it in JIRA.
No patch; sorry; don't have a CA. Laurent improved on it somewhat anyway.
You're we
2011/1/25 Ken Wesson :
> On Mon, Jan 24, 2011 at 7:32 PM, Laurent PETIT
> wrote:
>> 2011/1/25 Ken Wesson :
>>> Are we generally agreed that we want to preserve the body exception,
>>> if any, else the close exception, if any, else the body return value?
>>>
>>> Then, without further ado:
>>>
>>>
of course I missed something :-(
2011/1/25 Laurent PETIT :
> 2011/1/25 Ken Wesson :
>> On Mon, Jan 24, 2011 at 7:32 PM, Laurent PETIT
>> wrote:
>>> 2011/1/25 Ken Wesson :
Are we generally agreed that we want to preserve the body exception,
if any, else the close exception, if any, else
There it is, corrected:
(in-ns 'clojure.core)
(defmacro with-open
"bindings => [name init ...]
Evaluates body in a try expression with names bound to the values
of the inits, and a finally clause that calls (.close name) on each
name in reverse order."
{:added "1.0"}
[bindings & body]
On Mon, Jan 24, 2011 at 7:43 PM, Laurent PETIT wrote:
> 2011/1/25 Ken Wesson :
>> Ah, I guess it may be a bit cleaner to just eschew "finally"
>> altogether and close in the try and in the catch. The one thing that's
>> a bit icky about that is that if the body close throws, the catch
>> clause tr
Huh. We came up with almost the same final version. I guess I took 13
minutes longer because I tested mine -- yours still has the missing #.
:)
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.c
Ugly? Aww, I thought the ^ metadata looked kinda cute...
It is a bit awkward that defn- exists and not def-, but it seems defs
are not going to be as common as defns (though I'll admit I haven't
written or read enough complex idiomatic Clojure code to know for
sure). And if you really want to be
On Mon, Jan 24, 2011 at 8:42 PM, Nick Brown wrote:
> Ugly? Aww, I thought the ^ metadata looked kinda cute...
>
> It is a bit awkward that defn- exists and not def-, but it seems defs
> are not going to be as common as defns (though I'll admit I haven't
> written or read enough complex idiomatic
Seems pretty clear that your macports version of curl is the problem, it's
up to you what you want to do about it. I don't know if uninstalling it
would leave you with the OS X version of curl or not. Link to get you
started:
http://www.richarddooling.com/index.php/2009/09/12/macports-on-snow-le
Hello.
> And if you really want to be consistent you would probably
> also want defmulti-, defmacro-, defstruct-, defprotocol-, etc.
In my opinion, if defn- is not in core but in contrib, I feel "be consistent".
By the way, defstruct- and defmacro- is in contrib consistently :-)
> If we really w
Hi Larry,
As a quick temporary workaround you could just set your PATH environment
variable so that it picks up the curl executable from /usr/bin instead
of the broken MacPorts one from /opt/local/bin.
$ which curl
/opt/local/bin/curl
$ export PATH=/usr/bin:$PATH
$ which curl
/usr/bin/curl
You'l
i would totally recommend uninstalling macports, and moving over to
homebrew which is far better (https://github.com/mxcl/homebrew).
On Mon, Jan 24, 2011 at 8:44 PM, Alex Osborne wrote:
> Hi Larry,
>
> As a quick temporary workaround you could just set your PATH environment
> variable so that it
user> (use '[clojure.contrib.http.agent :as ha])
WARNING: bytes already refers to: #'clojure.core/bytes in namespace:
user, being replaced by: #'clojure.contrib.http.agent/bytes
nil
user> (string (http-agent "http://url.that.doesnt.exist.com";))
This will block indefinitely since the url does not
On Mon, Jan 24, 2011 at 11:23 PM, HiHeelHottie wrote:
>
> user> (use '[clojure.contrib.http.agent :as ha])
> WARNING: bytes already refers to: #'clojure.core/bytes in namespace:
> user, being replaced by: #'clojure.contrib.http.agent/bytes
> nil
> user> (string (http-agent "http://url.that.doesnt.
The changed code should catch 'Exception', not 'Throwable' because the
latter is a common ancestor of both 'Exception' and 'Error'. An
'Error' must not be swallowed at any point in the system, unless you
are writing an app server or a JVM implementation. ;-)
Regards,
Shantanu
On Jan 25, 6:11 am,
Hi,
On 25 Jan., 01:33, Ken Wesson wrote:
> It looks a little quirky in macroexpand output and seems slightly ugly
> but it works and probably isn't even inefficient at runtime, as the
> close symbol presumably has a name slot that takes up four bytes
> whether it's nil or a pointer to a string,
Hi,
On 25 Jan., 01:57, Laurent PETIT wrote:
> (try (. ~(bindings 0) close) (catch Throwable _))
New code should use (.close foo) instead of (. foo close), IIRC.
Sincerely
Meikel
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this grou
85 matches
Mail list logo