0

In Python I believe a list is considered as a 1 dimensional vector.

how do I define a list A = [1, 2, 100, 300] for example whose elements is of set B provided that the element is more than zero:

B ={-1, -2, 1, 2, -300, 100, -100, 300}

would this definition below be correct ? :

$$A = [h]_{\forall h\in B: h>0}$$

Thanks !

5201314
  • 2,227
  • I'm not sure I understand what you're looking for. You can't represent a vector with a set so if I'm understanding your question correctly, then the answer is no. – Oussema Jul 25 '21 at 03:32
  • thanks @Oussema, I next a list of elements that belongs to a set. I cant have a set (instead of list) of above elements cause set does not allowed for repeated element, as seen in the example above. If vector is not the right representation of this python list, feel free to advice what should I represent it with :) – user21872 Jul 25 '21 at 03:36
  • Are you looking for mathematical notation to denote the vector with all the negative entries removed? – Oussema Jul 25 '21 at 03:39
  • You're using set-builder notation which doesn't work for vectors: https://en.wikipedia.org/wiki/Set-builder_notation . If you want to know whether a similar notation for vectors exists then check out this question: https://math.stackexchange.com/questions/3332039/builder-notation-for-vectors – Oussema Jul 25 '21 at 03:45
  • thanks @Oussema for pointing to this answer. I dont understand why it should be a summation though, let me digest on this a bit. wonder why theres no simpler notation a the set builder notation. they are almost similar except for the characteristic (duplicate elements, etc) – user21872 Jul 25 '21 at 03:52
  • The Python syntax for this is A = [x for x in B if x > 0]. If B is originally defined as a set, it will not include repeated elements, but if B = [-1, -2, 1, 2, -300, 100, -100, 2, 300, 1] (a list), then both B and A will include repeated elements. – John Palmieri Jul 25 '21 at 03:53
  • thanks @johnPalmieri, Ive corrected/editted the question. the set elements shouldnt contains duplicates of element – user21872 Jul 25 '21 at 03:58

0 Answers0