Re: FAQ

2008-12-19 Thread Jason
ng results. (Hi all, I'm new to Clojure and this is my first email here ... sorry if this has already been discussed elsewhere) -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" gro

doc strings for multimethods?

2008-12-19 Thread Jason
would be a way to provide doc strings for each method implementation as well, but that seems trickier to fit in the current framework. -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" gr

Re: Blogging About Clojure?

2008-12-19 Thread Jason
ave a one-click wordpress install. I'm not sure how best to post code, but for now simple seems to work OK. -Jason On Dec 16, 11:05 am, Randall R Schulz wrote: > Hi, > > Wordy though I am, I've never done any blogging before, but now that I'm > finally beginning to get up

Re: Blogging About Clojure?

2008-12-19 Thread Jason
reasonably priced in that department. Anyway, I'm not there yet. > htmlize.el works like a dream:http://www.emacswiki.org/emacs/Htmlize Thanks for the tip; I'll definitely check that out. I'd imagine you could paste the generated HTML directly into a wordpress post; have you

Re: doc strings for multimethods?

2008-12-20 Thread Jason
Thanks all. The patch looks interesting to me, although I'd only use it if it was integrated into the main build. -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to t

"Lazy" inconsistency between map and mapcat; lazy concatenation

2008-12-21 Thread Jason
umber of seqs must be known at compile-time (correct?). Perhaps most useful would be a function that takes a lazy seq of lazy seqs, and returns their supremely lazy concatenation. Thanks! Jason --~--~-~--~~~---~--~~ You received this message because you are subscrib

Re: "Lazy" inconsistency between map and mapcat; lazy concatenation

2008-12-21 Thread Jason
ed to explain that the first coll is always "needed" right away. If so, I'm also curious why this is the case. Thanks, Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" gro

Curiosity: why doesn't (count (doall (range 1000000000))) exhaust memory?

2008-12-21 Thread Jason
1 ; now as expected ; Out of memory Thanks, Jason --~--~-~--~~~---~--~~ 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 To unsubscrib

Re: Random Number Generation Issues

2008-12-23 Thread Jason
ndom*)] (if (< x max-val) x (recur)) #'user/my-rand-int user> (my-rand-int 123134202193481203941234192384712938471239841237489123481234812304902349820394812304213481203498) 87828784102811276246738863788257270796166300292074486

Re: Random Number Generation Issues

2008-12-23 Thread Jason
" [n] (int (rand n))) and it looks like (int x) rounds x as I've described: user> (int 139872398412937841234) -451786158 user> (int 12938471928347198.12312) 2147483647 -Jason --~--~-~--~~~---~--~~ You received this message because you are subsc

Questions & workaround regarding Clojure, true laziness, and nil-terminated sequences

2008-12-23 Thread Jason
valuate the concat call until actually needed. Note that the result of delay-seq is a seq-able collection, and no corresponding force call is ever needed. [1] http://w01fe.com/?attachment_id=48 Comments about this are very welcome; this was my first voyage into the internals of Clojure, and I still have l

Bugs in contains? (?)

2009-01-03 Thread Jason
(hash-map [1 2] nil) '(1 2)) false 1:5 user=> (contains? (array-map [1 2] nil) '(1 2)) true As far as I can figure all five of these should return true (the exception is particularly weird). Am I missing something here? Thanks, Jason --~--~-~--~~~---~--~---

Slow nested subvecs (+ fix)

2009-01-03 Thread Jason
end = end + s.start; } else { this.v = v; this.start = start; this.end = end; } } I've tested this a bit and it appears to work properly. Does this seem like a good idea? -Jason --~--~-~--~~---

Re: Bugs in contains? (?)

2009-01-03 Thread Jason
> I believe the exception is expected here due to the implementation of > sorted sets. See this thread for explanation of a similar exception > thrown by a sorted > map:http://groups.google.com/group/clojure/browse_frm/thread/34def2ec6342... OK, that part makes sense to me, tha

Bug in .hashCode for vectors/lists (Old subject: "Bugs in contains? (?))

2009-01-03 Thread Jason
ods for Clojure vectors and lists: user> (.equals [1 2] '(1 2)) true user> (list (.hashCode [1 2]) (.hashCode '(1 2))) (994 -1919631597) Cheers, Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups &quo

Re: Getting Started in Mac OS X Snow Leopard

