List Frequency
This page has been deleted from the main contents of the wiki, and moved to the deleted: namespace as a record of its contents. Rather than adding content to this page, please put it somewhere where it will actually have a use. In addition, please avoid linking to this page.

Routine Summary

Returns a list of the frequency of values in another list.

Inputs

L₁ - the list you want to find the frequency of

Outputs

L₂ - the values of L₁ without repetition
L₃ - the frequencies of the values in the list L₂

Variables Used

L₁, L₂, L₃, I

Calculator Compatibility

TI-83/84/+/SE

Author

DarkerLine

URL: United TI

listfrequency.zip

``````:{L₁(1→L₂
:{1→L₃
:For(I,2,dim(L₁
:If max(L₂=L₁(I:Then
:L₃+(L₂=L₁(I→L₂
:Else
:augment(L₂,{L₁(I→L₂
:augment(L₂,{1→L₃
:End:End```
```

With our list of values stored in L₁, we store the first element of L₁ to L₂ to initialize it, and store a value of one to L₃ because that value has appeared once in the list (by default it is the first value and thus we know it appeared). We then begin looping in the second element to avoid an extra increment and then through all of the elements of L₁.

When determining the frequency of a value, we need to check to see if the particular element (in this case, L₁(I)) has already appeared in L₂. If it has, we increment (add one) to its respective frequency in L₂. However, if the value has never appeared in L₁, we add that value as a new element to the end of L₂ and also set its frequency to one. We repeat this until we have the frequency of all of the values in L₁ stored in L₂.

When you are done using L₁, L₂, and L₃, you should clean them up at the end of your program.