/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def generateSin(amplitude,frequency,phase,x): return [x,amplitude * math.sin(x * frequency + phase)] print [generateSin(10, 1, 0, x) for x in range(10)] ''' [[0, 0.0], [1, 8.4147098480789655], [2, 9.0929742682568175], [3, 1.4112000805986722], [4, -7.5680249530792825], [5, -9.5892427466313848], [6, -2.7941549819892586], [7, 6.5698659871878906], [8, 9.8935824662338181], [9, 4.1211848524175663]] ''' #this will flatten the list print sum([generateSin(10, 1, 0, x) for x in range(10)],[]) ''' [0, 0.0, 1, 8.4147098480789655, 2, 9.0929742682568175, 3, 1.4112000805986722, 4, -7.5680249530792825, 5, -9.5892427466313848, 6, -2.7941549819892586, 7, 6.5698659871878906, 8, 9.8935824662338181, 9, 4.1211848524175663] '''