YES please. If I could upvote this message I would.
A half-a-dozen of examples on ns/in-ns and require/use/refer and the
differences in using them at the prompt or inside a ns would be
fantastic.
The ns macro is one of the obscure corners of clojure. It relates to
the java class path problem,
A quick question about how closures work in Clojure.
In this simple recursive expression:
(def t (fn [x] (if (zero? x) 0 (+ x (t (dec x))
The fn special form is evaluated within a context where t is not yet
bound.
t is only bound AFTER fn has captured its environment.
In other words, the
(doc some) says:
... this will return true if :fred is in the sequence, otherwise nil:
(some #{:fred} coll)
However, some returns the matching value instead:
= (some #{:fred} [:foo :fred :ethel])
:fred
Attached patch fixes the docstring. (Not that applying the patch would
be any easier than
mbrodersen wrote:
In this simple recursive expression:
(def t (fn [x] (if (zero? x) 0 (+ x (t (dec x))
The fn special form is evaluated within a context where t is not yet
bound.
t is only bound AFTER fn has captured its environment.
In other words, the closure captured by fn
John Ky wrote:
How to I print without spaces?
(println (str a b c))
--
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 - please be patient with
Hi,
(println (str a b c))
Regards,
Lauri
On Wed, Nov 11, 2009 at 9:15 AM, John Ky newho...@gmail.com wrote:
Hi all,
How to I print without spaces?
For example:
(println a b c)
Gives:
a b c
Rather than
abc
Thanks,
-John
--
You received this message because you are
John Ky wrote:
Hi all,
I'm looking for a way to write a defkw macro so that (defkw ABSENT)
expands to
(def ABSENT (kw ABSENT :ABSENT )).
Just use `(...) as a template and use ~ to unescape, like so:
(defmacro defkw [sym]
`(def ~sym (kw ~(str sym) ~(keyword sym
(defkw ANSEMT)
=
Hi all,
I'm looking for a way to write a defkw macro so that (defkw ABSENT) expands
to
(def ABSENT (kw ABSENT :ABSENT )).
Thanks,
-John
--
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
Hi all,
How to I print without spaces?
For example:
(println a b c)
Gives:
a b c
Rather than
abc
Thanks,
-John
--
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
On Nov 10, 2:28 am, John Harrop jharrop...@gmail.com wrote:
(I suppose T and F are static fields holding java.lang.Booleans, and this
code was written pre-autoboxing?)
It's still much faster to use a pre-boxed Boolean than to create a
new boxed value every time around.
Kresten
--
You
Hi,
On Nov 11, 2:34 pm, Alex Osborne a...@meshy.org wrote:
(let [t (fn [x] (if (zero? x) 0 (+ x (t (dec x)] (t 2))
But also note, that you can give an anonymous function a name. %)
(let [t (fn t [x] (if (zero? x) 0 (+ x (t (dec x)] (t 2))
Sincerely
Meikel
--
You received this
Hello,
On Wed, Nov 11, 2009 at 2:57 PM, Albert Cardona sapri...@gmail.com wrote:
YES please. If I could upvote this message I would.
A half-a-dozen of examples on ns/in-ns and require/use/refer and the
differences in using them at the prompt or inside a ns would be
fantastic.
Some more ns
Symbols are late resolved to functions.
(def t (fn ...)) means define a Var bound to symbol t, and store the
function in it. In JVM terms, the function becomes a new class that is
instantiated.
(t (dec x)) means locate the Var bound to symbol t -- at execution
time (not compilation time) ---
Check out this post for some suggestions on working with Clojure in a
distributed fashion.
http://groups.google.com/group/clojure/msg/4a7a866c45dc2101
-Travis
On Nov 9, 2:09 pm, Michael Jaaka michael.ja...@googlemail.com wrote:
Hi!
Is there any support from Clojure for communication between
On Nov 10, 2009, at 9:08 PM, John Harrop wrote:
(ns foo.bar.baz
(:use [clojure.contrib.core :only (seqable?)]))
(and thus violates the usual clojure rule of using vectors rather
than lists for groupings that are not invocations -- that is,
function calls, macro calls, or special form
On Wed, Nov 11, 2009 at 1:12 PM, Stephen C. Gilardi squee...@mac.comwrote:
Before:
(:refer-clojure :exclude [read])
(:require (clojure.contrib [graph :as graph] [fcase :as fcase])
[clojure.contrib.stream-utils :as su])
(:use [clojure.contrib def except server-socket]
(:uses [clojure.core :exclude [read])
[clojure.contrib.graph]
[clojure.contrib.fcase]
[clojure.contrib.stream-utils :as su]
[clojure.contrib.def :refer-all true]
[clojure.contrib.except :refer-all true]
[clojure.contrib.server-socket
Just use first and second for both cases.
On Nov 11, 9:52 am, samppi rbysam...@gmail.com wrote:
Clojure 1.1.0-alpha-SNAPSHOT
user= (conj (first {1 2}) 3)
[1 2 3]
user= (conj {1 2} [2 5])
{2 5, 1 2}
user= (key (first {1 2}))
1
user= (key [1 2])
java.lang.ClassCastException:
On Wed, Nov 11, 2009 at 1:12 PM, Stephen C. Gilardi squee...@mac.com wrote:
Here are some of the ideas I've liked best for how to do it.
Thanks for pulling this together. I like the whole direction
you're going here.
- require that each libspec (reference to a lib) be a vector, disallowing
Hi!
On Wed, Nov 11, 2009 at 7:12 PM, Stephen C. Gilardi squee...@mac.com wrote:
Here are some of the ideas I've liked best for how to do it.
I like where this is heading.
- don't refer any names from the target namespace into the current
namespace by default
YES!
- support :only [],
2009/11/11 Andrew Boekhoff boekho...@gmail.com:
(:uses [clojure.core :exclude [read])
[clojure.contrib.graph]
[clojure.contrib.fcase]
[clojure.contrib.stream-utils :as su]
[clojure.contrib.def :refer-all true]
[clojure.contrib.except :refer-all
On Wed, Nov 11, 2009 at 3:54 PM, Laurent PETIT laurent.pe...@gmail.comwrote:
2009/11/11 Andrew Boekhoff boekho...@gmail.com:
(:uses [clojure.core :exclude [read])
[clojure.contrib.graph]
[clojure.contrib.fcase]
[clojure.contrib.stream-utils :as su]
I like almost all of this a lot. My only disagreement is on prefix
lists ... I wouldn't want to lose them, and in fact would prefer to
see them extended to recursive prefix lists (trees).
-Jason
On Nov 11, 10:12 am, Stephen C. Gilardi squee...@mac.com wrote:
On Nov 10, 2009, at 9:08 PM, John
Thanks Howard. Another great answer.
Morten
On Nov 12, 2:58 am, Howard Lewis Ship hls...@gmail.com wrote:
Symbols are late resolved to functions.
(def t (fn ...)) means define a Var bound to symbol t, and store the
function in it. In JVM terms, the function becomes a new class that is
Great answer Alex. Thanks!
Morten
On Nov 12, 12:34 am, Alex Osborne a...@meshy.org wrote:
mbrodersen wrote:
In this simple recursive expression:
(def t (fn [x] (if (zero? x) 0 (+ x (t (dec x))
The fn special form is evaluated within a context where t is not yet
bound.
t is only
Hi all,
Does anyone know why if the first character in my *.clj file is '#', then
when I open it in VIM, ClojureVIM fails to recognise it as a Clojure file?
Thanks
-John
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send
Thanks,
On Thu, Nov 12, 2009 at 12:34 AM, Alex Osborne a...@meshy.org wrote:
John Ky wrote:
How to I print without spaces?
(println (str a b c))
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to
Hi Alex,
I had to ~(keyword (str sym)) instead of ~(keyword sym), but now it works
well.
Cheers,
-John
On Thu, Nov 12, 2009 at 12:40 AM, Alex Osborne a...@meshy.org wrote:
John Ky wrote:
Hi all,
I'm looking for a way to write a defkw macro so that (defkw ABSENT)
expands to
(def
John Ky wrote:
I had to ~(keyword (str sym)) instead of ~(keyword sym), but now it
works well.
Hmm, odd. Must have changed since Clojure 1.0. (keyword 'some-symbol)
works for me on the new branch.
--
You received this message because you are subscribed to the Google
Groups Clojure group.
Does anyone know why if the first character in my *.clj file is '#', then
when I open it in VIM, ClojureVIM fails to recognise it as a Clojure file?
I don't know why, but I can provide this data point:
It does not do that for me.
Vim 7.2, vimclojure 2.1.2, java 6.0.14
--
You received this
Try looking at this:
http://github.com/hlship/cascade/blob/master/src/main/clojure/cascade/mock.clj
On Thu, Nov 5, 2009 at 5:00 AM, vanallan vanal...@gmail.com wrote:
Hi
Im trying to convert a couple of Java methods in a Java project to
Clojure. The Java methods have test methods that mocks
Warren Wood warrenthomasw...@yahoo.com writes:
Thought of this, which I like better. Again, I'm surprised if
conjunction is not already a standard function, but I can't find it.
I'm still a bit tempted to call it AND for readabilty of code. (I
spent some time studying combinatory logic back
I'm curious what the best idiomatic way of handling events is (e.g.
receiving a series of messages and dispatching functions on the basis
of the messages). One could use the 'experimental' add-watch(er)
functions. But it might also be nice to do something stream-oriented,
e.g. a doseq on a
Mine is almost the same:
Vim 7.2, vimclojure 2.1.2, java 1.6.0_10
On Thu, Nov 12, 2009 at 10:47 AM, MarkSwanson mark.swanson...@gmail.comwrote:
Does anyone know why if the first character in my *.clj file is '#', then
when I open it in VIM, ClojureVIM fails to recognise it as a Clojure
nchubrich wrote:
I'm curious what the best idiomatic way of handling events is (e.g.
receiving a series of messages and dispatching functions on the basis
of the messages). One could use the 'experimental' add-watch(er)
functions. But it might also be nice to do something stream-oriented,
Hi,
I've been trying to implement a topological sort and have been
struggling a bit. I have a map of symbol vs collection of symbols
like:
{a [b c], b [c], c [nil]}
which can be read as 'a' depends on 'b' and 'c', 'b' depends on 'c'
and 'c' doesn't depend on anything. I've been trying to write
Hi everyone. I wrote a CSV parsing and output library for my own uses
when I didn't see another one available. Someone on #clojure suggested
it might be of general interest for clojure.contrib. If you guys
agree, I'm happy to do whatever is necessary to assist with that.
The code is at
Yeah, sorry, missed that.
How does making the gensyms unreadable make things worse for
macroexpand than they are in CL? If the gensym is used more than once
in the expansion (like bound to something in a let then referenced),
then reading the expansion back in will read two different symbols and
I often have to manipulate keywords and symbols. A symbol name needs
a string appended in a macro, a keyword uses underscores instead of
dashes.
In order to do this, I usually transform them into a string, do some
manipulation, and then turn the result back into a keyword/symbol.
This pattern
Nick Day nicke...@gmail.com writes:
I've been trying to implement a topological sort and have been
struggling a bit. I have a map of symbol vs collection of symbols
like:
{a [b c], b [c], c [nil]}
which can be read as 'a' depends on 'b' and 'c', 'b' depends on 'c'
and 'c' doesn't depend on
On Wed, Nov 11, 2009 at 2:04 PM, Nick Day nicke...@gmail.com wrote:
Hi,
I've been trying to implement a topological sort and have been
struggling a bit. I have a map of symbol vs collection of symbols
like:
{a [b c], b [c], c [nil]}
which can be read as 'a' depends on 'b' and 'c', 'b'
On Wed, Nov 11, 2009 at 10:46 PM, Kevin Tucker tuckerke...@gmail.comwrote:
Yeah, sorry, missed that.
How does making the gensyms unreadable make things worse for
macroexpand than they are in CL?
It doesn't. Just worse than they currently are in Clojure. :)
--
You received this message
42 matches
Mail list logo