380 likes | 504 Views
1320 Principles Of Programming I. Chapter 7-B Array Functions. Dr. Thomas Hicks Computer Science Department Trinity University. 1. 6. Storage Of ActNo (Review). Use arr(0) To Store ActNo. 6. 0. 7. 5. 2. 4. 3. 0. 5. 2. 1. 1. ActNo . 5. 0. nos. Time
E N D
1320Principles Of Programming I Chapter 7-BArray Functions Dr. Thomas Hicks Computer Science Department Trinity University 1 6
Storage OfActNo (Review)
Use arr(0) To Store ActNo 6 0 7 5 2 4 3 0 5 2 1 1 ActNo 5 0 nos
Time System.nanoTime
arr.drop(n) Return An Array, Or List, With The First N Elements Removed
arr.drop(n) • Explicitly returns an Array, or List, with n elements removed from the front.
arr.init Return An Array, Or List, With The Last Element Removed
arr.init • Explicitly returns an Array, or List, with n elements removed from the rear.
arr.head & arr.first Return The First Element Of The Array Or List
arr.head & arr.first • Explicitly returns the first element in the Array or List.
arr.last Return The Last Element Of The Array Or List
arr.last • Explicitly return the Last Element in the Array or List.
arr.slice(f,l) Return The Array, or List, Beginning With Element f & Continuing To The Element Just Before l
arr.slice(f,l) • Explicitly returns an Array, or List, Beginning With Element f & Continuing To The Element Just Before Element l.
arr.splitAt(n) Return A Tuple Containing Two Arrays The First Array Contains The First Portion Of The List (Up To, But Not Including Element n) The Second Array Contains The Items From Element n To The End.
arr.splitAt(n) • Explicitly Return A Tuple Containing Two Arrays The First Array Contains The First Portion Of The List (Up To, But Not Including Element n) The Second Array Contains The Items From Element n To The End..
arr.take(n) Return The Array, or List, Of n Elements Taken From The Beginning/Left
arr.take(n) • Explicitly Return The Array, or List, Of n Elements Taken From The Beginning/Left • .
arr.takeRight(n) Return The Array, or List, Of n Elements Taken From The End/Right
arr.takeRight(n) • Explicitly Return The Array, or List, Of n Elements Taken From The End/Right • .
arr.contains(n) Return true If n Is In The List Or Array
arr.contains(n) • Explicitly Return trueIf n Is One Of The Data Element Members Of The List Or Array; Otherwise Return false • .
arr.isEmpty Return true If The Array, Or List, Is Empty – Has 0 Data Element Members
arr.isEmpty • Explicitly Return trueReturn true If The Array, Or List, Is Empty – Has 0 Data Element Members; Otherwise Return false • .
arr.nonEmpty Return true If The Array, Or List, Is Empty – Has 0 Data Element Members
arr.nonEmpty • Explicitly Return trueReturn true If The Array, Or List, Is Empty – Has At Least 1, or more, Data Element Members; If Empty, Return false • .
arr.startsWith(arr) Return true If The Array, Or List, Is Starts With The PassedArray
arr.startsWith(arr1) • Explicitly Return true If The Array, Or List, Is Starts With The Passed Array. • .
arr.indexOf(n) Return The Element Subscript If The n Is A Member Of The Array, or List; Return -1 If The Element Is Not In The Array Or List
arr.indexOf(n) • Explicitly Return The Element Subscript If The n Is A Member Of The Array; Return -1If The Element Is Not In The Array.
arr.lastIndexOf(n) Return The Element Subscript If The n Is A Member Of The Array, Or List; Return -1 If The Element Is Not In The Array Or List
arr.lastIndexOf(n) • Explicitly Return The Element Subscript If The n Is A Member Of The Array; Return -1 If The Element Is Not In The Array.
arr.diff(arr1) Return An Array, Or List, Containing Those Elements In arr1, That Are Not In arr.
arr.diff(arr1) • Explicitly Return An Array Containing Those Elements In arr, That Are Not In arr.
arr.reverse Return An Array, Or List, Whose Elements Are In Reverse Order
arr.reverse • Explicitly Return An Array Whose Elements Are In Reverse Order.
Principles Of Programming ICSCI 1320 Dr. Thomas E. Hicks Computer Science DepartmentTrinity University Textbook: An Introduction to Programming with ScalaBy Dr. Mark Lewis Special Thanks To Dr. Mark Lewis For Providing Some Of Text For Use In This Presentation.