You can also use the list function if you don't care about syntactic sugar, and it seems. Like it should look like this:
=> (list 1 2 3 4) '(1 2 3 4) or <1 2 3 4> <-- although i'd use that for vectors and use [] for lists. Wouldn't that be cool? I imagine (set 1 2 3 4) prints as #{1 2 3 4} On Oct 27, 2011 5:46 PM, "Nicolas" <bousque...@gmail.com> wrote: > Hi! > > Well [1 2 3] is just a syntaxic sugar for (vector 1 2 3): > =>(vector 1 2 3) > [1 2 3] > > When you enter a vector in the repl, it is evaluted to itself. Here an > example that show it: > =>[1 2 (+ 1 2)] > [1 2 3] > > And you can use the vector function for the same result: > =>(vector 1 2 (+ 1 2)) > [1 2 3] > > The quote prevent evaluation but this is not specific to lists: > =>'[1 2 (+ 1 2)] > [1 2 (+ 1 2)] > > The way to make function calls in lisp (and in clojure) is to consider > the first element of the list to be the function, and the next one to > be the argument of the function. This what happen when you perform say > an addition > (+ 1 2) is a call to the add function with 2 parameters. > > But this mean that you can't define a list (data structure) just by > writing it, because it will be evaluated. To prevent this, maybe the > best solution is to use the list function, that return a list with its > arguments. > =>(list 1 2 3) > (1 2 3) > > You see the consistency here. As vectors are contructed with vector > function. Notice calling the list function is very different that > using a quote: > =>(list 1 2 (+ 1 2)) > (1 2 3) > =>'(1 2 (+ 1 2)) > (1 2 (+ 1 2)) > > This mean that you might not want to use quote everywhere just to say > 'here is a list data structure'. > > The preference for vectors as data structure when possible is to make > code more lisible. Using a list is just adding more parens, in a > language with lot of parens. Doesn't help the reading. > > Using syntaxic sugar for vector, on the contrary help the reading. > > On 27 oct, 01:08, e <evier...@gmail.com> wrote: > > not necessarily. > > > > [1 2 3] is a vector that is not evaluated. Since there is no overload > with > > things that are, there's no need for a special mark. > > > > '(1 2 3) is currently a way of say, "don't evaluate this list", but it > could > > have been: > > > > '(1 2 3) is a list that is not evaluated. No loss of generality. it's a > > special type of list. One that's not evaluated. as opposed to a special > > indicator to the repl. > > > > On Wed, Oct 26, 2011 at 6:09 PM, Mark Rathwell <mark.rathw...@gmail.com > >wrote: > > > > > > > > > > > > > > > > > The point to think about here is that functions are also lists, the > > > same as your list of integers. The difference is that one is > > > evaluated, the other is not. That is what the quote is saying: "don't > > > evaluate me". The quote is not actually a part of the list. It's just > > > the way you tell the reader not to evaluate the list that follows. > > > > > So the question is should all unevaluated forms be preceded with a > > > quote in the repl output? To me that would be more confusing. > > > > > On Wed, Oct 26, 2011 at 5:34 PM, e <evier...@gmail.com> wrote: > > > > long long time since I last looked a clojure, but I've never lost > > > > interest and I'm trying to find the time again. > > > > > > for the short version see "*INCONSISTENT*", in the example at the > end. > > > > > > I know what the answer will be here. Something like "you will get > > > > used to it". or "it's not important". or "no one hardly uses lists > > > > anymore, anyway, since vectors are not purely contiguous". But, if > > > > you can make things better and it's easy, then why not? > > > > > > So here's the deal: > > > > > > I still think the following is only inconsistent because that's how > it > > > > was in older lisps. Specifically, lists had to be quoted so the > first > > > > argument wouldn't be called as a function. I asked long ago (here > and > > > > in person) why, then regular functions couldn't require the quote so > > > > the paren could be reserved for the list data structure, and Rich > > > > answered that it'd simply be a pain to have to quote every function > > > > call. Well, my mind moves slowly. I'm just now realizing to ask, > > > > "Ok, then how about making the list really be defined using the > single > > > > quote as part of it just like sets include the sharp to distinguish > > > > them from maps?". That's a much simpler explanation than saying, > "you > > > > have to escape them, etc, etc." I realize this is a small matter > since > > > > all I am talking about is how lists are represented as text. > > > > > > checking out the "Try Clojure": > > > > > > if you type the following, you get output that matches what you typed > > > > in every case except for lists. > > > > > > Vectors: --> [1 2 3 4] > > > > [1 2 3 4] > > > > > > Maps: --> {:foo "bar" 3 4} > > > > {:foo "bar" 3 4} > > > > > > Lists: --> '(1 2 3 4) > > > > (1 2 3 4) <----- *INCONSISTENT* why not render this as '(1 2 3 4) > ... > > > > this would make much more sense to newbies. > > > > > > Sets: --> #{1 2 3 4} > > > > #{1 2 3 4} > > > > > > -- > > > > 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 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 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 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