Kotlin has a bunch of built-in higher-order functions.
The built-in higher-order functions can be broadly categorized into three main groups:
1. Scope Functions {let, run, with, also, apply}
2. Collection Operations
3. Utility & Control Flow
As many of Kotlin’s higher-order functions are designed to work with collections, we’re going to introduce you to some of the most useful higher order functions defined in Kotlin’s collections package.
It is hard to say how many HOF are there in Kotlin. But we will cover most of them.
Transform
1. map
2. mapIndexed
3. mapNotNull
4. mapKeys
5. mapValues
6. flatMap
7. flatten
Filter
8. filter
9. filterNot
10. filterIndexed
11. filterIsInstance
12. filterNotNull
13. partition
14. takeWhile
15. dropWhile
Reduce
16. fold
17. foldRight
18. reduce
19. runningFold
20. runningReduce
21. sumOf
22. any
23. all
24. none
25. count
26. takeIf
27. takeUnless
Ordering
28. sortedBy
29. sortedByDescending
30. sortedWith
31. minBy
32. minByOrNull
33. maxBy
34. maxByOrNull
Grouping
35. groupBy
36. associateBy
37. associateWith
Flatten/Window
38. distinct
39. distinctBy
40. chunked
41. windowed
Zip & Join
42. zip
43. unzip
44. zipWithNext
45. joinToString
46. forEach
47. forEachIndexed
48. onEach
49. find/findLast
50. first/last
51. indexOf / indexOfFirst / indexOfLast
52. asSequence
53. generateSequence
54. sequence { } builder + yield / yieldAll
55. Useful Operator (plus/minus intersect union subtract)
In the last we will cover Closure and chain function calls together
Telegram Group: https://t.me/androidNinjaWarrior
Guide to watch:
00:00 What is Higher Order Function?
05:48 map
11:54 mapIndexed
17:35 mapNotNull
23:54 mapKeys
26:58 mapValues
31:21 flatten
32:50 flatMap
37:30 filter
41:06 filterNot
43:36 filterIndexed
48:20 filterIsInstance
51:45 filterNotNull
53:28 partition
58:03 takeWhile
01:01:28 dropWhile
01:04:23 fold
01:07:47 foldRight
01:08:56 reduce
01:13:09 runningFold
01:15:32 runningReduce
01:17:24 sumOf
01:23:04 any
01:24:58 all
01:27:21 none
01:28:45 count
01:30:51 takeIf
01:32:30 takeUnless
01:33:33 sortedBy
01:37:06 sortedByDescending
01:39:30 sortedWith
01:42:25 minBy
01:43:11 maxBy
01:44:04 minByOrNull
01:45:30 maxByOrNull
01:46:25 groupBy
01:53:05 associateBy
01:57:35 associateWith
02:00:00 distinct
02:01:23 distinctBy
02:02:33 chunked
02:05:16 windowed
02:12:49 zip
02:16:50 unzip
02:18:56 zipWithNext
02:24:06 joinToString
02:30:00 forEach
02:32:36 forEachIndexed
02:33:54 onEach
02:36:59 find/findLast
02:39:00 first/last/firstOrNull/lastOrNull
02:40:34 indexOf / indexOfFirst / indexOfLast
02:43:14 asSequence
02:46:58 generateSequence
02:51:50 sequence builder + yield / yieldAll
02:55:00 plus minus Operator
02:57:10 intersect Operator
02:58:40 union Operator
02:59:19 subtract Operator
03:00:30 closure
03:02:09 chain function calls together
03:04:46 Revision of Higher Order Function
#HOF #higherOrderFunction #Built-in #kotlin #Collection #lambda #collectionOperation #higher #higherOrder #function #typeOfHOF #closure #chainFunctionCall #chainFunction
Disclaimer- Some content are used for educational purposes under fair use.
Copyright Disclaimer Under Section 107 of the Copyright Act 1976, allowance is made for "fair use" for purposes such as criticism, comment, news reporting, teaching, scholarship, and research. Fair use is a use permitted by copyright statute that might otherwise be infringing. Non-profit, educational, or personal use tips the balance in favor of fair use. All credit for copyright material used in the video goes to the respected Owner.
Thank you guys.