2009-12-01 Thread Jason
in Aquamacs try coping the code on the ELPA install page and then eval'ing with C-x-e (hold down control key, then type x key and then e key) On Dec 1, 2:30 pm, Charras wrote: > David; > > My problem is that I haven't been able to install the clojure-mode. > What I read is that this is done usin

execute a function once

2011-05-18 Thread Jason
hi I have a small problem.. I want to execute a java init function just once for a scheduler. I have tried defonce and def to do this, this gets the work done but which is the best way to do it. What i actually want is run the function once when the jvm starts up problem with defonce i actually nee

Re: execute a function once

2011-05-18 Thread Jason
thanks i'll try it :) On May 18, 8:28 pm, Ken Wesson wrote: > On Wed, May 18, 2011 at 10:09 AM, Jason wrote: > > hi I have a small problem.. I want to execute a java init function > > just once for a scheduler. I have tried defonce and def to do this, > > this gets

Re: Sample Vaadin application in Clojure

2011-07-02 Thread Jason
you can try the following link https://github.com/hsenid-mobile/clj-vaadin it is a Clojure wrapper written for Vaadin. It's still in its initial stage :) You can check the implantation. -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Clojure Group in Singapore

2011-08-01 Thread Jason
Hi All I just moved to Singapore and I'm looking for a Clojure Group which i can join. Anyone know any? -- 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 ar

Re: Clojure Group in Singapore

2011-08-04 Thread Jason
Hi Zehua Thank you for the reply. I just joined the group. Cheers, Jason -- 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 -

Re: searching for a good name thread-let, thread-with, thread-thru

2011-02-08 Thread Jason
How about (%-> starting-value (foo 3 %) (bar % arg2 arg3)) This combines the standard shorthand argument form from the inline function with the threading. I also like be because the '%' stands out. On Feb 4, 3:05 pm, B Smith-Mannschott wrote: > Clojure's threading macros -> a

Bug in .hashCode for vectors/lists (Old subject: "Bugs in contains? (?))

2009-01-03 Thread Jason Wolfe
truefalse true If it's really by design to violate the Java .hashCode contract, I'd be very interested in hearing why. Cheers, Jason [1] http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Object.html#hashCode() [2] http://java.sun.com/j2se/1.4.2/docs/api/java/util/List.html#has

Re: Bug in .hashCode for vectors/lists (Old subject: "Bugs in contains? (?))

2009-01-03 Thread Jason Wolfe
em, just something that users should be aware of. Perhaps one of the pages on the website (Java interop / data structures?) should mention this? Cheers, Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "

Re: Slow nested subvecs (+ fix)

2009-01-04 Thread Jason Wolfe
their nesting level and periodically flatten themselves so that sequences of add and subvec operations have amortized O(1) time (and use constant memory). I'm not sure if that's even possible though; Clojure has been my first real experience with immutable data structures. Thoughts? Cheer

Re: Slow nested subvecs (+ fix)

2009-01-04 Thread Jason Wolfe
served by PersistentQueues, I don't know. Still, it seems like if vectors could be made more efficient, it couldn't hurt. Thanks, Jason > > > --Chouser > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Go

Re: Questions & workaround regarding Clojure, true laziness, and nil-terminated sequences

2009-01-04 Thread Jason Wolfe
extracted. With either workaround, the built-in seq functions are no longer directly applicable. I can't call filter directly on an mstk, for example. This isn't a big deal, I was mostly just curious why the seq abstraction was set

Re: Functional Shuffle

2009-01-05 Thread Jason Wolfe
)), prev (aget arr i)] (aset arr i (aget arr r)) (aset arr r prev))) (seq arr))) -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: Why aren't lists callable?

2009-01-12 Thread Jason Wolfe
ark")]) {:greet "hello" :farewell "goodbye"}) {:farewell "goodbye Mark", :greet "hello Mark"} -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure&

Utilities for clojure.contrib?

