Note that there are some explanatory texts on larger screens.

plurals
  1. POpassing contents of a list to different functions
    text
    copied!<p>I have a list like the following,</p> <pre><code>plist = [[('s', [0.0, 0.1, 0.0, 0.4, 0.0]), ('aa', [0.0, 0.1, 0.0, 0.5, 0.0])], [('m', [0.0, 0.0, 0.1, 0.3, 0.0]), ('ih', [0.0, 0.1, 0.1, 0.2, 0.0])], [('k', [0.0, 0.1, 0.0, 0.1, 0.0]), ('l', [0.0, 0.1, 0.0, 0.6, 0.0]), ('eh', [0.0, 0.1, 0.0, 0.0, 0.0]), ('k', [0.0, 0.1, 0.0, 0.0, 0.0])], [('t', [0.0, 0.1, 0.0, 0.1, 0.0]), ('aa', [0.0, 0.1, 0.0, 0.0, 0.0])], [('n', [0.0, 0.1, 0.1, 0.2, 0.0]), ('ih', [0.0, 0.1, 0.1, 0.0, 0.0]), ('t', [0.0, 0.1, 0.0, 0.0, 0.0])], [('g', [0.0, 0.1, 0.0, 0.4, 0.0]), ('eh', [0.0, 0.1, 0.0, 0.0, 0.0]), ('l', [0.0, 0.1, 0.0, 0.5, 0.0])], [('v', [0.3, 0.0, 0.1, 0.1, 0.0]), ('ae', [0.0, 0.1, 0.1, 0.0, 0.0])], [('n', [0.0, 0.1, 0.1, 0.2, 0.0]), ('ih', [0.0, 0.1, 0.1, 0.0, 0.0])], [('k', [0.0, 0.1, 0.0, 0.0, 0.0]), ('aa', [0.0, 0.1, 0.0, 0.0, 0.0])], [('p', [0.0, 0.0, 0.3, 0.0, 0.0]), ('l', [0.0, 0.1, 0.2, 0.0, 0.0])], [('k', [0.0, 0.1, 0.1, 0.0, 0.0])]] </code></pre> <p>This list is generated from a function. I need to pass the values from the list to different functions. Since there are 5 values inside each inner list therefore I have 5 functions. Now I have to use the values in these functions like the following,</p> <pre><code>def lips_part_bezier(u_value) : """ Calculating sampling points using rational bezier curve equation""" p0 = 0.0 (1st value of 's') p3 = 0.0 (1st value of 'aa') p1 = p0 p2 = p3 u = u_value p_u = math.pow(1 - u, 3) * 0.7 + 3 * u * math.pow(1 - u, 2) * 0.23 \ + 3 * (1 - u) * math.pow(u, 2) * 0.1 + math.pow(u, 3) * 0.52 p_u = p_u * w d = math.pow(1 - u, 3) * w + 3 * u * w * math.pow(1 - u, 2) + 3 * (1 - u) * w * math.pow(u, 2) + math.pow(u, 3) * w p_u = p_u / d #print "p(u) = ", p_u return p_u </code></pre> <p>The u_value is passed from another function. There are other functions with the same operation. The second function takes the second values of 's' and 'aa' and so on. This is the first iteration. In the next iteration, p0 in all the functions is the previous p1 and p1 would be the next values from the list. This continues till there are no values left in the list. Also, the list is generated in another function. Being a beginner this looks a bit complicated for me. Thank you. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload