This page is dedicated to showcase small snippets of code may be useful. These small routines are designed to accomplish tasks involving lists, matrices, and their attributes. Unless specified, output is in Ans.
Index of Maximum List Element – jonbush
This line finds the index of first occurrence of a specific value in a list.
The list to be searched is in Ans at the beginning.
This can also be used to find the index of the minimum or of any other value in place of "max(Ans"
Number of Elements Less than X – kg583
This line counts the number of elements in a list less than some number X.
The list to be searched is in Ans.
Replace < with > to return the number of elements greater than X, ≤ for numbers less than or equal to X and ≥ for numbers greater than or equal to X.
Shuffle a list
This routine is the fastest way to shuffle a list. L1 is the list to be shuffled and L2 is a temporary list used to do the shuffling. Make sure to clean up L2 after your program.