On Mar 9, 1:19 am, Mark Engelberg wrote:
> On Sun, Mar 8, 2009 at 10:44 PM, mikel wrote:
> > Clojure doesn't have to provide these facilities (though I wouldn't
> > mind if it did); it just needs to stay out of my way when I decide I
> > need to add them.
>
> Yeah, as much as I like maps, I fe
On Sun, Mar 8, 2009 at 10:44 PM, mikel wrote:
> Clojure doesn't have to provide these facilities (though I wouldn't
> mind if it did); it just needs to stay out of my way when I decide I
> need to add them.
Yeah, as much as I like maps, I feel like there are several common
uses cases for maps th
On Mar 8, 5:30 pm, Mark Volkmann wrote:
> I made an attempt at categorizing all special forms, functions and
> macros in clojure.core, plus some outside that namespace.
> Seehttp://www.ociweb.com/mark/clojure/ClojureCategorized.html. I'd love
> some feedback on the names of the categories and wh
On Mar 6, 8:06 pm, David Sletten 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 words, if that
On Mar 8, 12:53 pm, Rich Hickey 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 map, set, or
> 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 t
... 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 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 complaining abou
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
;;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 []
(
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
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 wrote:
> I made an attempt
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 maps
On Mar 8, 6:17 am, David Powell 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? Am I looking in
On Mar 8, 10:10 pm, "Stephen C. Gilardi" 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)
> #'user/fo
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
On Mar 8, 10:53 am, Rich Hickey wrote:>
> 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 a map.
One time I find myself abusing vectors where maps would be better is
in a situation where I have to retrieve key/value pair
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, 9:05 pm, "Stephen C. Gilardi" wrote:
> 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 correspondi
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. Bu
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. Bu
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 bre
On Sun, Mar 8, 2009 at 6:13 PM, Dan 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 means it's
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" bui
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 t
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 woul
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 str
> 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 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 obviou
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 wrote:
> "youngblood.carl" writes:
> > Thanks Lucio,
Dan 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 with creatin
On Sun, Mar 8, 2009 at 3:15 PM, Phil Hagelberg 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 saying "don't us
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 func
> 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 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 typing
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
the
"youngblood.carl" 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. Swank-clojure *has* been
On 7 Mrz., 18:38, Meikel Brandmeyer 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 plac
On 8 Mrz., 13:40, Mark Volkmann 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 dosync.
Hi Mark.
I und
On Mar 8, 1:53 pm, Rich Hickey 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 of Steve Yegge's ar
Thanks for linking Clojure Box, that is cool.
If anyone wants to try my fix I've branched swank-clojure on github
and committed the change.
http://github.com/doncarlosx/swank-clojure/tree/master
On Mar 8, 9:39 am, christophe turle wrote:
> Same problem here.
>
> my solution : i'm currently usi
On Mar 5, 4:23 pm, Paul Stadig 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 Clojure codebas
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
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 a
my try :
;;; *** application code ***
;;; (my-capitalize "ab c") -> "Ab C"
;;; (my-capitalize "ab") -> "Ab"
;;; (my-capitalize "") -> ""
;;; (def s "ab c")
(defn my-capitalize [s]
(words->string (map capitalize (string->words s))) )
;;; *** libraries code ***
;;; (string->words "") -> []
On Mar 8, 9:39 am, David Sletten 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
--~--~-
On Sun, Mar 8, 2009 at 9:26 AM, Itay Maman wrote:
>
> What's the shortest way for capitalizing the first letter of every
> word, i.e.: (assert (= (capitalize "ab cd") "Ab Cd")) ?
(use '[clojure.contrib.str-utils :only (re-gsub)])
(defn capitalize [s]
(re-gsub #"\b." #(.toUpperCase %) s))
--C
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]
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 clojure@googleg
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
*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 YAHO
*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 YAHO
*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 YAHO
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 Traine
*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 YAHO
*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 YAHO
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
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
wrote:
>
> Thanks Lucio, but you can see on git-hub that the head version of
> core.clj uses lazy-seq:
>
>
> http://github
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 wrote:
> First of all, make sure you use the latest versions of slime, cloj
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 -
http://github.com/
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
--~--~
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 wrote:
>
> Is there a function to capitalize the first letter of a string or a
> better way t
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.
--~--~-~-
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 m
On Sun, Mar 8, 2009 at 6:48 AM, Meikel Brandmeyer 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 no
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 not. I would
prefer laziness over speed.
Sincerely
Meikel
smime.p7s
Desc
On Mar 8, 6:20 am, Meikel Brandmeyer 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 supply
> 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 . .
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 Clo
(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
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 ite
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)
(fo
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
> 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
--~--~-~--~-
You're absolutely right...
user=> (time (let [[a b] (separate even? (range 100))] (nth a 3)))
"Elapsed time: 0.115 msecs"
6
user=> (time (let [[a b] (filt-split even? (range 100))] (nth a 3)))
"Elapsed time: 413.614 msecs"
6
and is also more efficient over large sequences...
(time (let
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 in
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
>
> That
76 matches
Mail list logo