2009-01-12 Thread Jason Wolfe
": Got " '~form " as " (cons '~(first form) (list ~@(rest form) (I have more too, but these are the ones I use most frequently.) Comments/criticisms welcome. Also, many of these are placeholders for more efficient versions, which I

Re: Utilities for clojure.contrib?

2009-01-13 Thread Jason Wolfe
he (reduce (fn [m [k v]] (assoc m k (f v))) {} m) type idioms they replace are much more difficult to read than calls to the utilities IMO. Cheers, Jason map-map --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clo

Profiling Clojure with YourKit: file names and line numbers?

2009-01-13 Thread Jason Wolfe
ne? Or, even better, might it be possible to replace the (gensym?) numbers following anonymous functions with something more meaningful, like fn__ where a is the first function on the line, going from inside-out and then left-to-right? [1] http://www.yourkit.com/eap/inde

Re: Utilities for clojure.contrib?

2009-01-13 Thread Jason Wolfe
your point that having more standardized utilities just means that nobody will ever know them all well. -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send emai

Re: Utilities for clojure.contrib?

2009-01-14 Thread Jason Wolfe
map k v)) (concat deposits withdrawls))) which is considerably uglier and less clear IMO. Any chance of changing merge-with in this way? (Note this is actually similar to clojure.set union/intersection/ difference, which only require that the first e

Re: Utilities for clojure.contrib?

2009-01-14 Thread Jason Wolfe
ut, I agree; the seq/coll distinction can be very confusing at first, especially when faced with seemingly contradictory outputs like user> (= '(1) [1]) true user> (= '() []) false user> {'(1) true} {(1) true} user> (get *1 [1]) true user&g

Re: Utilities for clojure.contrib?

2009-01-14 Thread Jason Wolfe
>>> 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 :). --~--~-~

Multiple hashing functions? (+ bug in PersistentHashMap.java?)

2009-01-14 Thread Jason Wolfe
but for, e.g., Doubles and Integers it may only happen at a single number (if at all).) -Jason [1] http://groups.google.com/group/clojure/browse_thread/thread/5d11bc0da25a7ecc/06d6cd888a516119?hl=en&lnk=gst&q=.hashcode#06d6cd888a516119 [2] http://code.google.com/p/c

Re: Utilities for clojure.contrib?

2009-01-14 Thread Jason Wolfe
, then which value would you use (if two values are my-equal but >> not =)? > > Oh. Good point. I guess I was thinking it would be like > 'merge-with', but if the conflict resolution function returned nil or > false, you'd get back a nil instead of a map. Hmmm, but so

Re: Utilities for clojure.contrib?

2009-01-14 Thread Jason Wolfe
lding up a > bit of a language for whatever problem I'm tackling. (There's the > schemaniac in me again.) There's a golden mean between complexity and > clarity. At first glance, Jason's suggestions seem close to that mean > to me, and I really like what he's done

