From the course: Mathematica 11 Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Identify the first or last item in a list

Identify the first or last item in a list - Mathematica Tutorial

From the course: Mathematica 11 Essential Training

Start my 1-month free trial

Identify the first or last item in a list

- [Instructor] When you store data in a Mathematica list, you might just care about the collection as a whole and not the individual items. On the other hand, you might want to find the first and last item of the list. Those elements could represent your first or last measurement of an experiment, which might provide insights into your results. I'm working in a blank Mathematica notebook. So I will start by creating a list. I'll call it mlist = and then a left curly bracket, and let's just say that I have the values, one, five, eight, nine and 14, all separated by commas. Then a right curly bracket, shift + enter, and there's my list. This is a very simple list and it will be easy to verify what the first and last values are, but you can imagine that if you had a list of thousands of values that the first and last keywords would be much easier to use than trying to find length, or even referring to a specific position. With that in mind, I will use the first keyword to display the…

Contents