Difference between revisions of "TI-BASIC:List Frequency2"
(Initial automated import) |
(Automated @@ correction) |
||
Line 1: | Line 1: | ||
{{Template:TI-BASIC:Routine | {{Template:TI-BASIC:Routine | ||
− | |picture= | + | |picture= |
|summary=Returns a list of the frequency of values in another list sorted. | |summary=Returns a list of the frequency of values in another list sorted. | ||
|input=''L₁'' - the list you want to find the frequency of | |input=''L₁'' - the list you want to find the frequency of | ||
Line 8: | Line 8: | ||
|compatibility=TI-83/84/+/SE | |compatibility=TI-83/84/+/SE | ||
|author=Galandros | |author=Galandros | ||
− | |authors= | + | |authors= |
|url=http://www.unitedti.org/index.php?act=ST&f=63&t=8202 United TI | |url=http://www.unitedti.org/index.php?act=ST&f=63&t=8202 United TI | ||
|download=[file listfrequency2] | |download=[file listfrequency2] |
Latest revision as of 22:12, 24 February 2016
Routine Summary
Returns a list of the frequency of values in another list sorted.
Inputs
L₁ - the list you want to find the frequency of
Outputs
L₂ - the values of L₁ without repetition sorted L₃ - the frequencies of the values in the list L₂ sorted
Variables Used
L₁, L₂, L₃, θ
Calculator Compatibility
TI-83/84/+/SE Author
GalandrosURL: United TI Download
:DelVar L₂DelVar L₃SortA L₁ :For(θ,1,dim(L₁ :L₁(θ→L₂(1+dim(L₂ :sum(L₁=Ans→L₃(dim(L₂ :θ-1+Ans→θ :End
In the first line we initialize L₁, L₂, and L₃. We sort L₁ so like values will be adjacent.
Then we start looping by storing the first value encountered to the next element of list L₂. In the next line we find the frequency of the value already stored in L₂ and is stored to the correspondent element in L₃. θ is increased by the frequency found minus 1 to pass to next number, but then incremented by 1 in the For loop. We loop we reach the end of L₁.
And that's it. The output is put on L₂ and L₃ already sorted. Notice how well Ans is used for speed and size optimization.
When you are done using L₁, L₂, and L₃, you should clean them up at the end of your program.