Re: [moderated] I don't understand what (:t :t) means

2016-12-28 Thread John Gabriele


>
> hello,everyOne,i'm a new clojure learner.
> I don't know what the structure of (:t :t)!
> when i use coll? list? vector? set? map? seq? they all return false!!
> what is the structure of (:t :t)? thank you very much!
>

Couple other things to note:

  * `:t` is just a keyword, like `:foo` or `:bar`. (In case you were 
thinking of Scheme, where `#t` is the boolean true.)

  * you can always check what type something is by doing `(class 
that-thing)` (though, in this case, as you've already seen, `(:t :t)` 
results in `nil`).

-- 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 posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [moderated] I don't understand what (:t :t) means

2016-12-26 Thread Aaron Cohen
(:t :t) is a function invocation. Clojure always attempts to invoke the
first element of a list as a function unless told not to, this is one of
the fundamental behaviours of a lisp.

In this case, clojure will attempt to invoke the keyword ":t" as a
function. Keywords are actually invokable in clojure, their behaviour is to
look themselves up in the specified collection.

For instance: (:t {:t "Here", :r "There"}) would return "Here".

In your example, the parameter is not a collection though, it's the same
keyword again, ":t". Attempting to do a collection look up using a
non-collection is defined to return nil.

Thus, (:t :t) -> nil

If you wish to create a structure by preventing clojure from using the
first element as a function, you must "quote" your example, ie, (quote (:t
:t)) or '(:t :t) then the structure would be a list with two elements.

--Aaron

On Mon, Dec 26, 2016 at 10:17 AM, Stuart Sierra  wrote:

> As a moderator, I am posting this message on behalf of a new forum user,
> below. I have edited the message for appropriate language. –Stuart S.
>
>
> From: silver1 silver1 
> Date: Mon, 26 Dec 2016 22:11:17 +0800
> Subject: I don't understand (:t :t)mean ,please help me !!
>
> hello,everyOne,i'm a new clojure learner.
> I don't know what the structure of (:t :t)!
> when i use coll? list? vector? set? map? seq? they all return false!!
> what is the structure of (:t :t)? thank you very much!
>
> --
> 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
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
> ---
> You received this message because you are subscribed to the Google Groups
> "Clojure" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[moderated] I don't understand what (:t :t) means

2016-12-26 Thread Stuart Sierra
As a moderator, I am posting this message on behalf of a new forum user, 
below. I have edited the message for appropriate language. –Stuart S.


From: silver1 silver1 
Date: Mon, 26 Dec 2016 22:11:17 +0800
Subject: I don't understand (:t :t)mean ,please help me !!

hello,everyOne,i'm a new clojure learner.
I don't know what the structure of (:t :t)!
when i use coll? list? vector? set? map? seq? they all return false!!
what is the structure of (:t :t)? thank you very much!

-- 
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 your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.