Re: Clojure desktop wallpaper request/discussion

2009-03-02 Thread Chouser
I'm not big on wallpaper but graphics are fun and I had a couple ideas... http://clojure.googlegroups.com/web/clojure-wallpaper-02.png http://clojure.googlegroups.com/web/clojure-wallpaper-03.png --Chouser --~--~-~--~~~---~--~~ You received this message

Re: new Clojure article

2009-03-02 Thread Chouser
x (nth), while lists provide only linear-time lookup by index. Lists provide no convenient or efficient mechanism for "changing" a value in the middle, while vectors provide essentially constant-time 'assoc' for any existing position. --Chouser --~--~-~--~~--

Re: Roman Numerals

2009-03-03 Thread Chouser
>                                                              num-list)) >                                 (arabic-to-roman n tail )) You might consider using 'reduce' instead of recursion here. Alternatively, it's interesting to note that because of the ease wit

Re: doall, dorun, doseq, for

2009-03-03 Thread Chouser
t's a more convenient way to express the lazy seq you want than the equivalent combination of map, filter, take-while, etc. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: doall, dorun, doseq, for

2009-03-03 Thread Chouser
tc. > > I must confess, I almost never used for... Maybe I should > try to use it more often. I like 'for' when I need nested behavior: (for [x '(a b c), y '(d e f)] [x y]) vs. (mapcat (fn [x] (map #(vector x %) '(d e f)))

Re: doall, dorun, doseq, for

2009-03-03 Thread Chouser
1000)] (inc i))) The results would be the same, but dorun requires 'map', which creates another seq. 'doseq' is able to accomplish the same work with less allocation. user=> (time (f)) "Elapsed time: 1685.796066 msecs" user=&

Re: Question on names of errors in error-kit

2009-03-03 Thread Chouser
ook with earmuffs, and didn't change them. I'm hesitant to remove them because I like how they stand out in the code. Perhaps it's not really necessary, or perhaps there's a better naming convention we could use? Any thoughts? --Chouser --~--~-~--~~~

Re: Question on names of errors in error-kit

2009-03-03 Thread Chouser
t; error this way, but I intend to keep on wrapping my errors in earmuffs :) Since earmuffs already mean something different, perhaps there's something else that would work? Maybe capitals, because they're a kind of type name? Error, O

Re: Roman Numerals

2009-03-04 Thread Chouser
(>= n arabic) determines whether we continue working with the > original num-list or proceed to the tail. I'm not sure of how to get > that behavior with "reduce". You're absolutely right, 'reduce' will not work here. I missed that the 'if' was making t

Re: Question on names of errors in error-kit

2009-03-04 Thread Chouser
if you were using the name '*error*' directly. --Chouser --~--~-~--~~~---~--~~ 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 unsubs

Re: :use feature requests

2009-03-04 Thread Chouser
l alias *and* the fact that all the util names were refer'ed in. I dare say that would not break much existing code, and if it did would be easy to track down and fix (by simply adding :all). --Chouser --~--~-~--~~~---~--~~ You received this message because you

Re: :use feature requests

2009-03-05 Thread Chouser
On Thu, Mar 5, 2009 at 12:00 AM, Stephen C. Gilardi wrote: > > On Mar 4, 2009, at 11:46 PM, Chouser wrote: > >> Adding an :all option as Steve suggests would clean this up even more: >> >>  (ns util >>   (:use [really.long.namespace.util :as util :all])) >

Re: :use feature requests

2009-03-05 Thread Chouser
On Thu, Mar 5, 2009 at 9:00 AM, Stephen C. Gilardi wrote: > > On Mar 5, 2009, at 8:50 AM, Chouser wrote: > >> Aren't there already no-arg options like :reload and :verbose? > > Those apply to the entire :use or :require clause. They are flags that are > peers w

Re: conj questions

2009-03-06 Thread Chouser
ems to call itself > recursively with the exact same arguments. How does that ever > terminate? You're probably getting confused by the old-style Java interop syntax. (. clojure.lang.RT (conj coll x)) is the same as: (clojure.lang.RT/conj coll x) --Chouser --~--~-~--~~-

Re: Clojure infinite loop

