Hello Everyone,
I am proposing new transformation operator syntax that can be used in various ways including creating ranges, type conversion, and applying functions:
a = (1..10) # list of numbers from 1 to 10 inclusive
a = (0.0..1.0) # list of numbers from 0 to 1 by 0.1 inclusive.
((1,0.02)..2) #list of numbers from 1 to 2 by 0.02 by using tuple value
(1..(2,0.02)) #list of numbers from 1 to 2 by 0.02 by using tuple value
a_length = a..len # same as len(a) as a piping functionality.
a_map = a..(map, map_function) # same as map(map_function, a)
a_map = a..(lambda _:map(map_function,_)) # same as map(map_function, a)
a_filter = a..(filter, filter_function) # same as filter(filter_function, a)
a=1.0
a_int = a..int # same as int(a)
a_str = a..str # same as str(a)
We can also use another forms of this operator for extended functionalities including (<.., >.., ^..) or (... or ...., ....., ......) to be used as exclusive types of transformations.
a = (1..10) # list of 1 to 10, general
a = (1~..10) # list of 1 to 10
a = (1*..10) # list of 1 to 10
a = (1+..10) # list of 1 to 10
a = (1-..10) # list of 1 to 10
a = (1/..10) # list of 1 to 10
a = (1%..10) # list of 1 to 10
a = (1<..10) # list of 1 to 9
a = (1>..10) # list of 2 to 10
a = (1^..10) # list of 2 to 9
a=[1,2,3]+..[4,5,6] # add 2 matrices
a=[1,2,3]-..[4,5,6] # subtract 2 matrices
a=[1,2,3]*..[4,5,6] # multiply 2 matrices
a = 1
a ..=10 # list of 1 to 10, general
a ~..=10 # list of 1 to 10
a <..=10 # list of 1 to 9
a >..=10 # list of 2 to 10
a ^..=10 # list of 2 to 9
There can particular focus on .. operator for the proposal, and the other operator can be divided into a different topic or proposal as an extension if needed.
a = ((1, True)..(10, False)) # list of 1 to 9 using tuple value
a = ((1, False)..(10, True)) # list of 2 to 10 using tuple value
a = ((1, False)..(10, False)) # list of 2 to 9 using tuple value
If there is a need to seperate the range and pipe functionality, we can use the operator :: or ::: for ranges while .. for pipe functionality.
a=(1::10) # list of values from 1 to 10 # used in arrays for [::] value.
a=(1:::10) # list of values from 1 to 10
a_str=a..str # str(a)
Thank you