package solution object LambdaKotlin { @JvmStatic fun main(args: Array<String>) = listOf("hola","mundo","cruel").forEach(::println) }
/*** Created by Javatlacati on 26/10/2016.*/- package solution
- object LambdaKotlin {
- @JvmStatic
fun main(args: Array<String>) {val arr=arrayOf("hola","mundo","cruel")arr.forEach {println(it)}}- fun main(args: Array<String>) = listOf("hola","mundo","cruel").forEach(::println)
- }
// You can test using JUnit or KotlinTest. JUnit is shown below // TODO: replace this example test with your own, this is just here to demonstrate usage. // TODO: replace with whatever your package is called package solution import org.junit.Test class TestExample { @Test fun test() { LambdaKotlin.main(arrayOf<String>()) } }
- // You can test using JUnit or KotlinTest. JUnit is shown below
- // TODO: replace this example test with your own, this is just here to demonstrate usage.
- // TODO: replace with whatever your package is called
- package solution
- import org.junit.Test
- class TestExample {
- @Test
- fun test() {
- LambdaKotlin.main(arrayOf<String>())
- }
- }
package solution fun tribonacci(n: Int, signature: Triple<Int, Int, Int> = Triple(1, 1, 1)) = generateSequence(signature) { Triple(it.second, it.third, it.first + it.second + it.third) } .map { it.first } .take(n) .toList()
fun tribonacci(signature: DoubleArray, n: Int) = generateSequence(Triple(signature[0], signature[1], signature[2])) {Triple(it.second, it.third, it.first + it.second + it.third) }- package solution
- fun tribonacci(n: Int, signature: Triple<Int, Int, Int> = Triple(1, 1, 1)) =
- generateSequence(signature) { Triple(it.second, it.third, it.first + it.second + it.third) }
- .map { it.first }
- .take(n)
- .toList()
.toDoubleArray()fun main() {val array = doubleArrayOf(1.0,1.0,1.0)tribonacci(array, 10)}
package solution import kotlin.test.assertEquals import org.junit.Test class TestExample { @Test fun testTribonacci() { assertEquals(listOf(1), tribonacci(1)) assertEquals(listOf(1, 1, 1, 3, 5, 9, 17, 31, 57, 105), tribonacci(10)) assertEquals(listOf(2, 2, 2, 6, 10, 18, 34, 62, 114, 210), tribonacci(10, Triple(2, 2, 2))) } }
// You can test using JUnit or KotlinTest. JUnit is shown below// TODO: replace this example test with your own, this is just here to demonstrate usage.// TODO: replace with whatever your package is called- package solution
- import kotlin.test.assertEquals
- import org.junit.Test
- class TestExample {
@Testfun tribonacci() {}- @Test
- fun testTribonacci() {
- assertEquals(listOf(1), tribonacci(1))
- assertEquals(listOf(1, 1, 1, 3, 5, 9, 17, 31, 57, 105), tribonacci(10))
- assertEquals(listOf(2, 2, 2, 6, 10, 18, 34, 62, 114, 210), tribonacci(10, Triple(2, 2, 2)))
- }
- }
import java.util.stream.Stream; public class AbbreviateTwoWords { public static String abbrevName(String name) { return Stream.of(name.split(" ")) .map(it -> it.substring(0, 1).toUpperCase()) .reduce((l, r) -> l + "." + r) .get(); } }
public class AbbreviateTwoWords {- import java.util.stream.Stream;
- public class AbbreviateTwoWords {
- public static String abbrevName(String name) {
String[] names = name.split(" ");return (names[0].charAt(0) + "." + names[1].charAt(0)).toUpperCase();}- return Stream.of(name.split(" "))
- .map(it -> it.substring(0, 1).toUpperCase())
- .reduce((l, r) -> l + "." + r)
- .get();
- }
- }