Kotlin Lambda: Exercises, Practice, Solutions
Kotlin Lambda expressions and anonymous functions Exercises [ 14 exercises with solution ]
[An editor is available at the bottom of the page to write and execute the scripts. Go to the editor]
1. Write a Kotlin program that implements a lambda expression to multiply two numbers and return the result.
2. Write a Kotlin program that implements a lambda expression to find the square of a number and return the result.
3. Write a Kotlin program that implements a lambda expression to check if a number is even.
4. Write a Kotlin program that implements a lambda expression to calculate the average of a list of numbers.
5. Write a Kotlin program that implements a lambda expression to filter a list of strings. It returns only strings starting with the letter 'K'.
6. Write a Kotlin program that implements a lambda expression to sort a list of integers in descending order.
7. Write a Kotlin program that implements a lambda expression to convert a list of strings to uppercase.
8. Write an anonymous Kotlin function to check if a string is a palindrome.
9. Write an anonymous Kotlin function to calculate the factorial of a number.
10. Write an anonymous Kotlin function to find the maximum element in an array.
11. Write an anonymous Kotlin function to count the number of vowels in a string.
12. Write an anonymous Kotlin function to calculate the sum of all odd numbers in a list.
13. Write an anonymous Kotlin function to concatenate two strings and return the result.
14. Write an anonymous Kotlin function to find the average of the squares of a list of numbers.
More to Come !
* To run the code mouse over on Result panel and click on 'RERUN' button.*
Kotlin Editor:
Do not submit any solution of the above exercises at here, if you want to contribute go to the appropriate exercise page.
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/kotlin-exercises/lambda/index.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics