nstead of struct, but I think the above
case is far more common. So why not make it the default if you call
the struct-basis? The attached patch allows:
user=> (point 42 11)
{:x 42, :y 11}
This is less wordy and has a nice declarative ring to it.
--Chouser
1. http://clojure-log.n01se.net/
On Wed, Nov 5, 2008 at 12:10 AM, Chouser <[EMAIL PROTECTED]> wrote:
> The attached patch allows:
>
> user=> (point 42 11)
> {:x 42, :y 11}
The right tool for the job makes all the difference. Attached is a
much simpler patch to accomplish the s
:
(ancestors (class #()))
Cleaned up output:
#{#=clojure.lang.AFn
#=clojure.lang.IFn
#=clojure.lang.IObj
#=clojure.lang.Obj
#=java.io.Serializable
#=java.lang.Object
#=java.lang.Runnable
#=java.util.Comparator
#=java.util.concurrent.
c type than IPersistentMap -- you get the right behavior by
default:
user=> (sorted-map 1 2 3 4 5 6)
#=(sorted-map 1 2,3 4,5 6)
That still doesn't get read in right, and I'm not sure why. But it
seems to be printing ok.
--Chouser
--~--~-~--~~~---~--~
nerates the
> "#=(sorted-map ..." printing? I've looked but can't find it in
> boot.clj.
Now *I'm* confused. It's your code that's printing "#=(sorted-map ..."
for me, without any call to "prefer-method" required.
--Chouser
--~--~
binding form".
This patch also includes fixes to all the places in boot, proxy,
gen-class, and xml (that I found) that use these macros. I
assume every lib in clojure-contrib and in fact nearly every
piece of clojure code more that 10 line
me Clojure function to read. ...but I don't
really know enough about ant (or svn either, for that matter) to do
this myself.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
T
t -- add a check to make sure
only one binding pair is given. Alternatively it could act as if it
were nested, as "for" (and now "doseq") do, in which case it would act
like an "and", and both x and y would be bound to non-false values.
--Chouser
--~--~-~--~-
lier patch).
This patch is against 1089, the "Interim checkin - DO NOT USE!!" version of SVN.
--Chouser
On Sat, Nov 8, 2008 at 7:42 AM, Rich Hickey <[EMAIL PROTECTED]> wrote:
>
>
>
> On Nov 7, 5:09 pm, James Reeves <[EMAIL PROTECTED]> wrote:
>> On Nov 7, 9:32
(when (= 1 (dosync (alter call-count inc)))
> (apply function args)
Or:
(defn runonce
"Create a function that will only run its argument once."
[function]
(let [needed (java.util.concurrent.atomic.AtomicBoolean. true)]
(fn [& args]
(when (.getA
ta key."
(let [has-run (gensym)]
`(let [[function# ~has-run] (runonce (fn [] [EMAIL PROTECTED]))]
(def ~(with-meta sym {:has-run has-run}) function#
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Googl
n constants
new *print-dup* flag, prints duplicators
back to simplified readably printing for repl
readable fns, as long as they are not closures
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clo
-)
Ok, I've said my piece. I'll try harder not respond next time.
--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
I do actually use Clojure to prepare the pages. At this point I
could probably use ClojureScript instead of Clojure for the
client-side code, but I haven't done that yet.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to th
ught to be replace by a real IRC bot, but nobody's quite gotten
around to that yet.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to cloj
efore evaluation begins. By the time you bind *ns* to
your target-ns, it's too late -- the defn is already compiled to
resolve to the old namespace.
I can't think of any way to do this in a single macro expansion
without using "eval" on the defn f
assume you're using a version older than that.
--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
lojure (all one keyword):
(ns a (:refer-clojure :exclude (load)))
--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
(in-ns 'a)
#
a=> (load)
my-load
a=> (doc mmap)
-
clojure.contrib.mmap/mmap
([f])
Memory-map the file named f. Returns a ByteBuffer.
nil
a=> (doc children)
-
clojure.contrib.zip-filter/children
([loc])
Returns a lazy sequence of all immediat
On Fri, Nov 14, 2008 at 12:16 PM, Howard Lewis Ship <[EMAIL PROTECTED]> wrote:
>
> Is this mailing list the correct place to report bugs? The bug list
> on the SF page looks pretty sparse.
Yes, this is a fine place to report b
h off of, you'll have to attach that yourself, either as
another key that all your Maps share or as metadata.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this
On Fri, Nov 14, 2008 at 3:51 PM, Bradbev <[EMAIL PROTECTED]> wrote:
>
> (which will convert it from lazy to ...? Hmm, what's the
> word - motivated?)
I think the word you want is "eager"
http://www.zazzle.com/i_get_more_done_when_im_lazy_clojure_shirt
ction -- it
may look similar, but it's not the same. So the structure will only
be as deep as you make it.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this gro
On Sat, Nov 15, 2008 at 1:20 PM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote:
>
> I usually use Mac OS X's Mail from a "mac.com/MobileMe" account to
> send and receive mail with this group.
I use gmail.com, and have never noticed a problem sending an
attac
ow to
make it visible to anyone who doesn't log in using a Google account:
I'll make the results available to everyone in some other format once
sufficient time has been passed for everyone to vote.
https://spreadsheets.google.com/gform?key=p1hkQs__fVyaQGEP_bOFRVQ&hl=en&a
in Clojure put the dot elsewhere,
either (. "foo" substring 1) or preferably (.substring "foo" 1)
Putting those together, as Stephen Gilardi said, you get (.println
System/out "get it done")
--Chouser
--~--~-~--~~~---~--~~
You received t
(if (nil? (.getCause x))
>x
>(recur (.getCause x))
>
> However I get:
>
> java.lang.UnsupportedOperationException: Cannot recur from catch/finally
> (NO_SOURCE_FILE:1)
>
> Is this intended?
You could of course work around this by putting your loop
definitions) for
> denoting lazy/strict versions of functions. (e.g. (map f ...) is a
> lazy seq, (map! f ...) is strict)
(vec x) will force a lazy seq x and store it in a vector. (apply list
x) will force and store in a list.
--Chouser
--~--~-~--~~~---~--~
tWip in IRC notice with-in-str is broken. Patch attached.
--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 used in code (defn, let, etc.) and can format the
required args differently than the "rest" args. This would allow some
code forms to look more natural.
Anyway, it's definitely a work in progress. What I've got so far is
attached. All thoughts and comments are welcome.
--
e on short lists. :-)
I wanted to post what I had right away, but I will now take the time
to understand your code, so I can come up with own opinion about how
we ought to proceed.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscr
see that the type signature looks good:
user=> my-tricky-array
#
To unpack it into Clojure seqs again:
user=> (map seq my-tricky-array)
((1.0 2.0) (3.0 4.0))
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Gr
gt; user=> (into-array (map double-array [[1.0] [2.0]]))
> #
Ah, nice. 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@goo
need this you
can wrap either step in a function to make calling it more pleasant.
--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
ting the
array inside the vector.
--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 group, se
8-11-14.html#17:40a-17:52
--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 group, send email to
re, load the generated .class files.
--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 group, se
ang.PersistentHashMap (1)
[ 5] static create : class clojure.lang.PersistentHashMap (2)
[ 6] static create : interface clojure.lang.IPersistentMap (1)
[ 7] (interface clojure.lang.IPersistentMap, int, interface
clojure.lang.PersistentHashMap$INode)
[ 8] applyTo : class java.lang.Object (1
ss-platform way to launch
clojure from the command line that supports all the various "normal"
usage patterns naturally. Until then use -- either manually, or put it
in your clj shell script somewhere.
--Chouser
--~--~-~--~~~---~--~~
You received this messag
-length* since it does its own looping and
only over concrete things like method lists -- no infinite seqs there.
No, the *print-length* is set for the whole REPL context to save
myself from pain when I accidentally evaluate the equivalent of
(iterate in
on't need to alter
state in as many places as you would in other languages, and when you
do it's easier to do it in a thread-safe way.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure
a is
that you shouldn't have to actually set the state very often, usually
just once at the top level of any particular code path or even
handler, which will have benefits even in a single-threaded system.
It can be hard to think through algorithms this way at first, but I've
found
t agents are really what you want, but anyway...
(send player update-in [:str] inc)
(await player)
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email
ay (or let my vim roots show
too much) but jEdit is a 2 or 3MB download. I bet it wouldn't be very
hard to get a Clojure REPL in there.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure&qu
ve to keep that in mind.
(zero? n) is an idiom for (= 0 n)
Alas even your beautiful, succinct implementation and careful code
comments are apparently insufficient for me to understand monads.
I'll keep trying. :-)
--Chouser
--~--~-~--~~~---~--~~
You r
n to produce a .jar file directly, allowing a fifth use case:
5. java -jar my-foo.jar arg1 arg2
A cleverly written clj shell-script ought to be able to do all this
today, though that doesn't work well as a cross-platform solution. So
the question is -- are these use cases generall
s something about a lisp other than Clojure
can comment.
--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 fr
fVyaQGEP_bOFRVQ
--Chouser
On Sat, Nov 15, 2008 at 5:22 PM, Chouser <[EMAIL PROTECTED]> wrote:
> I've put up a poll form to allow everyone to vote on which
> clojure.contrib libs they think should be in clojure.core or otherwise
> bundled with Clojure:
>
> htt
)] [(flatten
(:doc2 x))])
This would of course require you to change everywhere that currently
expects a struct with a :type to instead use (first x) for the type
and the rest of the seq as args.
Is your current version visible anywhere? Perhaps a more holistic
look would reveal some other options.
ur classpath. You get no error at
this point, but apparently if the directory doesn't exist it's not
really used, even though it's shown in the java.class.parth property
string.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are s
If you add me as a committer I will be well-
> behaved. Maybe even install svn. :-)
Oh, please don't bother. git-svn works beautifully.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojur
))
That's essentially the same algorithm. I don't think there's a
built-in function to do it for you.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this
the mutual-recursion
case you could get a nice error if you make a mistake like:
(def foo []
(+ 10
(tail-call bar 1 2)))
Although something less ugly might be nice.
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Googl
#(prn "Hello"))
>
> How can I execute the closure in myClosure now?
user=> (myClosure)
"Hello"
or now,
user=> (trampoline myClosure)
"Hello"
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscr
make writing unit tests very
easy [using test-clojure and test-is]
Chouser:
[seq-utils] group-by
Anonymous:
if slurp is in clojure, spit [from duck-streams] should be there, too
sj:
sql and miglayout are important because they from the basis of so
many applications
Perry Trolard:
ments, which generally means
you need build the array the method is expecting. Fortunately, in the
cases you list you can just use the Clojure function 'format' which
does it for you:
(.println System/out (format "%d" 1))
--Chouser
--~--~-~--~~~---~--~
On Thu, Nov 27, 2008 at 11:50 PM, Stephen C. Gilardi <[EMAIL PROTECTED]> wrote:
>
> You might also consider these Clojure functions:
> user=> (count "")
> 0
> user=> (empty? "")
> true
or (seq "") which returns nil on empty.
--Chouse
ling of character, and the
doubling of the number of symbols? Personally, I would say no. And
if you're doing fewer than a million, it's certainly not worth it.
So write code for the programmer rather than the computer -- write it
the way that will be the easiest for yourself and futu
back in by 'read'. For example:
user=> (java.util.Date.)
#
Hope that helps make sense of things,
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this gro
0.
So it's up to you to determine how you want to spend your time.
Personally, I stay up to date with SVN. :-)
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to
psed time: 36.130324 msecs"
nil
user=> (time (dotimes [_ 100] (reduce str long-sequence)))
"Elapsed time: 1050.878775 msecs"
nil
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure"
, :a 1}
user=> (reduce (fn [m [k v]] (assoc m k v)) {} seq-of-pairs) ; if you
really want to use assoc
{:c 3, :b 2, :a 1}
--Chouser
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To pos
ns-publics already calls 'the-ns' on its arg, and 'for' is handy for
destructuring.
(defn ns-var-metas [ns-name]
(into {} (for [[n v] (ns-publics ns-name)] [n ^v])))
Both 'into' and 'apply conj' allow you to specify nil instead of a
pair if you wanted
x27;m generally in favor of ditching parens whenever possible. I do
wonder, though, if people would be confused by:
user=> [1 2 3]
java.lang.IllegalArgumentException: Wrong number of args passed to:
LazilyPersistentVector (NO_SOURCE_FILE:0)
--Chouser
--~--~-~--~~~
uppose 'coll' would be a misleading name. In
that case perhaps 's' or 'sequence' or something would do, but never
'seq'. Although it doesn't directly generate an error to use the word
'seq' as an arg or local, it shadows the
elegates to (RT/seq) uses the name 'coll'.
For the others, they do all appear to call 'seq' on the arg you name,
so any collection could be passed in. Whether it makes sense to
highlight this fact by renaming the arg to something-coll or not
probably depends on the specific functi
-for-int prompt junk-allowed default
Or, since a default only makes sense if it might be returned:
(defn prompt-for-int
([prompt] (or (prompt-for-int prompt nil) (recur prompt)))
([prompt default] (or (parse-int (prompt-read prompt)) default)))
--Chouser
--~--~-~--~~-
"Test"]]
This has not been deeply tested:
(defn f [{:keys [tag attrs content] :as other}]
(if tag
(vec (concat [tag]
(when attrs [attrs])
(when-let [s (map f content)] (vec s
other))
--Chouser
--~--~-~--~~~---
e the
document) vs. translating iterations into stack depth, you'll be okay.
That's no promise, of course, but building a nested structure like
this using only tail recursion sounds messier than I'd like to deal
with at the moment. :-)
--Chouser
--~--~-~--~~~--
the documentation for the
> String class at http://java.sun.com/javase/6/docs/api/java/lang/String.html.
> It would also be helpful to know which File I/O libraries are most
> relevant, and a couple short examples of how to use them. An
701 - 770 of 770 matches
Mail list logo