Name: Anonymous 2022-10-31 18:14
So you think [1,2]*2 = [2,3]?
Think harder you dumb nigger!
Because in Python [1,2]*2 == [1,2,1,2]
Think harder you dumb nigger!
Because in Python [1,2]*2 == [1,2,1,2]
1*2 = 2
but 2*2 = 3
.And if you're super retarded and believe that xs[0:4:1] is just xs[4:0:-1] reversed, then think twice, because Pissthon is not your african mathematics where everything is symmetric.
[:3]
to select the first 3 characters, and [3:]
to select everything but the first 3."But wait! How can I get [7, 6, 5, 4, 3, 2, 1]" - a mental midget will ask in vain, missing the obvious fact that Pukethon provides no way to reverse a list with a [start:stop] range.
xs = [1, 2, 3, 4, 5, 6, 7]
xs[0::1] -> [1, 2, 3, 4, 5, 6, 7]
xs[0:None:1] -> [1, 2, 3, 4, 5, 6, 7]
xs[6::-1] -> [7, 6, 5, 4, 3, 2, 1]
xs[6:None:-1] -> [7, 6, 5, 4, 3, 2, 1]
xs[::1] -> [1, 2, 3, 4, 5, 6, 7]
xs[::-1] -> [7, 6, 5, 4, 3, 2, 1]
Same logic applies to numeric ranges, therefore range(0,10,-2) != range(10,0,-2)
When splicing lists over their entire length, you should either not specify end at all, or use None
None
maps closely to NIL
in something like Common Lisp, where it can stand either for false, or nothing [assume default] (for example, end arguments to STRING=
).xs = [1, 2, 3, 4, 5, 6, 7]
a = 0
xs[:a:-1] -> [7, 6, 5, 4, 3, 2]
a = None
xs[:a:-1] -> [7, 6, 5, 4, 3, 2, 1]
end
argument to STRING=
can accept either an integer or a NIL
value (the so called bounding index designator), python's slice (https://docs.python.org/3/library/functions.html#slice) can likewise take either an integer, or None, in which case it takes on some default behavior defined inside the function.