I'm a clojure newbie. Why does the compiler complain about being unable to
resolve cube-root-recur on line 17? thanks
1 (def cube-root
2 (fn [n]
it is a macro with a syntax quote, so all symbols are
namespace-qualified. so = will actually be clojure.core/=
the ~' removes this namespace-qualification, so it is rendered as just =.
2010/8/21 limux liumengji...@gmail.com:
This is some code in a blog of William Gropper, the useage of ~'=
Clojure whitin a `(...) context resolves the name space of symbols.
This is most often what you want and prevent some name collisions at
macro expension.
But as binders can not be name-space resolved this do not allow to write:
`(let [and ])
this would expand to (let [ns/and ...]) which
Is where a canonical doc about ~' or I have to read the core.clj?
On 8月21日, 下午10时40分, Nicolas Oury nicolas.o...@gmail.com wrote:
Clojure whitin a `(...) context resolves the name space of symbols.
This is most often what you want and prevent some name collisions at
macro expension.
But as
Thanks, I remindered that it's a reader macro used to get the symbol
itself exactly without namespace. Ok, I see!
On 8月21日, 下午10时58分, limux liumengji...@gmail.com wrote:
Is where a canonical doc about ~' or I have to read the core.clj?
On 8月21日, 下午10时40分, Nicolas Oury nicolas.o...@gmail.com
On Aug 21, 9:58 am, limux liumengji...@gmail.com wrote:
Is where a canonical doc about ~' or I have to read the core.clj?
~' is not an actual thing. Note that `~expr is the same as expr, so
`~'foo is the same as 'foo is the same as (quote foo), which when
evaluated yields the symbol foo.
--
Hello John,
I would want to add something to what Justin said.
(defn goo [ i k l] (println l))
= (goo 2 3 [233])
;;; gives ([233])
(conj '([233]) ...)
(defn goo [i k [l]](println l))
=(goo 2 3 [233])
;;; gives [233]
(conj [233] ...)
Hope the difference is clear now.
Emeka
On Mon, Aug 2,
I've just implemented an inorder traversal function for a vector-based tree.
The functions look like,
(defn- do-traversal [tree idx traversal]
(cond
(not (node-exists? tree idx)) traversal
(leaf? tree idx) (conj traversal (tree idx))
:else (apply conj
(do-traversal tree
I think you want:
(defn- do-traversal [tree idx [tree-traversal]]
...)
Note the extra brackets for destructuring.
Another alternative is using multiple arg lists:
(defn- do-traversal
([tree idx]
(do-traversal tree idx []))
([tree idx traversal]
...))
Lastly, FYI, the form (if
Thanks for the response and suggestions Justin. A co-worker also just
suggested multiple arg lists which is perfect. He also suggested (or foo
bar) to further simplify my code. It definitely cleans the code up and
improves readability.
- John
On Mon, Aug 2, 2010 at 5:37 PM, Justin Kramer
Hello ataggart,
thank you for the correction!
Only now I understand A.Rosts question. May be somebody can help, and
explain why my hypothesis was wrong. Obviousely, while functions are
first class, special forms are even better, kind of zeroth class.
Thank you, alux
On 31 Mai, 04:15, ataggart
In fact, keywords are not symbols. So thats why you were wrong.
You can read about in on the page http://clojure.org/lisps
--
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
So I don't understand if there any way do it. I'm really curious about
it.
--
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
Hi Аркадий,
I started another thread about the difference between special form and
macros today - and got told that it is not possible to overwrite a
special form.
Regards, alux
On 31 Mai, 21:15, Ark. Rost arkr...@gmail.com wrote:
So I don't understand if there any way do it. I'm really
Hi!
For example, it's possible to do things like:
(def do println)
((var do) example)
And it works correct. But I don't understand how to get the same
behavior in let bindings.
I mean
(let [do println]
..)
what can I write to get the same results?
--
You received this message
Hi A.,
I dont completely understand what you refer to with works correct.
You define a local variable, named do, and use it. That works of
course. Btw you may use it without the call to var
(def do println)
(do example)
In let you may do
(let [do println] (do :plop))
Is this what you want?
On May 30, 12:45 pm, alux alu...@googlemail.com wrote:
Hi A.,
I dont completely understand what you refer to with works correct.
You define a local variable, named do, and use it. That works of
course. Btw you may use it without the call to var
(def do println)
(do example)
It only
Tom Hicks hickstoh...@gmail.com writes:
I can't seem to do this with the 'inc' function:
user= (binding [inc (fn [y] (+ 2 y))] (inc 44))
45
Why doesn't this work?
See this thread:
http://groups.google.com/group/clojure/browse_thread/thread/d772e114e50aace6
--
You received this message
Actually, I think shadowing core functions is not a great idea
Quite so! Common Lisp expressly prohibits this stuff for the COMMON-
LISP package.
but I wanted to understand the principles involved here. Thanks
again for your rapid help.
My pleasure. Happy Christmas!
--
You received this
On a related note, can someone explain the following...
I can define a function 'p1':
user= (defn p1 [x] (+ 1 x))
#'user/p1
user= (p1 44)
45
and then shadow it within the binding construct:
user= (binding [p1 (fn [y] (+ 2 y))] (p1 44))
46
but, I can't seem to do this with the 'inc' function:
but, I can't seem to do this with the 'inc' function:
user= (binding [inc (fn [y] (+ 2 y))] (inc 44))
45
Why doesn't this work?
Because inc is inlined, and thus isn't mentioned when your binding
occurs.
(defn inc
Returns a number one greater than num.
{:inline (fn [x] `(.
On Dec 24, 6:01 pm, Richard Newman holyg...@gmail.com wrote:
but, I can't seem to do this with the 'inc' function:
user= (binding [inc (fn [y] (+ 2 y))] (inc 44))
45
Why doesn't this work?
Because inc is inlined, and thus isn't mentioned when your binding
occurs.
Thanks
Hi,
just found that a binding-form within a let-form does still use the
outer value.
user (def *val* root binding)
#'user/*val*
user (defn print-val [] (println *val* is: *val*))
#'user/print-val
user (defn let-vs-binding []
(println beginning: *val*)
(let [*val* bound by let]
On Dec 19, 2009, at 5:23 PM, Stefan Kamphausen wrote:
1. Is my explanation correct?
It is. The binding form operates on the var, it doesn't affect name resolution
within the binding form's body. *val* within the body of the binding still
resolves to the let-bound local. While *val* is
24 matches
Mail list logo