Clarified the cons/conj list return type #20

Merged
merged 1 commit into from Jan 5, 2014

Conversation

Projects
None yet
2 participants
Contributor

pol commented Jan 5, 2014

While reading through the article, I went looking for clarification of cons/conj. I ran into a thread that described the two functions as expanded to:

conj(oin items)
cons(truct a sequence)

And after doing some poking around in the repl, it is true that the returned classes from conj and cons are not the same:

user=> (def stooges (list "Moe" "Larry" "Curly"))
#'user/stooges
user=> (class (conj stooges "Shemp"))
clojure.lang.PersistentList
user=> (class (cons "Shemp" stooges))
clojure.lang.Cons

I am a Clojure newb though, and so I don't know if a Cons is more similar to a PersistentList than a LazySeq type. Meaning, I don't know enough of clojure to know if this change is more confusing than helpful. If a Cons quacks like a List, then this is probably more confusing. But, saying that both return a list isn't quite true (but it might be true enough).

mvolkmann added a commit that referenced this pull request Jan 5, 2014

Merge pull request #20 from pol/list-conj-cons
Clarified the cons/conj list return type

@mvolkmann mvolkmann merged commit 12b37d3 into mvolkmann:master Jan 5, 2014

Owner

mvolkmann commented Jan 5, 2014

Thanks! The pull request has been merged.

On Sun, Jan 5, 2014 at 2:31 PM, pol llovet notifications@github.com wrote:

While reading through the article, I went looking for clarification of
cons/conj. I ran into a thread that described the two functions as expanded
to:

conj(oin items)
cons(truct a sequence)

And after doing some poking around in the repl, it is true that the
returned classes from conj and cons are not the same:

user=> (def stooges (list "Moe" "Larry" "Curly"))
#'user/stooges
user=> (class (conj stooges "Shemp"))
clojure.lang.PersistentList
user=> (class (cons "Shemp" stooges))
clojure.lang.Cons

I am a Clojure newb though, and so I don't know if a Cons is more similar
to a PersistentList than a LazySeq type. Meaning, I don't know enough of
clojure to know if this change is more confusing than helpful. If a Cons
quacks like a List, then this is probably more confusing. But, saying that

both return a list isn't quite true (but it might be true enough).

You can merge this Pull Request by running

git pull https://github.com/pol/Clojure-Article list-conj-cons

Or view, comment on, or merge it at:

#20
Commit Summary

  • Clarified the cons/conj list return type

File Changes

  • M article.htmlhttps://github.com/mvolkmann/Clojure-Article/pull/20/files#diff-0(7)

Patch Links:


Reply to this email directly or view it on GitHubhttps://github.com/mvolkmann/Clojure-Article/pull/20
.

R. Mark Volkmann
Object Computing, Inc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment