The parameter of the operation is not a function, it is the first order function
We use specific code to illustrate:
Package com.dt.scala.datasetobject listfirstorderops { def main (args: Array[string]): unit = { //list Merge, using::: operator &NBSP;&NBSP;&NBSP;&NBSP;PRINTLN ( List::: List (3,4)::: List (5,6)) println (list):::(list (3,4)::: List (5,6))) // the length of the list println (list (1,2,3,4,5,5). Length) val bigdata = list ("Spark", "Hadoop", "Kafka") //the last element of the list println (bigdata.last) //kafka //selects all elements except the last element println (Bigdata.init) //list (spark, hadoop) //reverses the position of elements in the list println (Bigdata.reverse) //list (Kafka, hadoop, spark) Take the first n elements println (Bigdata.take (2)) //take all the elements except the first n println (Bigdata.drop (2) // split list to two list at n position. The effect is equivalent to (c take n,c drop n) But Splitat is more efficient println (bigData.splitAt ( 2) //(list (spark, hadoop), List (Kafka)) //The value of the element by index, and the index starts with 0 . Execution requires time index values to be proportional. println (Bigdata.apply (2)) //kafka println (BigData (2)) // actually calls the Apply method val data = list ("a" , "B", "C", "D", "E", "F", "G") //produce a range println with the index of the list (data.indices ) //range (0, 1, 2, 3, 4, 5, 6) //zip operation with index and data, This operation is called the zipper Operation println (Data.indices zip data) //vector ((0,a), (1,b), (2,c), (3,d), (4,e), (5,f), (6,g)) // list provides a way to implement the above zipper operation println (Data.zipwithindex) //Convert list to String println (Data.tostring ()) //"list (a, b, c, d, e, F,&NBSP;G) " //uses strings to stitch together elements in the list println (data.mkstring (" < ", ",", ">") //"<a,b,c,d,e,f,g>" println (data.mkstring (",")) //"A,b,c,d,e,f,g" println (data.mkstring) //"ABCDEFG" val buffer = new StringBuilder //Append all elements of the list to the StringBuilder object data.addstring (buffer) // with Data.mkstring ("<", ",", ">") this operation type, except that addstring will append the string / /To StringBuilder object data.addstring (buffer, "<", ",", ">") &NBSP;&NBSP;&NBSP;PRINTLN (buffer) //array and list mutual transfer &nbsP;val arr = data.toarray println (arr.tolist) //Get iterators val iterator = data.iterator println (Iterator.next ()) println (Iterator.next ()) }}
This article is from the "Ding Dong" blog, please be sure to keep this source http://lqding.blog.51cto.com/9123978/1741966
33rd: List of the first-order function operation code to combat the detailed