Is there a term for non-map collections?
As Tim McCormack's helpful web page on Collections and Sequences in Clojurehttp://www.brainonfire.net/files/seqs-and-colls/main.htmlsays, Newcomers to Clojure are often confused by the collection and sequence abstractions and how they relate to one another. I'd been using collections and sequences successfully, but was confused about terminology until I read McCormack's explanation. I have a further question: Is there are term for collections that are not maps? Although vectors can function like maps, because they are associative?, and functions like find and get treat indexes as if they were map keys, from another perspective vectors are just sequences of single elements, not sequences of key-val pairs. This difference shows up in contexts such as map : (map identity [:a :b]) ; == (:a :b) (map identity {1 :a 2 :b}) ; == ([1 :a] [2 :b]) Is there a single term that covers vectors, lists, sets, lazy sequences, cons's, etc., but not maps? The only reason that this matters to me is for naming functions, parameters, and docstrings. Sometimes I write a function that will work in the intended way only with collections that are not maps. (For example, suppose I write a function that's supposed to operate on vectors, lists, sets, or lazy sequences of keywords, what do I call its argument? keyw-coll is too broad, and keyw-seq is too narrow.) -- 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: Is there a term for non-map collections?
On May 16, 2014, at 12:53 PM, Mars0i marsh...@logical.net wrote: Sometimes I write a function that will work in the intended way only with collections that are not maps. (For example, suppose I write a function that's supposed to operate on vectors, lists, sets, or lazy sequences of keywords, what do I call its argument? keyw-coll is too broad, and keyw-seq is too narrow.) I think I'd use kws or keywords in that case. I'd expect a seq of keywords. I don't think keyw-seq is too narrow though. The items in a seq on a map are map entries or more generically pairs, not keywords. --Steve -- 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: Is there a term for non-map collections?
On Friday, May 16, 2014 12:09:36 PM UTC-5, squeegee wrote: I think I’d use “kws” or “keywords” in that case. I’d expect a seq of keywords. I don’t think keyw-seq is too narrow though. The items in a seq on a map are “map entries or more generically “pairs”, not “keywords”. OK, but seq implies that sets aren't appropriate, but as long as I don't care about order, they may be perfectly fine. -- 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: Is there a term for non-map collections?
On May 16, 2014, at 1:23 PM, Mars0i marsh...@logical.net wrote: I think I'd use kws or keywords in that case. I'd expect a seq of keywords. I don't think keyw-seq is too narrow though. The items in a seq on a map are map entries or more generically pairs, not keywords. OK, but seq implies that sets aren't appropriate, but as long as I don't care about order, they may be perfectly fine. Good point. Technically kw-seq is too narrow because you probably have no need to restrict your argument to seqs. The distinction is often blurred because many Clojure functions that operate on seqs also directly or indirectly call seq on their argument. Any coll that's seqable will also work. I think looking at the word kew-seq as an argument name, I would expect to be able to pass in colls that are not seqs but are seqable including vector and set. Revising my earlier thought: I think I'd use kws or keywords in that case. I'd expect a seq or seqable coll whose items are keywords. --Steve -- 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: Is there a term for non-map collections?
On Friday, May 16, 2014 12:46:10 PM UTC-5, squeegee wrote: On May 16, 2014, at 1:23 PM, Mars0i mars...@logical.net javascript: wrote: OK, but seq implies that sets aren't appropriate, but as long as I don't care about order, they may be perfectly fine. Good point. Technically kw-seq is too narrow because you probably have no need to restrict your argument to seqs. The distinction is often blurred because many Clojure functions that operate on seqs also directly or indirectly call “seq” on their argument. Any coll that’s “seqable” will also work. I think looking at the word kew-seq as an argument name, I would expect to be able to pass in colls that are not seqs but are seqable including vector and set. Revising my earlier thought: I think I’d use “kws” or “keywords” in that case. I’d expect a seq or seqable coll whose items are keywords. So there really isn't a term for the category I have in mind, but your point, I take it, is that seq can do the job, even for sets, despite their lack of order, since they are things that will take on an order when needed. (Keyword was just an illustration. I had a more general question in mind. You really can pass in a map to anything that will take seqs, vectors, and sets, in general, but sometimes it's kind of a bizarre thing to do, and it's worth conveying that to users (even when the only user is oneself).) I still would kind of like a special term If no one has one already, I could try to make one up. Maybe the difference between maps and vectors is that, although they both have keys, it's easier to lose vector keys (as in the examples with the map function): de-keyable, dekeyed, de-pair-able? I don't think this is going to help make my docstrings clearer. -- 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: Is there a term for non-map collections?
For what it's worth, I would either choose kws/keywords for brevity, or keywords-seqable for explicitness. All in all, better imprecise but correct than precise and incorrect. Hope this helps, -- Laurent 2014-05-16 22:38 GMT+02:00 Mars0i marsh...@logical.net: On Friday, May 16, 2014 12:46:10 PM UTC-5, squeegee wrote: On May 16, 2014, at 1:23 PM, Mars0i mars...@logical.net wrote: OK, but seq implies that sets aren't appropriate, but as long as I don't care about order, they may be perfectly fine. Good point. Technically kw-seq is too narrow because you probably have no need to restrict your argument to seqs. The distinction is often blurred because many Clojure functions that operate on seqs also directly or indirectly call “seq” on their argument. Any coll that’s “seqable” will also work. I think looking at the word kew-seq as an argument name, I would expect to be able to pass in colls that are not seqs but are seqable including vector and set. Revising my earlier thought: I think I’d use “kws” or “keywords” in that case. I’d expect a seq or seqable coll whose items are keywords. So there really isn't a term for the category I have in mind, but your point, I take it, is that seq can do the job, even for sets, despite their lack of order, since they are things that will take on an order when needed. (Keyword was just an illustration. I had a more general question in mind. You really can pass in a map to anything that will take seqs, vectors, and sets, in general, but sometimes it's kind of a bizarre thing to do, and it's worth conveying that to users (even when the only user is oneself).) I still would kind of like a special term If no one has one already, I could try to make one up. Maybe the difference between maps and vectors is that, although they both have keys, it's easier to lose vector keys (as in the examples with the map function): de-keyable, dekeyed, de-pair-able? I don't think this is going to help make my docstrings clearer. -- 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.
Re: Is there a term for non-map collections?
On Friday, May 16, 2014 6:53:08 PM UTC+2, Mars0i wrote: Is there a single term that covers vectors, lists, sets, lazy sequences, cons's, etc., but not maps? I would use a collection of keywords in your example. As mentioned by Steve, a map is a collection of map entries/pairs, so a map *cannot* be a collection of keywords. -- Jean Niklas -- 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: Is there a term for non-map collections?
It's clear that the answer to my question is: No. There is no common term for non-map collections. Btw, the way that I expressed the question has been misleading. I'm not really interested in a function that is supposed to accept only collections of keywords. I defined a function, which in my application will operate on collections of keywords, as it happens--in particular, keywords that represent things called persons in the application. In the application, the argument will always be a vector of person-ids, so I could call it person-vec-to-foo. On the other hand, since what the function performs is a general-purpose operation that could be used for any group of objects, I wanted to call it and its parameter something more general. But it would be bizarre to pass maps to the function (unless someone wanted to perform operations on MapEntrys) so collection seemed like the wrong term. I could give more details or post the code, but I think the answer is clear. Thank you to all who answered! -- 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.