2009-03-06 Thread Chouser
d me to type > "(System/exit 0)" which will call the java.lang.System.exit method and > terminate the program. This seems to work for me. On windows, Ctrl-Z works as well. This is the normal end-of-file pattern on Windows. That's Ctrl and Z

Re: Missing function?

2009-03-06 Thread Chouser
latest release, not the latest SVN HEAD (with a few exceptions). You're probably looking for 'fnext': user=> (doc fnext) - clojure.core/fnext ([x]) Same as (first (next x)) nil --Chouser --~--~-~--~~~---~--~~ You rece

Re: Clojure infinite loop

2009-03-06 Thread Chouser
or you to decide. Please let me know if this fails in some case, or even more importantly if it causes any kind of breakage. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to

Re: Capitalize string

2009-03-08 Thread Chouser
] (re-gsub #"\b." #(.toUpperCase %) s)) --Chouser --~--~-~--~~~---~--~~ 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

Re: hash-map based on identity

2009-03-09 Thread Chouser
jure. > > Issue/patch welcome. I've created an issue, just so we don't lose track of this, but I'm not writing a patch at the moment. This is probably some nice low-hanging fruit for someone who has sent in their CA and is interested in starting to get p

Re: Macros problem

2009-03-10 Thread Chouser
(let [rcode (reverse code)] `(let [func# (to-fn ~rcode)] (run-example func# Also, try to avoid using builtin names like 'fn' for your own locals. It only leads to more pain in the long run. --Chouser --~--~-~--~~~---~--~~ You received this mes

Re: filter1 interesting?

2009-03-10 Thread Chouser
On Tue, Mar 10, 2009 at 9:03 PM, e wrote: > seems like a good reason all predicates should be required to return their > argument, contractually. You'd have some trouble with 'nil?' and 'false?' at the very least. --Chouser --~--~-~--~~---

Re: On the importance of recognizing and using maps

2009-03-11 Thread Chouser
asses than the Python equivalent -- you start with the data you actually need, and can add "methods", polymorphism, etc. if needed later. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojur

Re: Performance tips for Clojure

2009-03-12 Thread Chouser
ange 100))) ==> "Elapsed time: 147.096976 msecs" The amount of time it takes to build the vector goes up significantly, but the timed part, calling 'rest' a million times, doesn't take anywhere near 100 times longer. --Chouser --~--~-~--~~---

Re: filter1 interesting?

2009-03-16 Thread Chouser
; nil Thus for some coll, the new (first coll) would *not* be the same as (first identity coll). --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send ema

Re: Going to ILC 2009?

2009-03-18 Thread Chouser
ssume it's far too late to order one now: http://www.zazzle.com/clojure --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googleg

Re: The unshared part of two mostly-shared structures

2009-03-21 Thread Chouser
ould return a map c such that (merge a c) would produce a value equal to b again. But for course this can't be as 'merge' never removes an entry. An option that would work (but doesn't strike me as terribly elegant) would be for (diff a b) to return [c d], such that: (= b

Re: Why not "sorted-set-by"?

2009-03-25 Thread Chouser
) (comparator [] (.comparator impl)) (entryKey [e] e) (seq ([] (keys impl)) ([asc] (keys (.seq impl asc (seqFrom [k asc] (keys (.seqFrom impl k asc) nil (apply sorted-map-by cmp (interleave items items user=> (sorted

Re: How to flatten a coll only 1 level deep?

2009-04-08 Thread Chouser
the seq library and I've studied > the code for flatten and tree-seq to look for hints but so far I can't > see the way to do this. Can anyone help? (defn flat1 [coll] (mapcat #(if (coll? %) % [%]) coll)) (flat1 [ 1 2 3 [4 5 [6 7] ] ]) --Chouser --~--~-~--~~---

Re: clojure.contrib.lazy-xml/parse-trim forces parsing whole input

2009-04-08 Thread Chouser
nce the siblings function loops lazily over > all the input from parse-seq, it seems logical that calling "last" on > its result should not be done right away. Thanks for the report. I've checked in a change (rev 656) that I think will solve t

Re: The :file metadata key value

2009-04-14 Thread Chouser
ure.contrib.repl-utils library, for example, now fails to get the > source code of the core functions (I remember the function was working > before). I've fixed repl-utils/source in contrib 667. Thanks for the report. --Chouser --~--~-~--~~~---~--~~ You re

Re: How to abort a long running operation at the SLIME REPL?

2009-04-15 Thread Chouser
thanks for the report. Fixed in contrib 669 --Chouser --~--~-~--~~~---~--~~ 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 grou

Re: clojure.contrib.repl-utils.show and bigint

2009-04-22 Thread Chouser
igint': user=> (source bigint) (defn bigint "Coerce to BigInteger" {:tag BigInteger} [x] (cond (instance? BigInteger x) x (decimal? x) (.toBigInteger #^BigDecimal x) (number? x) (BigInteger/valueOf (long x)) :else (BigInteger. x))) nil --Chouser --~-

Re: ICFP 2009

2009-04-22 Thread Chouser
talk anybody else into helping: https://projects.cecs.pdx.edu/~jgmorris/icfpc08/index.cgi/wiki/TeamPages#Chouser --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email

Re: error-kit: passing a variable error type into a handle statement

2009-05-18 Thread Chouser
ith-handler (raise parse-error) (handle {tag :tag :as this-err} (if (isa? tag error-type) (prn :caught this-err) (do-not-handle) --Chouser --~--~-~--~~~---~--~~ You received this message because you are su

Re: macro issue

2009-05-20 Thread Chouser
macro) is built on create-struct (a function): (defmacro def-fields [name tgs] `(def ~name (apply create-struct (map keyword ~tgs user=> (def tags ["name" "age"]) #'user/tags user=> (def-fields fs tags) #'user/fs user=> (def testfs (struct fs "

Re: Call for Help!: Clojure Code for JavaOne Talk

2009-05-21 Thread Chouser
win here if you care only about speed. This one is more than 5 times faster than the original reverse-num: (defn reverse-num [n] (loop [nrem (int n), rev (int 0)] (if (zero? nrem) (+ n rev) (recur (int (quot nrem 10)) (int (+ (* 10 rev) (rem nrem 10))) --Chouse

Re: Call for Help!: Clojure Code for JavaOne Talk

2009-05-23 Thread Chouser
ctions. There's a nice blog post here that covers several options for how to put together related functions: http://programming-puzzler.blogspot.com/2009/04/adts-in-clojure.html --Chouser --~--~-~--~~~---~--~~ You received this message because you ar

Re: off topic - sending and receiving raw Ethernet frames from clojure/java

2009-05-24 Thread Chouser
; conclusion was the same - not possible without JNI or using jpcap... Allow me to toss in the idea of JNA here. I don't know if it would be easier to use han jpcap, but it might we worth looking at. And if you're going to look at JNA, allow me a shameless plug: http://git

Re: some vs. every?

2009-05-26 Thread Chouser
to behave this way in the future?  If > so, it seems like a bad alias for (first (filter...)) It's not an alias for (first (filter ...)), bad or otherwise: user=> (some #(when (even? %) (/ % 2)) [1 3 5 6]) 3 user=> (first (filter #(when (even? %) (/ % 2)) [1 3 5 6])) 6 They behave dif

Re: (gensym) not equivalent to #?

2009-05-28 Thread Chouser
uto) (foo__425__auto__) user=> (f-auto) (foo__425__auto__) user=> (f-auto) (foo__425__auto__) Thanks for bringing this up. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: "run" macro for "executable namespaces"

2009-06-02 Thread Chouser
ke you're using a function named "main" that expects symbol, string, etc. args. I assume this difference is intentional? --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" gr

Re: A few ideas

2009-06-04 Thread Chouser
structs that are perhaps getting in the way of smaller improvemnts. http://code.google.com/p/clojure/issues/detail?id=46 For example, defstruct could define a Java class with named accessors (and "mutators"?) for the given fields. --Chouser --~--~-~--~~~-

Re: clojure.contrib.except enhanced

2009-06-06 Thread Chouser
as incorrect:" e I suppose the catch clause could be augmented: (tryf (foo -5 10) (catchf [e] (isa? ::Args (:source e)) (printf "Argument was incorrect:" e))) ...or something. Any thoughts? --Chouser --~--~-~--~~~---~--~~ You r

Re: Why is this using reflection?

2009-06-08 Thread Chouser
n that, you need to hint the function itself: (defn #^String searcher-path [#^IndexSearcher searcher] (let [#^FSDirectory fsdir (.. searcher getIndexReader directory)] (.. fsdir getFile getPath))) user=> (expression-info '(searcher-path nil)) {:class java.lang.String, :primit

Re: Artificial Intelligence in Clojure

2009-06-08 Thread Chouser
tions, which have been discussed in the group several times. I think there are a couple different implementations that may have useful ideas for you. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "C

Re: Simple idiom in clojure, mutate a value

2009-06-11 Thread Chouser
"Read a file and return a vector of its records." [fpath] (with-open [r (BufferedReader. (FileReader. (File. fpath)))] (vec (map do-something-with (next ; discard first line (line-seq r)) --Chouser --~--~-~--~~--

Re: A text about Clojure

2009-06-12 Thread Chouser
t was interesting to read about your experiences and opinions. --Chouser --~--~-~--~~~---~--~~ 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

Re: Lazy load of imports

2009-06-12 Thread Chouser
etty painful depending on what you're actually doing, so if I were you I'd try new-by-name first and only if you're sure it's too slow would I try another option. --Chouser --~--~-~--~~~---~--~~ You received this message because you are

Re: do-asynch-periodically

2009-06-12 Thread Chouser
ly [nm interval & body] >  `(defdaemon ~nm >     (loop [] >       (Thread/sleep (* 1000 ~interval)) >       ~...@body >       (recur The 'recur' will loop to the enclosing function if no 'loop' is given, so in this case you could leave out the '

Re: do-asynch-periodically

2009-06-12 Thread Chouser
the var is interned in the namespace at compile time. This is true of all macros that expand to 'def', not just 'defonce'. That's one of the reasons that using 'def' other than at the top level is suspect. --Chouser --~--~-~--~~~-

Re: breaking early from a "tight loop"

2009-06-15 Thread Chouser
10) (inc counter) counter)) 0 (iterate dec 15))) --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.c

Re: Best way to augment core functions to support other data types?

2009-06-16 Thread Chouser
ons on it, proxy will probably work nicely for you. The core functions generally depend on specific Java interfaces that are defined in the clojure.lang package, and wrapping a proxy around that is usually pretty easy. --Chouser --~--~-~--~~~---~--~~ You received this mes

Re: Apply a function to some values in a map

2009-06-18 Thread Chouser
ke to admit staring at "(merge-with + map ..." trying to figure out what merge-with was going to do with a second function parameter. When I re-use names like that I always end up confusing myself eventually. --Chouser --~--~-~--~~~---~--~~ You receiv

Re: Which map access is more idiomatic

2009-06-19 Thread Chouser
keyword I'll usually put it first, if key is not a keyword and map is more complex that a simple local or var I'll usually use 'get'. An example of that last point, I think: (@(:state-map my-obj) field-id-num) is more confusing than:

Re: Type hints on primities

2009-06-19 Thread Chouser
gt; {:class java.lang.Integer, :primitive? false} (expression-info '(let [x 5] (.shortValue #^Integer x))) ==> {:class short, :primitive? true} (expression-info '(let [x 5] x)) ==> {:class java.lang.Integer, :primitive? false} Hope that helps, --Chouser --~--~-~--

Re: Code generation at runtime

2009-06-22 Thread Chouser
e of 'binding' would have any purpose. Perhaps it would be worth your time to review http://clojure.org/vars --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to thi

Re: Was it decided to add these functions to core?

2009-06-23 Thread Chouser
; even numbers (range 1 :forever 2) ; odd numbers --Chouser --~--~-~--~~~---~--~~ 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

Re: Was it decided to add these functions to core?

2009-06-23 Thread Chouser
On Tue, Jun 23, 2009 at 5:15 PM, Stephen C. Gilardi wrote: > > On Jun 23, 2009, at 2:07 PM, Chouser wrote: > >> >> On Tue, Jun 23, 2009 at 1:09 PM, CuppoJava >> wrote: >>> >>> (iterate inc 0) >> >> Just riffing here, but what if range to

Re: Concatenating Regexes?

2009-06-24 Thread Chouser
ple: (use '[clojure.contrib.str-utils :only [str-join]]) (defn my-regex [words] (re-pattern (str #"(.*?)" ; stands alone, so #"" works "(\\((?:" ; regular string, so \ must be escaped (str-join "|" words) ").*)")

Re: Improved Error Messages - Part XXXVIII

2009-06-25 Thread Chouser
a.lang.IllegalArgumentException: No matching method found: abs > (NO_SOURCE_FILE:0) > ;; abs wont work on ratios, but the error message doesn't give the > signature being sought. > ;; abs for java numbers exists, abs for ratios doesn't. > ;; It is not a

Re: Improved Error Messages - Part XXXVIII

2009-06-25 Thread Chouser
s could be caught at read time, just by having the Map classes complain about non-even-length init arrays. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, sen

Re: Concatenating Regexes?

2009-06-25 Thread Chouser
On Wed, Jun 24, 2009 at 9:04 PM, Chouser wrote: > On Wed, Jun 24, 2009 at 6:13 PM, CuppoJava wrote: >> >> I need to dynamically create a regex, and would really like to be able >> to use Clojure's built-in regex syntax. But I don't know how to go >> about i

Re: HOWTO: Update the docs on clojure.org?

2009-06-25 Thread Chouser
thnext) in early Feb 2009. Fixed, thanks. --Chouser --~--~-~--~~~---~--~~ 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 mem

Re: Printing and reading a function

2009-06-25 Thread Chouser
;proxy'. ...but even once you've captured the code used to define a fn, I'm not sure how much good it's going to do you. That metadata won't include anything about the lexical environment in which the fn was defined, the values of any closed-over locals, etc. --Chouser

java.ext.dirs problem

2009-06-26 Thread Chouser
simplest way I've found to produce the error I'm seeing: 1. Compile clojure-contrib 2. Create a "classpaths" directory with symlink to clojure-contrib/classes, so as to add the compiled contrib classes to the classpath. Mine lookes like this: $ ls -l classpaths/

Re: java.ext.dirs problem

2009-06-27 Thread Chouser
ication project I'm working on. In either case, it can contain a link to the specific clojure jar I want. For example, cp-1.0 can include links to both clojure-1.0.jar and the 1.0 branch of contrib (once it exists), while clojure-master can include links to the lastest pull of

Re: ANN: libraries promoted from contrib to clojure

2009-06-29 Thread Chouser
that expands to either the old or new 'are' syntax, depending on the Clojure version runnin. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send ema

Re: Clojure only (in-memory) database / locking granularity

2009-06-30 Thread Chouser
; mutating access to any one of those relations. With either of the layouts I mentioned, this kind of multi-relation transaction ought to allow Clojure STM to really shine when compared to a more naive locking scheme. --Chouser --~--~-~--~~~---~--~~ You received

Re: Displaying Clojure code on a Website

2009-07-01 Thread Chouser
could similarly use maps for 'html-entity' and 'html-whitespace' -- 'get' accepts a default value, which might be useful here. ...and now that I'm looking at it, I think even 'whitespace?' could be just: (def whitespace? #

Re: print-base / print-radix?

2009-07-02 Thread Chouser
ot; 255) "377" user=> (format "%x" 255) "ff" user=> (format "%X" 255) "FF" --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group.

Re: Contrib branch compatible with Clojure 1.0

2009-07-02 Thread Chouser
what it's called, I'm grateful someone has done it. Thanks again, Stuart! --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@goog

Re: Return nil/null or empty object

2009-07-02 Thread Chouser
rn an empty vector rather than nil. Conversely, if 3 seem more important in your case, it's like you're could you 'when' in your API code, which returns nil (not an empty collection) in false cases. --Chouser --~--~-~--~~~---~--~~ You received this

Re: Mysterious ClassFormatError after simple code change.

2009-07-06 Thread Chouser
he return values of any of the functions called in your examples? --Chouser --~--~-~--~~~---~--~~ 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

Re: Is this unquote dangerous?

2009-07-06 Thread Chouser
is fine -- are you writing a macro? If some-symbol is not referring to a Var, though, it's more likely you want a regular quote than a syntax quote, in which case it may be more idiomatic to build a vector: (for [x [1 2 3]] ['some-symbol x]) Or if you really do need a list: (for [x

Re: Is this unquote dangerous?

2009-07-06 Thread Chouser
On Mon, Jul 6, 2009 at 4:18 PM, Meikel Brandmeyer wrote: > Hi, > > Am 06.07.2009 um 22:00 schrieb Chouser: > >> Or if you really do need a list: >> >>  (for [x [1 2 3]] (cons 'some-symbol (list x))) > > o.O > > *cough*(list 'some-symbol

Re: Questions / guidelines for adopting Clojure

2009-07-07 Thread Chouser
ode that I want to factor out but for which functions are insufficient. I know that's a bit vague, but I'm not sure how else to generalize it. Another common use case is to move certain kinds of lookups or computation from runtime to compile time. --Chouser --~--~-~--~~--

Re: Calling static methods on a variable holding a class

2009-07-08 Thread Chouser
r example) things get more complicated. You may be able to pass around a map of fns, perhaps assisted by a macro. ...or you may decide that reflection is better after all. (map-things {:foo #(MyClass/foo %) :bar #(MyClass/bar %)

Re: Trouble specifying a gen-class constructor taking an argument of the class being created

2009-07-08 Thread Chouser
is: http://www.assembla.com/spaces/clojure/tickets/84 --Chouser --~--~-~--~~~---~--~~ 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

Re: Idea for contrib.def: defmemo

2009-07-09 Thread Chouser
th docstrings to (def {:doc docstring} function > (memoize (fn ...)))s. Would this be useful for anyone else? Good idea. http://www.assembla.com/spaces/clojure-contrib/tickets/5-def--Add-defn-memo --Chouser --~--~-~--~~~---~--~~ You received this message because yo

Re: From Java to Clojure

2009-07-09 Thread Chouser
nd sometimes faster to use 'zero?', so perhaps: (if-not (zero? freq) freq (compare val1 val2)) > (defn -orderByFreq [_ coll] >  (if (empty? coll) () (keys (sort cmpr (count-words coll) Do you need to return an empty seq? If not, how about: (when

Re: Homoiconicity and printing functions

2009-07-09 Thread Chouser
s constructor. There's no syntax supporting it directly, but you can get at it from Java, gen-class, or proxy: (def add (proxy [clojure.lang.AFn] [{:i-has "metadata!"}] (invoke [a b] (+ a b user=> (add 2 5) 7 user=> ^add {:i-has "metadata!"} --Chouser --~

Re: *math-context*

2009-07-10 Thread Chouser
/clojure/tickets/137 --Chouser --~--~-~--~~~---~--~~ 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: Clojure in Clojure?

2009-07-10 Thread Chouser
Being > JVM-hosted has its advantages. I don't think Clojure will be abandoning the JVM any time soon. There's not been a lot of specifics anywhere about what Clojure-in-Clojure actually is, so I wrote up what I think I know. I hope it helps: http://blog.n

Re: Clojure vectors

2009-07-13 Thread Chouser
so knows its size and supports 'conj', 'pop', and 'peek': user=> (class '(3 2 1)) clojure.lang.PersistentList user=> (conj '(3 2 1) 4) (4 3 2 1) user=> (peek '(3 2 1)) 3 user=> (pop '(3 2 1)) (2 1) --Chouser --~--~-~--~~-

Re: Bug with struct-maps and *print-dup*

2009-07-13 Thread Chouser
emporarily patch clojure.lang.PersistentTreeMap/create to produce hash-maps. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@google

Re: another binding issue?

2009-07-14 Thread Chouser
ted result, simply force the seq to be realized before you return it, such as with doall, or put it into a non-lazy collection, such as with vec. user=> (binding [a 3] (doall (filter #(= % a) '(1 2 3 (3) --Chouser --~--~-~--~~~---~--~~ You received thi

Re: Clojure vectors

2009-07-15 Thread Chouser
ec of a subvec points directly at the new start and end > bounds for the original vector. Your original statement was true prior to Feb 28. Thanks for checking! --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google G

Re: Experiment with named args

2009-07-17 Thread Chouser
On Fri, Jul 17, 2009 at 11:21 AM, Mark Addleman wrote: > > On Jul 17, 2:35 am, Nicolas Oury wrote: >> Hello, >> >> Can this construct handle higher-order functions? > > Nope :) > > Chouser brought up this point in IRC.  It's not even clear what the >

Re: Experiment with named args

2009-07-17 Thread Chouser
On Fri, Jul 17, 2009 at 12:17 PM, Laurent PETIT wrote: > > 2009/7/17 Chouser >> >> On Fri, Jul 17, 2009 at 11:21 AM, Mark >> Addleman wrote: >> > >> > On Jul 17, 2:35 am, Nicolas Oury wrote: >> >> Hello, >> >> >

Re: Protocol question: donating code to clojure-contrib

2009-07-21 Thread Chouser
's best to hold off creating a ticket until a contrib committer asks for one. Would your code fit best with str-utils or str-utils2, do you think? --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "

Re: Can (genclass) be changed to operate when not compiling?

2009-07-21 Thread Chouser
nfortunately, it causes problems because named classes can't be changed once they're loaded in the JVM. I think there are also classloader issues that I don't yet fully understand. Named classes and named interfaces must be created before the

Re: Clojure as a CGI language?

2009-07-22 Thread Chouser
or a more expensive service: Java servlet container provider, private virtual machine, co-locate, or on up from there. --Chouser --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this

Re: a regular expression for matching and for generating?

2009-07-29 Thread Chouser
reuse that pattern to generate a text that replaces the groups > like this: > > user=> (re-gen pat "foo-gen" "bar-gen") > "foo=foo-gen;bar=bar-gen" (def my-keys (map second (re-seq #"(.*?)=(.*?);" "foo=F0o;bar=bAr;"))) user=&g

Re: New JDK 7 Feature: Support for Dynamically Typed Languages in the JVM

2009-07-29 Thread Chouser
On Wed, Jul 29, 2009 at 11:41 AM, Baishampayan Ghose wrote: > Hello, > > It seems JDK 7 is going to implement JSR 223 which explicitly adds > support for Dynamic Programming languages running on the JVM. > > http://java.sun.com/developer/technicalArticles/DynTypeLang/index.html > > I would like to

Re: REQUEST: Add seqable? to core

2009-07-29 Thread Chouser
c. user=> (filter #(Character/isUpperCase %) "Works For Me") (\W \F \M) user=> (seq (java.util.HashMap. {:a 1, :b 2, :c 3})) (# # #) > PS - Sorry if this isn't the right avenue for feature requests. No worries -- you're going about this exactly the right way. :-) -

Re: struct-map niggle

2009-07-30 Thread Chouser
-> (binding [*print-dup* true] (prn-str (sorted-map :a 1, :b 2))) java.io.StringReader. java.io.PushbackReader. read class) clojure.lang.PersistentTreeMap (-> (binding [*print-dup* true] (prn-str (sorted-map-by #(compare %2 %1) :a 1, :b 2))) java.io

Re: Clojure without Rich Hickey

2009-08-01 Thread Chouser
transparency and goodwill, I would expect. The thought of everyone trying to get all this organized is quite daunting, but people would manage. So I think you shouldn't let it trouble you too much. In other words: Don't worry. Be happy now. Doo doo doo... --Chouser --~--~-~--

Re: The :while modifier (list comprehensions)

2009-08-03 Thread Chouser
27;y' loop, so the 'x' loop is unaffected by your :while and proceeds through its entire range in both examples. In the first example, the 'y' loop never produces anything so the result is empty. The :while modifier for 'doseq' behaves the same way. This has come

Re: core.clj: 'into' definition

2009-08-11 Thread Chouser
lambdas are necessary? But then recur > would rebind the (nonexistent) lambda parameters I'd have thought. I don't know either. 'loop' is a macro that expands to 'loop*', which is in turn a special form. At that most basic level, loop* still creates a recur point,

Re: Can Clojure be as fast as Java?

2009-08-11 Thread Chouser
I wonder if continued discussion on this thread will be helpful to anyone. It seems to me we are not likely to soon get any closer to an answer for the original question than has already been offered. It's been lively and informative but I hope it's run its course.

<    1   2   3   4   5   6   7   8   >