Join Peggy Fisher for an in-depth discussion in this video Perform functions on lists, part of Foundations of Programming: Discrete Mathematics.
- [Voiceover] Ok, now that we've seen how to create…lists in SML, let's take a look at how to perform functions…on lists.…To do this, we're going to need to write our own…new functions.…Let's start by writing a function…that finds the sum of all the items in a list.…Here, I have a short list with some prime numbers.…Let's write a function that will add all the numbers.…I need to start by typing in "fun"…to tell the interpreter i'm creating a new function.…We'll call it "sum".…Now in parentheses, I need to tell the interpreter…what to expect.…
So i'm going to put two square brackets, open and closed,…so that it knows to expect a list.…I close my parentheses…and now i have to give it a default value…in case the user does not provide any elements in the list.…In that case, I want the function just to return a zero.…Ok we took care of that base case there.…Now, I want to create a recursive process…that will go through all the elements in the list.…So i'm going to call "sum" again.…I give a value to each element in the array…
This course relies on an open-source SML (standard machine language) library to demo the concepts behind discrete math. Peggy Fisher shows you how to manipulate sets of data, write proofs and truth tables, analyze data sequences, and visualize data using graph theory. Challenges at the end of every chapter allow you to test your knowledge. By the end of the course, you should be able to make the leap from theory to using discrete math in practice: saving time and resulting in code that's cleaner and easier to maintain in the long run.
- Real-world discrete math
- Objects as sets
- Set notation and operations
- Standard machine language (SML) setup
- Working with data types, strings, and functions in SML
- Analyzing data sequences
- Writing truth tables
- Identifying and evaluating predicates
- Validating arguments
- Writing proofs: subset, conditional, and biconditional proofs
- Visualizing data with graphs
- Advanced discrete math techniques
Skill Level Intermediate
Foundations of Programming: Design Patternswith Elisabeth Robson2h 19m Intermediate
1. Discrete Math Uses
3. Setting Up SML
4. Analyzing Data Sequences
5. Effective Arguments and Defensible Decisions
6. Proofs Made Easy
7. Advanced Discrete Math Topics
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.