Revision: 13770
Updated Code
at May 6, 2009 05:35 by iamok
Updated Code
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] '''
Revision: 13769
Updated Code
at May 6, 2009 05:32 by iamok
Updated Code
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)] -output- [(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)],[])
Revision: 13768
Updated Code
at May 6, 2009 04:06 by iamok
Updated Code
def generateSin(amplitude,frequency,phase,x): return amplitude * math.sin(x * frequency + phase) print [(x,generateSin(10, 1, 0, x)) for x in range(10)] -output- [(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)]
Revision: 13767
Updated Code
at May 6, 2009 04:01 by iamok
Updated Code
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)] -output- [(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)]
Revision: 13766
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at May 6, 2009 03:13 by iamok
Initial Code
def generateSin(amplitude,frequency,phase,x): return amplitude * math.sin(x * frequency + phase) print [generateSin(10, 1, 0, x) for x in range(10)]
Initial URL
Initial Description
Initial Title
generate periodic sin
Initial Tags
math
Initial Language
Python