It seems to me that neither filt-split nor filter-rem from e are lazy
operations (one uses reduce, the other one uses recur).
The version in clojurecontrib seems to preserve the original property of
filter of returning a lazy sequence.
My 0,02€,
--
Laurent
2009/3/8 Adrian Cuthbertson
On 08.03.2009, at 00:14, mikel wrote:
You can do a lot of that in Clojure, too, but, unless I'm mistaken,
there are some arbitrary limits as things stand right now. I don't
know of a way in Clojure to define an interface; as far as I know, if
Multimethods can be used very well to define
Identity is tested first in equality, if identical, equal, full stop.
That's what I'd assumed (it's what the JDK collections do), but
looking at the code, to say, APersistentVectory, I can't see where the
identity test is done? Am I looking in the wrong place?
--
Dave
Sorry, further to that last example, if you actually consume all of
both even and odd sets then the reduce version is more efficient...
(time (let [[a b] (filt-split even? (range 10))] [(nth a 4)
(nth b 4)]))
Elapsed time: 36.711 msecs
[8 9]
(time (let [[a b] (separate even?
The question showed up the other day on #clojure with the additional
constraint to evaluate pred only once per item, here is Rich's solution:
http://paste.lisp.org/display/76458#1
(defn unzip-with [pred coll]
(let [pvs (map #(vector (pred %) %) coll)]
[(for [[p v] pvs :when p] v)
Hmm, on the same (micro admittedly) benchmark as above...
(time (let [[a b] (unzip-with even? (range 10))] [(nth a 4)
(nth b 4)]))
Elapsed time: 177.797 msecs
[8 9]
that's a bit slower than both the previous versions. The reduce
version does only apply the pred once per item
(filt-rem identity '(true nil false 8)) = ((true) ())
(filt-split identity '(true nil false 8)) = [[true 8] [nil false]]
can't speak for this one, cause I don't know enough clojure
(filt-rem even? (range 10)) = ((8 6 4 2 0) (9 7 5 3 1))
(filter-split even? (range 10)) = [(0 2 4 6 8) (1 3 5
Hello Name-cousin, :)
Am 08.03.2009 um 08:10 schrieb mikel:
Now suppose I want to create some new objects that have all of those
advantages, but the interfaces that I want them to conform to don't
yet exist. How do I supply them? As far as I know, I have to write
Java code. I'd rather write
This is exactly what I'm trying to avoid. I don't want to traverse
the collection twice.
In that other thread, Time lies, even with doall, someone helped me figure
out a way to get the true time for filter-split, and concluded it was 2- 3
times faster than whats in contrib as expected . . .
On Mar 8, 6:20 am, Meikel Brandmeyer m...@kotka.de wrote:
Hello Name-cousin, :)
Woohoo!
Am 08.03.2009 um 08:10 schrieb mikel:
Now suppose I want to create some new objects that have all of those
advantages, but the interfaces that I want them to conform to don't
yet exist. How do I
On Sun, Mar 8, 2009 at 6:48 AM, Meikel Brandmeyer m...@kotka.de wrote:
Hi,
Am 08.03.2009 um 11:44 schrieb Adrian Cuthbertson:
that's a bit slower than both the previous versions. The reduce
version does only apply the pred once per item I think?
unzip-with is lazy, the reduce version is
Is there a function to capitalize the first letter of a string or a
better way than this idiotic code?
(apply str (map #(if (zero? %2) (Character/toUpperCase %1) %1)
clojuriffic (iterate inc 0)))
Aloha,
David Sletten
--~--~-~--~~~---~--~~
You received this
Is there a webpage or video that describes what Clojure transactions
do to avoid deadlocks? I'm not having a particular issue. I just want
to understand what is provided. Perhaps I just need to look at the
source starting from dosync.
--
R. Mark Volkmann
Object Computing, Inc.
How about this?
user= (defn upper-first [s] (apply str (Character/toUpperCase (first
s)) (rest s)))
#'user/upper-first
user= (upper-first a)
A
On Sun, Mar 8, 2009 at 3:39 PM, David Sletten da...@bosatsu.net wrote:
Is there a function to capitalize the first letter of a string or a
On Mar 8, 2009, at 2:45 AM, Joshua Fox wrote:
How about this?
user= (defn upper-first [s] (apply str (Character/toUpperCase (first
s)) (rest s)))
#'user/upper-first
user= (upper-first a)
A
That certainly qualifies as less idiotic. :)
Mahalo,
David Sletten
First of all, make sure you use the latest versions of slime, clojure,
swank-clojre and clojure-mode. It works fine for me on both linux and
windows.
get latest slime here - http://common-lisp.net/project/slime/
get latest swank-clojure (your version seems to be outdated) here -
Thanks Lucio, but you can see on git-hub that the head version of
core.clj uses lazy-seq:
http://github.com/jochu/swank-clojure/blob/349cb3b93a7bd8bcc86ffd0fd5415d84ed5f4028/swank/core.clj
On Mar 8, 9:02 am, Lucio Fulci luciofulc...@gmail.com wrote:
First of all, make sure you use the latest
well, I'm not an expert in lisp, emacs and linux either :)
the thing is that latest version of swank-clojure does work for me.
On Sun, Mar 8, 2009 at 5:09 PM, youngblood.carl
youngblood.c...@gmail.comwrote:
Thanks Lucio, but you can see on git-hub that the head version of
core.clj uses
I am not particularly fond of idiomatic style. In production code I
want something clear and explicit even if it is a bit longer. That
said, your question triggered this challenge: What's the shortest way
for capitalizing the first letter of every word, i.e.: (assert (=
(capitalize ab cd) Ab Cd))
*EARN 300-600 DOLLARS PER MONTH WITHOUT INVESTMENT
For more details please log on to
http://www.moreinfo247.com/10288668/CB
(instead of 9222074 use your ID)
•YOU WILL BE PAID 2 US DOLLARS FOR EACH MEMBER JOINING UNDER YOU
(they also should work)
•TO ENROLL MEMBERS YOU CAN USE
*EARN 300-600 DOLLARS PER MONTH WITHOUT INVESTMENT
For more details please log on to
http://www.moreinfo247.com/10288668/CB
(instead of 9222074 use your ID)
•YOU WILL BE PAID 2 US DOLLARS FOR EACH MEMBER JOINING UNDER YOU
(they also should work)
•TO ENROLL MEMBERS YOU CAN USE
*EARN 300-600 DOLLARS PER MONTH WITHOUT INVESTMENT
For more details please log on to
http://www.moreinfo247.com/10288668/CB
(instead of 9222074 use your ID)
•YOU WILL BE PAID 2 US DOLLARS FOR EACH MEMBER JOINING UNDER YOU
(they also should work)
•TO ENROLL MEMBERS YOU CAN USE
Get Nike Shoes at Super Cheap Prices
Discount Nike air jordans (www.stylishdudes.com)
Discount Nike Air Max 90 Sneakers (www.stylishdudes.com)
Discount Nike Air Max 91 Supplier (www.stylishdudes.com)
Discount Nike Air Max 95 Shoes Supplier (www.stylishdudes.com)
Discount Nike Air Max 97
*EARN 300-600 DOLLARS PER MONTH WITHOUT INVESTMENT
For more details please log on to
http://www.moreinfo247.com/10288668/CB
(instead of 9222074 use your ID)
•YOU WILL BE PAID 2 US DOLLARS FOR EACH MEMBER JOINING UNDER YOU
(they also should work)
•TO ENROLL MEMBERS YOU CAN USE
*EARN 300-600 DOLLARS PER MONTH WITHOUT INVESTMENT
For more details please log on to
http://www.moreinfo247.com/10288668/CB
(instead of 9222074 use your ID)
•YOU WILL BE PAID 2 US DOLLARS FOR EACH MEMBER JOINING UNDER YOU
(they also should work)
•TO ENROLL MEMBERS YOU CAN USE
Sorry about the spam. A few messages got through due to a mis-click on
my part. The defenses are still fine.
Rich
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this group, send email to
Same problem here.
my solution : i'm currently using Clojure Box - http://clojure.bighugh.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Clojure group.
To post to this group, send email to
Hi,
Am 08.03.2009 um 15:26 schrieb Itay Maman:
(assert (= (capitalize ab cd) Ab Cd)) ?
Here's my take:
(defn capitalize [s]
(apply str (map (fn [prev curr]
(or (and (= prev \space) (Character/toUpperCase curr)) curr))
(cons \space s) s)))
That's mine:
(defn capitalize
[words]
On Mar 8, 9:39 am, David Sletten da...@bosatsu.net wrote:
Is there a function to capitalize the first letter of a string or a
better way than this idiotic code?
Once again, Apache Commons to the rescue: http://tinyurl.com/d38wwq
(StringUtils/capitalize clojure)
;;= Clojure
-Stuart Sierra
It's great to see all of the Clojure libraries springing up as people
pull Clojure towards their application domains, and shape it for the
styles of programming they prefer.
In looking at some of the libraries, I am a bit concerned that maps
are not being used when the logical entity is in fact
youngblood.carl napisał(a):
Thanks Lucio, but you can see on git-hub that the head version of
core.clj uses lazy-seq:
http://github.com/jochu/swank-clojure/blob/349cb3b93a7bd8bcc86ffd0fd5415d84ed5f4028/swank/core.clj
I read somewhere too that lazy-seq dissapeared from clojure
and that is
On Mar 5, 4:23 pm, Paul Stadig p...@stadig.name wrote:
I had one last, major hurdle, and was helped by Chouser (thank you!).
http://paul.stadig.name/2009/03/clojure-terracotta-we-have-repl.html
Still lots more to do, and probably some simple changes that could be
rolled back into the
On Mar 8, 1:53 pm, Rich Hickey richhic...@gmail.com wrote:
I really appreciate the work everyone is doing, just trying to
maintain 'everything works with everything' with a nudge towards more
consistent use of maps. Don't build your API on an island.
And a good nudge it is! This reminds me
On 8 Mrz., 13:40, Mark Volkmann r.mark.volkm...@gmail.com wrote:
Is there a webpage or video that describes what Clojure transactions
do to avoid deadlocks? I'm not having a particular issue. I just want
to understand what is provided. Perhaps I just need to look at the
source starting from
On 7 Mrz., 18:38, Meikel Brandmeyer m...@kotka.de wrote:
Dear Clojurians,
I'd like to announce release of LazyMap v2.2.
New in this release are:
* compatibility with lazy-seq changes
* LazyMapSeq now inherits from ASeq
* 100% reflection free
The release maybe found at the usual
youngblood.carl youngblood.c...@gmail.com writes:
Thanks Lucio, but you can see on git-hub that the head version of
core.clj uses lazy-seq:
http://github.com/jochu/swank-clojure/blob/349cb3b93a7bd8bcc86ffd0fd5415d84ed5f4028/swank/core.clj
The lazy-seq macro is what replaced lazy-cons.
I regularily stumble upon the (first (filter predicate coll)) pattern.
Maybe we can add a filter1 for that?
In the Clojure project itself I found this two times, in core.clj for
the ns macro,
and in genclass.clj in find-field.
Also in the clojure-contrib project it shows up two times (again in
I like that Clojure is a dynamically typed language.
Even in dynamic languages it is possible to find out a lot more
about the code itself than one may think on a first glance.
Clojure already supports type hints that can make code run
faster. But what if we could add a soft layer of static
I guess I want to advocate - don't merely replicate the things with
which you are familiar. Try to do things in the Clojure way. If your
logical structure is a mapping of names to values, please use a map.
I tend to replace every instance of creating classes with creating
structs which, if I
Structs are maps with shared keys and positional constructors as Rich
mentions in the original post. I think Rich is saying that maps should
indeed be abused ;) By building all higher level structures on top of
them, consumers are guaranteed not only your custom functionality, but all
the
On Sun, Mar 8, 2009 at 3:15 PM, Phil Hagelberg p...@hagelb.org wrote:
It sounds more likely that your copy of Clojure is out of date. Are you
pulling from the sourceforge SVN by any chance?
It would probably be a good idea to make it so the last commit in the SF
repo is simply a README
Dan redalas...@gmail.com writes:
I guess I want to advocate - don't merely replicate the things with
which you are familiar. Try to do things in the Clojure way. If your
logical structure is a mapping of names to values, please use a map.
I tend to replace every instance of creating classes
Phil,
I am much obliged for the detailed help. I downloaded clojure as the
archive available from google code rather than using svn.
So the docs at http://clojure.org/api are out of date then?
Thanks,
Carl
On Mar 8, 2:15 pm, Phil Hagelberg p...@hagelb.org wrote:
youngblood.carl
I was playing around with some project euler problems, and I was
thinking that the cycle function has an analog for vectors. I
implemented a short simple method with the right behavior (at a simple
surface level):
(defn cyclic-vector [v]
(fn [x]
(v (mod x (count v)
However, this
I'm pretty sure structs are only appropriate for when you need to eek
the absolute last iota of performance out of a collection, in which case
they can provide greater speed than maps. But since the list of keys is
fixed, it means it's more effort to add or rename a key than it is with
a
I'm kind of a newb to these parts, but I disagree somewhat with Phil
that structmaps are only useful as a performance optimization.
It also seems to me that because they make it convenient to create
positional constructors for map structures, they make life much easier
to concisely build data
For your eueler problem consider using lazy functions cycle and range:
user= (take 15 (cycle (range 5)))
(0 1 2 3 4 0 1 2 3 4 0 1 2 3 4)
Or is there some other behavior you need to create?
Regarding proxy your main problem is that IPersistentVector is an
Interface (no implementation) so you
On Mar 8, 2009, at 1:53 PM, Rich Hickey wrote:
First up is contrib.sql, where insert-rows and insert-values both take
a vector of column names followed by vectors of unlabeled values that
must be in the same order as the corresponding columns. I would hope
never to have such fragile things as
On Mar 7, 2009, at 3:53 PM, Mark Engelberg wrote:
Anyone using IntelliJ or Netbeans as their primary development
environment, or is that stuff too experimental?
We've been using enclojure in NetBeans since we started using clojure
seriously. IMO, one should definitely track the hot builds
On Sun, Mar 8, 2009 at 6:13 PM, Dan redalas...@gmail.com wrote:
I'm pretty sure structs are only appropriate for when you need to eek
the absolute last iota of performance out of a collection, in which case
they can provide greater speed than maps. But since the list of keys is
fixed, it
I made an attempt at categorizing all special forms, functions and
macros in clojure.core, plus some outside that namespace. See
http://www.ociweb.com/mark/clojure/ClojureCategorized.html. I'd love
some feedback on the names of the categories and whether I've split
them up correctly. I think a
Exception in thread main java.lang.Exception: Too many arguments to
def (test.clj:26)
both
(def test-list (list (:one :two :three)))
and
(def test-list '(:one :two :three))
and changing the one/two/three into strings also gives me the error on
running. I don't get the error using the REPL.
Exception in thread main java.lang.Exception: Too many arguments to
def (test.clj:26)
both
(def test-list (list (:one :two :three)))
and
(def test-list '(:one :two :three))
and changing the one/two/three into strings also gives me the error on
running. I don't get the error using the REPL.
Mark,
I've thought about doing this in the past (partially for my own
reference) but never got around to it. Thanks so much for your effort!
It might be beneficial to make the function names links to the API
reference. I also found it a little hard when scanning the functions
to clearly
On Mar 8, 2009, at 9:13 PM, Shawn Hoover wrote:
Close... you can assoc new keys into a struct instance, but you
can't dissoc any of the basis keys.
That's right.
Given:
user= (defstruct foo :a :b)
#'user/foo
user= (def t (struct foo 3))
#'user/t
dissoc of a
On Mar 8, 10:10 pm, Stephen C. Gilardi squee...@mac.com wrote:
On Mar 8, 2009, at 9:13 PM, Shawn Hoover wrote:
Close... you can assoc new keys into a struct instance, but you
can't dissoc any of the basis keys.
That's right.
Given:
user= (defstruct foo :a :b)
On Mar 8, 6:17 am, David Powell djpow...@djpowell.net wrote:
Identity is tested first in equality, if identical, equal, full stop.
That's what I'd assumed (it's what the JDK collections do), but
looking at the code, to say, APersistentVectory, I can't see where the
identity test is done?
On Mar 8, 2009, at 9:38 PM, Rich Hickey wrote:
Do you have a case where the map-unpacking dominates the I/O time? Or
is this just a speculative optimization?
I was talking about the distinction between sending N value sets
across the JDBC interface in one call vs. in N calls. Unpacking
I like it; it's making me realize the existence of a bunch of
functions I've never considered before.
If it's practical, consider doing color-coding or somehow indicating
the types of the forms: special forms, macros, and functions. :)
On Mar 8, 6:30 pm, Mark Volkmann r.mark.volkm...@gmail.com
Exception in thread main java.lang.Exception: Too many arguments to
def (test.clj:26)
both
(def test-list (list (:one :two :three)))
and
(def test-list '(:one :two :three))
and changing the one/two/three into strings also gives me the error on
running. I don't get the error using the REPL. Bug?
;;helpers;;
(defn ++ [x]
(inc x))
;;infinite-counting;;
(defn infinite-counting [start]
(while true
(loop [count start]
(println (str count !))
(recur (++ count)
;;fibbonaci;;
; 1 1 2 3 5 8 13 etc. (prevprev + current = next)
(defn count-fibbonaci []
On Mar 8, 2009, at 10:52 PM, Zonbi wrote:
(def list-length [x] Gives the length of a list using 'give-me-
This is the line it's complaining about. The complaint is too many
args to def. You wanted defn there.
--Steve
smime.p7s
Description: S/MIME cryptographic signature
... wow. I really need to fix the line numbers on my Emacs _ Thanks a ton!
On Sun, Mar 8, 2009 at 9:06 PM, Stephen C. Gilardi squee...@mac.com wrote:
On Mar 8, 2009, at 10:52 PM, Zonbi wrote:
(def list-length [x] Gives the length of a list using 'give-me-
This is the line it's
I actually mentioned the cycle function in my message, and that's what
I was using, but the original question came up because accessing the
nth item in a list takes linear rather than constant time.
I'd be interested to hear how what I was attempting violates the
spirit of clojure. I was trying
On Mar 8, 12:53 pm, Rich Hickey richhic...@gmail.com wrote:
Recently it was said in a thread:
You can do a lot of that in Clojure, too, but, unless I'm mistaken,
there are some arbitrary limits as things stand right now. ... you can
have any kind of structure you want, as long as it's a
On Mar 6, 8:06 pm, David Sletten da...@bosatsu.net wrote:
It comes as no surprise that certain numbers cannot be represented by
a finite string of decimal digits. We all realize that 1/3 =
0...., and the ... part is critical. Take it away and the
equality goes away too. In other
66 matches
Mail list logo