I wrote a small set of functions for executing code while measuring
and/or limiting its time and/or memory consumption. I did this both
to run timing experiments, and to let me run things at the REPL
without risking an infinite loop (and having to restart Clojure from
scratch).
Would anyone
I think TCO is very doable and likely to appear in some common JVMs at
some point.
Continuations, on the other hand, are likely to require a massive
infrastructure overhaul.
Cliff
On Jan 26, 4:38 am, Rich Hickey richhic...@gmail.com wrote:
On Jan 26, 3:20 am, Konrad Hinsen
On Jan 27, 2009, at 16:28, cliffc wrote:
I think TCO is very doable and likely to appear in some common JVMs at
some point.
Continuations, on the other hand, are likely to require a massive
infrastructure overhaul.
TCO would already by a step forward: it would make continuation-
passing
On Jan 26, 3:20 am, Konrad Hinsen konrad.hin...@laposte.net wrote:
On 25.01.2009, at 21:33, Rich Hickey wrote:
Looks interesting. I made AStream.Iter an IFn, so you can try that.
Thanks! It works fine, the changes to stream-utils are checked in.
There is just one situation that still
On Jan 26, 3:20 am, Konrad Hinsen konrad.hin...@laposte.net wrote:
On 25.01.2009, at 21:33, Rich Hickey wrote:
Something else that would be nice for implementing generators and
thus streams is Scheme-style continuations. That would permit to
write generators like in Python, as loopy code
On Mon, Jan 26, 2009 at 4:38 AM, Rich Hickey richhic...@gmail.com wrote:
Continuations, like TCO, will have to come from the JVM.
Perhaps a better question to ask is whether it is possible to
implement yield without user-available continuations. I assume it's
possible since Python has yield,
On 26.01.2009, at 20:58, Mark Engelberg wrote:
On Mon, Jan 26, 2009 at 4:38 AM, Rich Hickey richhic...@gmail.com
wrote:
Continuations, like TCO, will have to come from the JVM.
Perhaps a better question to ask is whether it is possible to
implement yield without user-available
For those who like me are playing with the stream-enabled branch of
Clojure, there is a new module stream-utils on clojure.contrib:
http://code.google.com/p/clojure-contrib/source/browse/trunk/src/
clojure/contrib/stream-utils.clj
Obviously this is very experimental, and absolutely
, once again (Chouser?), is there anything I can do to help
implement the changes we've talked about? I can try to make patches
for the changes in core, and/or improve and document other utilities
for clojure.contrib, if that would be helpful.
Cheers,
Jason
in the archives, so I must
have been mistaken.
I can try to make patches for the changes in core, and/or improve
and document other utilities for clojure.contrib, if that would be
helpful.
I think it might be most useful to split up the changes into smaller
chunks, perhaps as small as a single
utilities for clojure.contrib, if that would be
helpful.
I think it might be most useful to split up the changes into smaller
chunks, perhaps as small as a single function each, or maybe a couple
of related functions together. Each of these chunks can be posted as
a feature-request
On Jan 20, 2009, at 3:36 PM, Jason Wolfe wrote:
OK, I'll get on this then. It this just for changes to core, or
should I post proposed functions for contrib there/ on the contrib
issues page too? If not, what should I do with them?
I recommend that proposed changes for clojure-contrib be
On Tue, Jan 20, 2009 at 3:55 PM, Stephen C. Gilardi squee...@mac.com wrote:
I recommend that proposed changes for clojure-contrib be tracked as
clojure-contrib issues.
I agree.
My understanding of the issue policy for Clojure is that Rich would still
like to approve them either here or on
On Jan 20, 4:15 pm, Chouser chou...@gmail.com wrote:
On Tue, Jan 20, 2009 at 3:55 PM, Stephen C. Gilardi squee...@mac.com wrote:
I recommend that proposed changes for clojure-contrib be tracked as
clojure-contrib issues.
I agree.
My understanding of the issue policy for Clojure is
On Jan 20, 4:15 pm, Chouser chou...@gmail.com wrote:
On Tue, Jan 20, 2009 at 3:55 PM, Stephen C. Gilardi
squee...@mac.com wrote:
I recommend that proposed changes for clojure-contrib be tracked as
clojure-contrib issues.
I agree.
My understanding of the issue policy for Clojure is
On Jan 20, 2009, at 7:16 PM, Jason Wolfe wrote:
On Jan 20, 4:15 pm, Chouser chou...@gmail.com wrote:
On Tue, Jan 20, 2009 at 3:55 PM, Stephen C. Gilardi
squee...@mac.com wrote:
I recommend that proposed changes for clojure-contrib be tracked as
clojure-contrib issues.
I agree.
My
I didn't find any of them compelling enough for core just yet. Putting
them in contrib first lets people try them out and refine them, point
out redundancies and conflicts etc.
As a general rule I haven't pulled many simple combining functions
from contrib, as they just pollute the
(defn maximal-elements [f s]
Return a seq of elements of s maximizing (f elt).
(when (seq s)
(loop [max-elts (first s),
max-val (f (first s)),
rest-elts (rest s)]
(if (empty? rest-elts)
max-elts
(let [next-val (f (first
On Jan 14, 1:03 pm, Jason Wolfe jawo...@berkeley.edu wrote:
(import '(java.util HashSet))
(defn distinct-elts? Are all of the elements of this sequence
distinct? Works on infinite sequences with repititions, making it
useful for, e.g., detecting cycles in graphs.
[s]
(let [hs
I also think it's unhelpful for codebases to stray further from the
builtin functions than needed, because it makes that code harder to
read as well. So I will consider each of these more carefully.
My comments below are of course highly influence by my personal
experiences using Clojure. I'm
On Wed, Jan 14, 2009 at 12:11 AM, GS gsincl...@gmail.com wrote:
On Jan 13, 7:17 pm, Nick Vogel voge...@gmail.com wrote:
seq returns nil when a collection has no items. According to the
documentation for empty?, empty? is the same as (not (seq coll)) so you
should use seq for expressing the
I agree with Chouser that an uncluttered library is a great virtue. I
too have been turned off by CL in part because of the enormous number
of subtly distinct built-in functions. I'm partial to Scheme, though,
so maybe I'm best viewed as a fanatic on this point. :-)
That said, it does seem
On Jan 14, 10:10 am, Chouser chou...@gmail.com wrote:
I also think it's unhelpful for codebases to stray further from the
builtin functions than needed, because it makes that code harder to
read as well. So I will consider each of these more carefully.
Thanks for your detailed response! To
So, either:
1. My experiment was wrong, and seq? is not a valid stand-in
for seq in the above code.
Right on the first try! :-)
Well, that's something :)
user= (seq-chunk 2 [1 2 3 4 5])
((1 2) (3 4) (5))
user= (seq?-chunk 2 [1 2 3 4 5])
nil
This is because a vector is not
Sigh, I wish the API docs were more helpful in this case.
clojure.core/seq?
([x])
Return true if x implements ISeq
It's asking a lot from me to know whether vectors implement ISeq.
If you don't know, you can always just ask the language :)
user (ancestors (class [1 2 3]))
On Wed, Jan 14, 2009 at 4:26 PM, Jason Wolfe jawo...@berkeley.edu wrote:
user (contains? (ancestors (class [1 2 3])) clojure.lang.ISeq)
false
Also there's 'isa?':
user= (isa? (class [1 2 3]) clojure.lang.ISeq)
false
user= (isa? (class (seq [1 2 3])) clojure.lang.ISeq)
true
And 'instance?':
On Jan 14, 5:02 pm, Chouser chou...@gmail.com wrote:
On Wed, Jan 14, 2009 at 4:26 PM, Jason Wolfe jawo...@berkeley.edu wrote:
user (contains? (ancestors (class [1 2 3])) clojure.lang.ISeq)
false
Also there's 'isa?':
user= (isa? (class [1 2 3]) clojure.lang.ISeq)
false
user= (isa?
user (= '(1) [1])
true
user (= '() [])
false
Hm. That does seem rather odd.
Fixed - svn 1208.
Oh, I always assumed this was intentional ... I guess I never tried
switching the order of arguments. Well, that makes a bit more sense
then :).
On Wed, Jan 14, 2009 at 4:03 PM, Jason Wolfe jawo...@berkeley.edu wrote:
To keep this manageable, I'll cut out the parts where I don't think
comments are needed.
Good idea!
(defn concat-elts Lazily concatenate elements of a seq of seqs. [s]
(when (seq s) (lazy-cat (first s) (concat-elts
On Jan 14, 12:07 pm, Michael Harrison (goodmike)
goodmike...@gmail.com wrote:
But I'm not afraid of using reduce, map, and apply to prepare values
to use as arguments to built-ins. And I'm not afraid to encapsulate
this into my own functions when I need to. I'm OK with building up a
bit of a
On Jan 13, 2:59 pm, Chouser chou...@gmail.com wrote:
It raises a question, though -- how much functionality should a
function provide to be worth making everyone who reads the code learn
the new vocabulary? I've written each of these inline when I've
needed them. Are they better as idioms
seq returns nil when a collection has no items. According to the
documentation for empty?, empty? is the same as (not (seq coll)) so you
should use seq for expressing the opposite of empty?
On Tue, Jan 13, 2009 at 3:12 AM, GS gsincl...@gmail.com wrote:
On Jan 13, 2:59 pm, Chouser
On Tue, Jan 13, 2009 at 3:12 AM, GS gsincl...@gmail.com wrote:
Should that seq be seq?. If not, why not?
Nick nailed that one.
The general question it raises for _me_ is this: why is such a basic,
useful and generally applicable function like 'chunk not included in
the core? Or
On Tue, Jan 13, 2009 at 4:05 PM, Jason Wolfe jawo...@berkeley.edu wrote:
It raises a question, though -- how much functionality should a
function provide to be worth making everyone who reads the code learn
the new vocabulary? I've written each of these inline when I've
needed them. Are
On Jan 13, 1:42 pm, Chouser chou...@gmail.com wrote:
One of the things I found difficult with CL was the extremely large
number of builtin functions -- a large vocabulary with subtle
differences between nearly synonymous-sounding words. It meant that
at first glance, a particular block of
On Jan 13, 4:42 pm, Chouser chou...@gmail.com wrote:
One of the things I found difficult with CL was the extremely large
number of builtin functions -- a large vocabulary with subtle
differences between nearly synonymous-sounding words.
I've had the same experience with Common Lisp code.
(defn chunk Lazily break s into chunks of length n (or less, for the
final chunk).
[n s]
(when (seq s)
(lazy-cons (take n s)
(chunk n (drop n s)
Should that seq be seq?. If not, why not?
On Jan 13, 7:17 pm, Nick Vogel voge...@gmail.com wrote:
seq
Hi all,
I've got lots of utilities that I think people might find useful, and
might fit well in clojure.contrib (just sent in my contrib agreement
last week). I don't know how the process works to get code in there,
but I figured I'd go ahead and post them all here so people can chime
in about
On Mon, Jan 12, 2009 at 6:48 PM, Jason Wolfe jawo...@berkeley.edu wrote:
(defn map-when Like map but discards logically false entries
[fn seqs]
(filter identity (apply map fn seqs)))
I'd use map-when.
(defn iterate-while [f x]
(take-while identity (iterate f x)))
This one too.
It
39 matches
Mail list logo