Question: The general functions like Program 108 (page 248) are the kind where the index array notation is really useful. Write reverse, copy, and clip using

The general functions like Program 108 (page 248) are the kind where the index array notation is really useful. Write reverse, copy, and clip using index array notation.


Data from Program 108

def reverse(source): target = makeEmptySound (getLength(source)) getlength (source)-1 for targetIndex in range (0,getLength(target)): sourceIndex = sourceValue = getSampleValueAt (source, sourceIndex) setSampleValueAt (target, targetIndex, sourceValue) - 1 sourceIndex = sourceIndex return target

def reverse(source): target = makeEmptySound (getLength(source)) getlength (source)-1 for targetIndex in range (0,getLength(target)): sourceIndex = sourceValue = getSampleValueAt (source, sourceIndex) setSampleValueAt (target, targetIndex, sourceValue) - 1 sourceIndex = sourceIndex return target

Step by Step Solution

3.34 Rating (157 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

def reverse2source target makeEmptySoundgetLengthsource targetSamples getSamplestarget ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Introduction to Computing and Programming in Pytho Questions!