Hi, As far as I know, the difference between `ArrayComprehension` and `list` lies in the notion of multidimensionality.
First of all, for clarification, > `List(i + j, (i,0,3), (j,0,4))` is the unevaluated form of `[i + j for i in range(4) for j in range(5)]`. is not quite true regarding the implementation of `ArrayComprehension`. In fact, `ArrayComprehension(i + j, (i,0,3), (j,0,4))` will be like `[[i + j for i in range(5)] for j in range(4)]`. Not to mention the different order of dimensions because the limits in `ArrayComprehension` are executed from left to right, the resulting output is a multidimensional list. So each time there is one more limit, the dimension of output list will +1. As you can see, `ArrayComprehension` is more likely to be a such structure: [[[...]...]...]. This multidimensionality comes from Table <https://reference.wolfram.com/language/ref/Table.html> in Wolfram Mathematica, which is the the example of the implementation of `ArrayComprehension`. Secondly, the implementation follows the example of `Array` module in SymPy, which means the properties and functions like `shape`, `rank()` have been already implemented.Plus, its output is of type `ImmutableDenseNDimArray`. Since an array has by default a notion of multidimensionality, it would be more coherent to call it as an array. That's why its name is `ArrayComprehension` rather than `ListComprehension`. However, it is no doubt that `ArrayComprehension` resembles a lot to list. It would be a good idea to have something similar to list implemented in SymPy, in order to add a notion of 'immutable' to list. Either renaming ArrayComprehension or creating a new module to do so is faisible. That's what I have understood while implementing `ArrayComprehension`. I hope that it could help make some concepts clear. Zhiqi 在 2019年6月4日星期二 UTC+2上午5:46:03,Chris Smith写道: > > From discussion at #16926 <https://github.com/sympy/sympy/pull/16929> where > I suggest that perhaps we should be naming ArrayComprehension as List and > it was said, > > > [ArrayComprehension] is supposed to be a multidimensional list > comprehension > > It looks like an unevaluated List to me: `List(i + j, (i,0,3), (j,0,4))` > is the unevaluated form of `[i + j for i in range(4) for j in range(5)]`. > (For comparison, Integral and Sum are examples of an unevaluated Expr, > which, after a doit and the right conditions, lose the wrapper and become > other Expr.) > > An evaluated form would be `List([1, 2, 3, 4])` where the `[]` would be > necessary to distinguish between the evaluated and comprehension form. > > Are we going to regret introducing an object that is so closely related to > a list or will we always want a list to be an unsympified object in SymPy? > > /c > -- You received this message because you are subscribed to the Google Groups "sympy" group. To unsubscribe from this group and stop receiving emails from it, send an email to sympy+unsubscr...@googlegroups.com. To post to this group, send email to sympy@googlegroups.com. Visit this group at https://groups.google.com/group/sympy. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/d7ddeb50-61ed-434a-8354-9fa54a1f9ed5%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.