Re: Bug in .hashCode for vectors/lists (Old subject: "Bugs in contains? (?))

2009-01-15 Thread Jason Wolfe
true and user=> (map #(contains? (hash-set [1 2]) %) '((1 2) [1 2])) (true true) Woohoo, thanks Rich! -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group

Re: Bug in .hashCode for vectors/lists (Old subject: "Bugs in contains? (?))

2009-01-15 Thread Jason Wolfe
Update: Rich just fixed this in http://code.google.com/p/ clojure/issues/detail?id=37&colspec=ID%20Type%20Status%20Priority %20Reporter%20Owner%20Summary">svn 1215 . -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed t

Re: Multiple hashing functions? (+ bug in PersistentHashMap.java?)

2009-01-15 Thread Jason Wolfe
On Jan 14, 6:01 pm, Jason Wolfe wrote: > I've already posted here [1] and on the issue board [2] about > hashing.  In particular, .hashCode for seqs/colls break the Java > contract that whenever (.equals x y), (= (.hashCode x) (.hashCode > y)).  (let x = [1] and y = (se

Re: Utilities for clojure.contrib?

2009-01-15 Thread Jason Wolfe
nt to (replicate (count (remove pred s)) nil). Also, can I do anything to help implement/integrate the changes we've agreed upon thus far? Thanks, Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cl

Re: A quasiquote for Clojure?

2009-01-15 Thread Jason Wolfe
ers. > > Rich I like this a lot. Any chance of getting the same treatment for unquote-splicing? user> '~x (clojure.core/unquote x) user> '~...@x ; Exception: can't embed object in code ; Desired output: (clojure.core/

Re: Utilities for clojure.contrib?

2009-01-15 Thread Jason Wolfe
On Jan 14, 1:03 pm, Jason Wolfe 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

Mysterious performance anomalies

2009-01-15 Thread Jason Wolfe
s" [6000] I'm at a total loss for what's going on. Anyway, I'll stop here for now in case I'm missing something stupid or obvious. Thanks for your help! Jason --~--~-~--~~~---~--~~ You received this message because you are su

Re: Mysterious performance anomalies

2009-01-16 Thread Jason Wolfe
> SVN 1216 - thanks for the report. Thanks for the quick fix! -Jason --~--~-~--~~~---~--~~ 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 T

Re: Utilities for clojure.contrib?

2009-01-16 Thread Jason Wolfe
> > > (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 > > >        (

Re: A quasiquote for Clojure?

2009-01-17 Thread Jason Wolfe
weet, thanks Meikel! Rich, what do you think about integrating this into the trunk? -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegrou

Possible feature: consider aliases when reading namespace-qualified keywords.

2009-01-19 Thread Jason Wolfe
hers think about this? Thanks, Jason --~--~-~--~~~---~--~~ 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 To unsubscribe from this group, send email to

Re: Utilities for clojure.contrib?

2009-01-20 Thread Jason Wolfe
h this and safe-get up by more than a factor of 4! [2] [2] http://w01fe.com/blog/2009/01/more-on-clojure-map-accessor-speeds/ Also, 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 c

Re: Possible feature: consider aliases when reading namespace-qualified keywords.

2009-01-20 Thread Jason Wolfe
ess in the mean-time I could use symbols instead of keywords for my class types. However, I assume that would slow things down substantially (unless method caching would take care of this; I'll have to check on that.) -Jason On Jan 19, 7:49 pm, David Nolen wrote: > My OO example from earli

Re: Utilities for clojure.contrib?

2009-01-20 Thread Jason Wolfe
> I'm sorry, Jason, I really thought I answered this the first time you > asked. But I can't find any such answer in the archives, so I must > have been mistaken. No worries, thanks for all your help with this. >> I can try to make patches for the changes in co

Re: Multiple hashing functions? (+ (update: not a) bug in PersistentHashMap.java?)

2009-01-20 Thread Jason Wolfe
lojure maps implement Java.util.Map, and thus should be using .equals for equality (as they are now). I still might like variants of maps that use identical? or =, but not as the default. -Jason --~--~-~--~~~---~--~~ You received this message because you are sub

Proposal: "smarter" set operations that take size into account for speed

2009-01-20 Thread Jason Wolfe
could argue that the user should know how the operations work and put the arguments in the right (fast) order -- but sometimes, that information will only be known at runtime. Overall, the possibility of a big O improvement for a small constant penalty seems worth it to me. Qu

Re: Proposal: "smarter" set operations that take size into account for speed

2009-01-20 Thread Jason Wolfe
ence "Like difference, but faster." [s1 s2] (if (or (not (set? s2)) (> (int (count s1)) (int (count s2 (clojure.set/difference s1 s2) (difference2 s1 s2))) -Jason --~--~-~--~~~---~--~~ You received this message because you are s

Re: Utilities for clojure.contrib?

2009-01-20 Thread Jason Wolfe
I think Chouser was referring above) was about issues for Clojure core, and whether or not an explicit sign-off from you was desired before they are posted there. This came up in this thread since after discussing with Chouser, several of my utilities seemed better-suited as changes/a

Re: Proposal: "smarter" set operations that take size into account for speed

2009-01-20 Thread Jason Wolfe
apsed time: 20444.035 msecs" ; (clojure.set/union small big) "Elapsed time: 0.956 msecs" ; (clojure.set/union big small) "Elapsed time: 2.906 msecs" ; (fast-union small big) "Elapsed time: 2.826 msecs" ; (fast-union b

Re: Utilities for clojure.contrib?

2009-01-20 Thread Jason Wolfe
ionality. Will you accept issues for any of these? Thanks, Jason --~--~-~--~~~---~--~~ 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 To unsubscribe

Re: Proposal: "smarter" set operations that take size into account for speed

2009-01-20 Thread Jason Wolfe
On Jan 20, 4:44 pm, Jason Wolfe wrote: > Apologies for multiple posts; I will try to thoroughly investigate > things before starting posting next time.  Anyway, to round out the > thread, here are corresponding results for intersection and union: Well, that didn't last too long .

(clojure.contrib.lazy-seqs/combinations) should return [[]], not nil?

2009-01-21 Thread Jason Wolfe
possible values for each variable. If there are no variables, this set should consist of the single "empty binding" rather than "no bindings possible". Will anyone sign off on adding this as a clojure.contrib issue? Thanks, Jason --~--~-~--~~~-

Re: greatest and least

2009-01-21 Thread Jason Wolfe
yours but also things like (random-element (maximal-elements ...)). -Jason On Jan 21, 8:09 pm, Vincent Foley wrote: > A couple months ago, there was a discussion in this group about the > functions max and min and making them work with data types other than > numbers.  I was toying ar

Re: struct question

2009-01-21 Thread Jason Wolfe
4c77f5babf?hl=en&lnk=gst&q=struct#e8e2a14c77f5babf http://groups.google.com/group/clojure/browse_thread/thread/74d430f8e4353725/cc8ad0b22adf60cc?hl=en&lnk=gst&q=struct#cc8ad0b22adf60cc -Jason On Jan 21, 10:48 pm, Mark Engelberg wrote: > Is there any way to determine whether so

Re: struct question

2009-01-21 Thread Jason Wolfe
rsistentStructMap x ) although this is probably not recommended and subject to change at any time. -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email t

Re: struct question

2009-01-22 Thread Jason Wolfe
n, and I'm not sure if this is the most idiomatic way to do things currently. -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure

Re: A nil puzzle

2009-01-23 Thread Jason Wolfe
eral as it will also work with multi-sets): (defn power-set "Returns a lazy seq of possible subvectors of seq s." [s] (loop [s (seq s), sets [[]]] (if s (recur (rest s) (lazy-cat sets (map #(conj % (first s)) sets))) sets))) user> (power-set '(1 1)) ([] [1

Re: A nil puzzle

2009-01-23 Thread Jason Wolfe
re which type). Or, you could just look at Wiki: "the power set of the empty set is the set containing the empty set" http://en.wikipedia.org/wiki/Power_set -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Go

Re: newbie Q: what's wrong with this?

2009-01-23 Thread Jason Wolfe
t other)) total)) 0 more)) #'user/sum user> (sum [1 2 3 4]) 10 (of course, sum could also be defined as just (apply + more) or (reduce + more)). -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google G

Re: (clojure.contrib.lazy-seqs/combinations) should return [[]], not nil?

2009-01-23 Thread Jason Wolfe
empty seq. Anyone willing to sign off?? On Jan 21, 5:34 pm, Jason Wolfe wrote: > I just got bit by (clojure.contrib.lazy-seqs/combinations) returning > nil, not [[]] as I expected.  I could see arguments for either being > the "correct" output, but let me give my case for [[]]

Re: (clojure.contrib.lazy-seqs/combinations) should return [[]], not nil?

2009-01-23 Thread Jason Wolfe
> this. Yes, exactly :) Returning nil for no-args was "hacked on" in a sense, in that the loop would have naturally done the "right thing" otherwise. Issue here: http://code.google.com/p/clojure-contrib/issues/detail?id=6 Thanks, Jason --~--~-~--~~

Re: Possible feature: consider aliases when reading namespace-qualified keywords.

2009-01-23 Thread Jason Wolfe
On Jan 19, 4:29 pm, Jason Wolfe wrote: > I've been doing some OO-type Clojure programming, and have run into > the following (quite minor) annoyance: > > I've defined a struct with a :class of ::Foo in namespace > my.long.namespace.foo. > > In another namespace m

Re: Proposal: "smarter" set operations that take size into account for speed

2009-01-23 Thread Jason Wolfe
OK, if these are not wanted in core right now, will anyone sign off for adding them to clojure.contrib? I can't say I like the idea of having two sets of functions that do exactly the same thing, but ... sometimes you just don't want things to run ~1000 times slower than they shoul

Re: License of/permission for Clojure's logo

2009-01-23 Thread Jason Riedy
And Rich Hickey writes: > You can use the logo on the wikipedia article on Clojure, but only if > you spell my name correctly :) May I use the logo for the identi.ca group? ( http://identi.ca/group/clj ) Jason --~--~-~--~~~---~--~~ You received this m

Re: Proposal: "smarter" set operations that take size into account for speed

2009-01-23 Thread Jason Wolfe
> > On Fri, Jan 23, 2009 at 12:23 PM, Jason Wolfe > wrote: >> >> OK, if these are not wanted in core right now, will anyone sign off >> for adding them to clojure.contrib? >> > > Well, *I* want these changes you've proposed in the core, but of >

Re: Binding values in a list of symbols and evaluating as code

2009-01-23 Thread Jason Wolfe
o it sped the whole application up by about 100 times. Definitely worth doing if you can! -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@

Re: Not nil and 'true' with conditional functions

2009-01-23 Thread Jason Wolfe
Every clojure function returns a value. Even if it is only used for side effects, it still has to return something (probably nil). -Jason On Jan 23, 12:17 pm, wubbie wrote: > Is every function supposed to return something? > Of course, except for pure side-effects. > > -sun >

Re: Proposal: "smarter" set operations that take size into account for speed

2009-01-23 Thread Jason Wolfe
ot= [1 2 3] [2 3 4]) > > No. > > - allow arguments to merge-with after the first to be lists of > pairs. > > No. OK, thanks. -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure"

Re: Proposal: "smarter" set operations that take size into account for speed

2009-01-23 Thread Jason Wolfe
> Hi Jason, > > Thanks very much for all your recent thought, work, and postings. > > I think it makes sense for clojure-contrib to be much more agile in   > accepting new, experimental, and incrementally improved code than   > Clojure proper. Things in contrib are always o

Re: Proposal: "smarter" set operations that take size into account for speed

2009-01-24 Thread Jason Wolfe
for this would be welcome. Finally, I don't know how to make a patch, and found nothing in a quick search of the wiki/newsgroup/website. I heard "Git" floating around somewhere earlier; am I to check out the SVN with git-svn and make a patch that way? -Jason --~--~-~-

Re: Proposal: "smarter" set operations that take size into account for speed

2009-01-24 Thread Jason Wolfe
On Jan 24, 2009, at 6:01 PM, Stephen C. Gilardi wrote: > On Jan 24, 2009, at 8:11 PM, Jason Wolfe wrote: >> Finally, I don't know how to make a patch, and found nothing in a >> quick search of the wiki/newsgroup/website. I heard "Git" floating >> around some

Re: (clojure.contrib.lazy-seqs/combinations) should return [[]], not nil?

2009-01-25 Thread Jason Wolfe
OK, cartesian_product it is. Two comments on your version. First, unlike mine (and the current "combinations"), it takes a single argument, a seq of seqs (rather than multiple seq arguments); which of these ways is preferred? Second, I had the clauses of my for loop backwards, which was slowing

Re: (clojure.contrib.lazy-seqs/combinations) should return [[]], not nil?

2009-01-26 Thread Jason Wolfe
CDEFG"] > > and let me know if you also see the 2x performance difference. Yes, yours runs more than 2x faster on this input. On the other hand, mine runs almost 2x faster on (range 3000) (range 3000) ... As far as I can tell, yours is faster when there are a large number of inp

Re: (clojure.contrib.lazy-seqs/combinations) should return [[]], not nil?

2009-01-26 Thread Jason Wolfe
> Also, it's worth pointing out that your newer version prints the > combinations out in a non-standard order. Good point ... I shouldn't have tried to avoid adding the "let": (defn combinations "Take a seq of seqs and return a lazy list of ordered combinations (pick 1 from each seq)" [seq

Re: (clojure.contrib.lazy-seqs/combinations) should return [[]], not nil?

2009-01-26 Thread Jason Wolfe
usly. Ah, I noticed the unpredictable timings too but didn't make that connection -- thanks. OK, I'm happy to go with your version then :) -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Cl

Re: (clojure.contrib.lazy-seqs/combinations) should return [[]], not nil?

2009-01-26 Thread Jason Wolfe
ive" versions of things I've seen floating around. -Jason --~--~-~--~~~---~--~~ 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 To unsub

Re: repeat and replicate

2009-01-28 Thread Jason Wolfe
> +1 from me, for what it's worth. Ditto. Every time I want replicate, I type "repeat", remember that it only takes 1 arg, and then have to search for "replicate" because the name just won't stick in my head. -Jason --~--~-~--~~~-

Re: Bug with clojure.set/intersection, clojure.set/difference etc.

2009-01-29 Thread Jason Wolfe
and not a promise of the interface". -Jason On Jan 29, 6:42 am, ntu...@googlemail.com wrote: > If its left argument is nil, "intersection" throws a NPE (Clojure rev. 1235): > > user=> (set/intersection nil #{1}) > java.lang.NullPointerException (NO_SOUR

RFC: new clojure.set functions

2009-01-29 Thread Jason Wolfe
up with. They will be a bit slower than "reduce"ing with the current ones (50% or so) when passed several tiny (i.e., 1-element) sets due to the overhead of extracting the big/small element, but as you can see, can be much much faster when there are both big and small sets involved. -J

Re: Alternatives to contains?

2009-01-29 Thread Jason Wolfe
> In that case, it makes me think of the degenerate example (I realize > this is slightly stupid): > > (some #{false} (list false)) Maybe this is an argument for adding "any?" to the list of core functions? -Jason --~--~-~--~~~---~--~~ You

Re: Alternatives to contains?

2009-01-29 Thread Jason Wolfe
except (.contains nil 2) ==> NPE :-) -Jason On Jan 29, 2009, at 3:55 PM, Kevin Downey wrote: > actually rhickey showed up on irc and pointed something out: > > 15:23 rhickey : user=> (.contains [1 2 3] 2) > 15:23 rhickey : true > 15:23 rhickey : user=> (.conta

Re: Documentation of lazy-cat should contain a warning

2009-01-30 Thread Jason Wolfe
whether to return an Object representing a non-empty seq, or nil, even if you never explicitly ask for any of the elements of the returned seq. This means evaluating each of its arguments in turn until it finds an argument x for which (seq x) is non-nil. HTH, Jason On Jan 30, 3:55 pm, André Thi

Re: Documentation of lazy-cat should contain a warning

2009-01-30 Thread Jason Wolfe
sed to it. Hmm, I don't think this is it. For instance, (take 0 (lazy-cons (prn "asdf") nil)) prints nothing. (Lazy-cons doesn't need to evaluate things up-front like lazy-cat, since lazy-cons always returns a (non-empty) seq with at least one element). -Jason --~--~---

Bug or desired behavior: "contains?" doesn't seem to work on java.util.Sets.

2009-01-30 Thread Jason Wolfe
ins? s "test")) false user> (let [s (HashSet.)] (.add s "test") (contains? (set s) "test")) true Bug or desired behavior? Thanks, Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups

Re: RFC: new clojure.set functions

2009-01-31 Thread Jason Wolfe
ets, it makes sense to always iterate through the smaller argument. This makes a huge speed difference when you have one small set and one big set, as you can see in the timings I included. -Jason --~--~-~--~~~---~--~~ You received this message because yo

Re: into vs. clojure.set/union

2009-01-31 Thread Jason Wolfe
maller than the other (s). - Works on any number of arguments (including 0/1). -Jason [1] http://groups.google.com/group/clojure/browse_thread/thread/b35ca9035762e1a4?hl=en# On Jan 31, 5:56 pm, Mark Volkmann wrote: > What's the difference between into and clojure.set/union? While their

Re: Why Isn't This Working

2009-01-31 Thread Jason Wolfe
output of for, so they'll be equivalent). -Jason --~--~-~--~~~---~--~~ 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 To unsubscribe from this gro

Re: meaning of coll

2009-01-31 Thread Jason Wolfe
ot;key" and the value with "second" or "val", although the latter options will tend to be much faster. You can also destructure: (some (fn [[k v]] (= k v)) {:a 2 :b :b}) ==> true -Jason --~--~-~--~~~---~--~~ You received this message

Re: meaning of coll

2009-01-31 Thread Jason Wolfe
icitly call seq on them first): user> (into [4] (.toArray [1 2 3])) [4 1 2 3] user> (into (.toArray [1 2 3]) [4]) ; ClassCastException user> (into (seq (.toArray [1 2 3])) [4]) (4 1 2 3) -Jason --~--~-~--~~~---~--~~ You received this message because you are

Re: what does -> mean?

2009-01-31 Thread Jason Wolfe
On Jan 31, 7:09 pm, wubbie wrote: > Hi, > > I saw in ants.clj a notation (->). > what is it? > For example, > (defn place [[x y]] >   (-> world (nth x) (nth y))) Did you check the docs? On the website: http://clojure.org/API#toc21 Within clojure itself: user> (doc ->)

Re: Turning a sequence of chars into a string.

2009-02-01 Thread Jason Wolfe
ot;&" in your fn arglist, the remaining arguments are bound to it as a lazy seq. On each call, only as many arguments as you explicitly declare are actually evaluated. -Jason --~--~-~--~~~---~--~~ You received this message because you are subscribed to

  1   2   3   4   5   6   7   >