Is the vector a sequence?

168 views
Skip to first unread message

ru

unread,
Apr 20, 2018, 11:33:02 AM4/20/18
to Clojure
Hi,

user=> (seq? [1 2 3 4 5])

false

user=> 


Sincerely,

  Ru

Alex Miller

unread,
Apr 20, 2018, 11:35:31 AM4/20/18
to Clojure
No, vectors are not sequences. They are however "seqable", that is they can provide a sequence when asked...

You might find this helpful:

Timothy Baldridge

unread,
Apr 20, 2018, 11:35:45 AM4/20/18
to clo...@googlegroups.com
It's not a seq, but it's seqable. 

(seq? [1 2]) => false
(seqable? [1 2]) => true
(seq? (seq [1 2])) => true



--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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+unsubscribe@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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
“One of the main causes of the fall of the Roman Empire was that–lacking zero–they had no way to indicate successful termination of their C programs.”
(Robert Firth)

ru

unread,
Apr 20, 2018, 11:54:20 AM4/20/18
to Clojure

user=> (seqable? [1 2])


CompilerException java.lang.RuntimeException: Unable to resolve symbol: seqable? in this context, compiling:(/private/var/folders/5j/k0rtjxqn3b57nykc_1jf2xnr0000gn/T/form-init6382892774167052117.clj:1:1) 

user=> 


пятница, 20 апреля 2018 г., 18:35:45 UTC+3 пользователь tbc++ написал:
It's not a seq, but it's seqable. 

(seq? [1 2]) => false
(seqable? [1 2]) => true
(seq? (seq [1 2])) => true


On Fri, Apr 20, 2018 at 9:33 AM, ru <sor...@oogis.ru> wrote:
Hi,

user=> (seq? [1 2 3 4 5])

false

user=> 


Sincerely,

  Ru

--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@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

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+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Timothy Baldridge

unread,
Apr 20, 2018, 11:55:59 AM4/20/18
to clo...@googlegroups.com
seqable? was added in Clojure 1.9


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+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

ru

unread,
Apr 20, 2018, 2:46:32 PM4/20/18
to Clojure
Thank you, Alex and tbc++

пятница, 20 апреля 2018 г., 18:55:59 UTC+3 пользователь tbc++ написал:

Rick Moynihan

unread,
Apr 20, 2018, 5:39:41 PM4/20/18
to Clojure
It's also worth mentioning vectors are sequential:

(sequential? [1 2 3]) ;; => true

R.

Alexander Yakushev

unread,
Apr 28, 2018, 4:46:06 AM4/28/18
to Clojure
You might also want to check this: http://bytopia.org/2016/03/08/what-is-a-list/

Peter Hull

unread,
Apr 28, 2018, 9:05:22 AM4/28/18
to Clojure
On Friday, 20 April 2018 22:39:41 UTC+1, Rick Moynihan wrote:
It's also worth mentioning vectors are sequential:
I'd be interested to know what is the purpose of sequential. The docs for sequential? just say it implements Sequential, and clojure.lang.Sequential is an interface with no behaviour of its own. So what extra could you do if you knew something was sequential? Is it something to do with Java interop?

Alex Miller

unread,
Apr 28, 2018, 10:34:07 AM4/28/18
to Clojure
sequential? is useful for partitioning the collection space for conditional behavior.

In particular, sequential? covers vector, list, and sequence, all of which compare equal.

Reply all
Reply to author
Forward
0 new messages