Ad
Code
Diff
  • 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)
    • }
Code
Diff
  • 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)
    • }
Code
Diff
  • 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();
    • }
    • }
Code
Diff
  • public class FirstClass {
        public static byte sum (byte a, byte b) {
            return (byte)(a + b);
        }
    }
    • public class FirstClass {
    • public static byte sum (byte a, byte b) {
    • byte c = (byte) (a + b);
    • return c;
    • return (byte)(a + b);
    • }
    • }