Thanks, Konrad. clojure.lang.Compiler/LOCAL_ENV is what I need.
--
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
On 13 Dec 2009, at 11:18, Dima Dogadaylo wrote:
> Is it possible to create a macros that knows from what function it was
> called and what variables (bindings) are defined in the caller
> function?
Yes. Look at the recent thread on debug REPLs:
http://groups.google.com/group/clojure/bro
Is it possible to create a macros that knows from what function it was
called and what variables (bindings) are defined in the caller
function?
For example following python code defines function print_env that
prints name of function that called print_env() along with local
variables of those func
On Mon, Aug 31, 2009 at 5:04 PM, Brian Hurt wrote:
> On Sun, Aug 30, 2009 at 9:31 AM, Jason Baker wrote:
>
>> On Aug 30, 2:24 am, Dan Fichter wrote:
>> > The Clojure version is more concise and radically safer but a little
>> more
>> > conceptually packed. Is it worth your trouble?
>>
>> Being
On Mon, Aug 31, 2009 at 5:15 PM, Brian Hurt wrote:
> If I recall correctly (and correct me if I'm wrong), Python uses a
> reference counting garbage collector. Which means as soon as the reference
> to the object goes away, the object gets collected and the handle closed.
> Most JVMs use some fo
On Mon, Aug 31, 2009 at 9:03 AM, Konrad Hinsen
wrote:
>
>
> In this particular case, there is no reason to worry: open() returns a
> file object that is fed to the method read(), but after that method
> returns, there is no more reference to the object, so it is garbage
> collected. Upon destructi
On Sun, Aug 30, 2009 at 9:31 AM, Jason Baker wrote:
>
> On Aug 30, 2:24 am, Dan Fichter wrote:
> > The Clojure version is more concise and radically safer but a little more
> > conceptually packed. Is it worth your trouble?
>
> Being primarily a Python programmer, I can say that the first thing
Usually the java libraries explicitly mention not to place OS resource
handles on the finalize() method called by the GC, that why I had the reflex
of thinking it was generally applicable to all languages with a GC.
--
Laurent
2009/8/31 Konrad Hinsen
>
> On 31 Aug 2009, at 14:08, Laurent PETIT
On 31 Aug 2009, at 14:08, Laurent PETIT wrote:
> [Python]
>
> open(filename, 'r').read() # who cares about closing files opened in
> read-mode?
>
> "who cares about closing files opened in read-mode" ?
>
> I would say anybody concerned about blowing up the underlying OS if
> not releasing fil
On Mon, Aug 31, 2009 at 14:08, Laurent PETIT wrote:
> Hi,
>
> Just one point:
>
> 2009/8/30 Dan Fichter
>>
>> Read the contents of a file.
>>
>> [Clojure]
>>
>> (slurp filename)
>>
>> [Python]
>>
>> open(filename, 'r').read() # who cares about closing files opened in
>> read-mode?
>
> "who cares
Hi,
Just one point:
2009/8/30 Dan Fichter
> Read the contents of a file.
>
> [Clojure]
>
> (slurp filename)
>
> [Python]
>
> open(filename, 'r').read() # who cares about closing files opened in
> read-mode?
>
"who cares about closing files opened in read-mode" ?
I would say anybody concerned
On Sun, Aug 30, 2009 at 12:32 PM, CuppoJava wrote:
>
> Your examples are very good I think. It always helps to have a
> straight-forward conversion from one language to another for
> beginners. They will eventually pick up idioms and methodology by
> playing around.
>
> One comparison that bothers
There are two styles of expression in higher level languages
(including Python and Clojure). Functional programming (map, filter,
reduce, fold) on one side and set (and list) comprehensions on the
other. This is somewhat a matter of culture, not capability. Although
slightly less convenient, funct
On Aug 30, 3:24 am, Dan Fichter wrote:
> [...]
> Take a dictionary of defaults and a user-supplied dictionary and return a
> new dictionary that combines them, with the user's entries winning when both
> dictionaries have the same key.
>
> [Clojure]
>
> (defn foo [defaults user]
> (merge defaul
Your examples are very good I think. It always helps to have a
straight-forward conversion from one language to another for
beginners. They will eventually pick up idioms and methodology by
playing around.
One comparison that bothers me though is this:
(not= (new Exception) (new Exception))
Agai
2009/8/30 Dan Fichter :
[...]
> [Clojure]
>
> (println "Hello, world")
>
> [Python]
>
> print "Hello, world"
Or Python 3.x:
print("Hello, world")
> A list (in Clojure, a vector) of three integers.
>
> [Clojure]
>
> [1 2 3]
This can also be written in Clojure as [1, 2, 3]. Commas are
considere
> For example, consider these two snippets:
>
> [Clojure]
> (if x
> (foo y)
> (bar y))
>
> [Python]
> if x:
> foo(y)
> else:
> bar(y)
>
Yeah, but then, in plain old Java:
if x {
foo(y);
} else {
bar(y);
}
which is not that different at all. The point is that these trivial
micro-sni
Dan Fichter napisał(a):
> I'd like to convince some Python developers that Clojure is not foreign and
> does many things better than Python. I'd appreciate whatever suggestions
> you have about what I've written.
[...]
> Check whether every object in the collection x can be called like a
> fu
On Aug 30, 2:24 am, Dan Fichter wrote:
> The Clojure version is more concise and radically safer but a little more
> conceptually packed. Is it worth your trouble?
Being primarily a Python programmer, I can say that the first thing my
co-workers would say is that Clojure isn't as readable as Py
On Aug 30, 2009, at 3:24 AM, Dan Fichter wrote:
> I'd like to convince some Python developers that Clojure is not
> foreign and does many things better than Python. I'd appreciate
> whatever suggestions you have about what I've written.
>
> Though I am crazy about STM and Clojure agents, I
I'd like to convince some Python developers that Clojure is not foreign and
does many things better than Python. I'd appreciate whatever suggestions
you have about what I've written.
Though I am crazy about STM and Clojure agents, I don't deal with them
here. This has to be a gentle introduction
It wont solve your performance problem but I think that your python code
translates to:
(defn f[a b c]
(+ (* c c c c) (* b b b) (* a a)))
(count
(into #{}
(for [c primes :while (< (f (first primes) (first primes) c) limit)
b primes :while (< (f (first primes) b c) limit)
On 12 Mrz., 07:48, tristan wrote:
> my clojure version
> http://github.com/tristan/project-euler-code/blob/4a17bc271b4b2743ee1...
Not about speed, but about readability:
(loop [c primes n #{}]
(let [r (loop [b primes n n]
(let [r (loop [a primes n n]
...)))
You should think about us
You should profile your code.
A cousin of mine was solving a problem from programmingchallenges.com
in C++. I wrote a solution in Clojure.
At the beginning, my version was astronomically slower. After
profiling, I reduced it to about 2x slower.
After modifying it to use Java arrays, it actually b
Setting that one
(set! *warn-on-reflection* true)
Helped a lot in my simulation model to find out where clojure/java
were having trouble. It pointed out that one of my main functions was
causing trouble, and could do with a bit of typehinting.
(defn #^Short find-all-epi
"turns the rx and stri
Hi guys,
I'm loving Clojure, but i'm having a lot of trouble writing programs
in it that run as fast as my python equivalents.
One example is code i've written for projecteuler.net problem 87 (for
those who don't want to see any solutions don't click the links
below :))
my python version
http://
26 matches
Mail list logo