print get_verb_i
# 0.0395220100000042
A:
Use a list comprehension.
(i.e. replace the with a { })
L = [3*i for i in L]
print(L)
Output
[3, 6, 9, 12, 15, 18, 21, 24, 27, 30]
You can also use math.floor to split your list by 3 and then you can convert it to an int:
L = [int(n) for n in (math.floor(i / 3) for i in L)]
2, 4, 6, 10}
function foo(vector)
local len = #vector
for i = 1, len do
vector[i] = math.floor(i / 3)
end
end
In the foo function you can specify arguments as an array and use them as array elements. In foo(10, 20, 30) the first argument is a tuple, but that is just how Erlang's syntax works:
If a function is of arity n, it is always called with n parameters: each argument is
supplied by an actual argument that is the head of a tuple of length n-1.
As a side note, I'm not sure that #a is the same as #1:
a = a * 10
?a
>?a
1
a #1
3
If you have that problem, Erlang has excellent documentation, but you may need to take some time to study it. I'll be happy to help.
Q:
How to add attributes to arrays without recreating the array in Python?
I want to add additional attributes to an array, but I don't want to recreate the whole array.
For example, I have this array
a = np.array([[1, 2], [3, 4]])
and I want to add another attribute to it (a.shape = (2,2)) without recreating a new array.
How do I achieve this in Python?
To append additional attributes to an array, you can use the.copy() method:
import numpy as np
a = np.array([[1, 2], [3, 4
Related links:
コメント