#A little example of how manipulate matrix with threads in C
- compile:
$ gcc -pthread squareMatrixItemsWithThreads.c -o squareMatrixItemsWithThreads
- run
$ ./squareMatrixItemsWithThreads
#A little example of how manipulate matrix with threads in C
$ gcc -pthread squareMatrixItemsWithThreads.c -o squareMatrixItemsWithThreads
$ ./squareMatrixItemsWithThreads
// TODO test if works | |
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
int[][] states = new int[][] { new int[] { android.R.attr.state_pressed } }; | |
int[] colors = new int[] { color }; | |
ColorStateList colorStateList = new ColorStateList(states, colors); | |
RippleDrawable rippleDrawable = new RippleDrawable(colorStateList, null, null); | |
view.setBackground(rippleDrawable); | |
} |
// Using Lambdas on Kotlin | |
val items = ArrayList<String>() | |
items.sortBy { item -> | |
item.length() | |
} | |
//or more implicity | |
items.sortBy { it.length() } | |
//------------------------------------------------------------------------------ |
// Using Nullables on Kotlin | |
var nothing = null | |
var stringNullable: String? = null | |
//------------------------------------------------------------------------------ | |
// Using Nullables in Java 7 | |
String alwaysCanBeNull = null |
// Using Class Fields on Kotlin | |
public class Foo(var variable: String, val value: String, val withDefault: String = "o") { | |
} | |
// And use it on Kotlin | |
Foo("f", "o", "o") | |
Foo("f", "o") | |
//------------------------------------------------------------------------------ |
// Using Variables on Kotlin | |
var foo = "mutable foo" | |
val finalFoo = "final foo" | |
val explicitFoo: String = "explicit foo" | |
//------------------------------------------------------------------------------ | |
// Using Variables in Java 7 |
// Using Singleton on Kotlin | |
public object MySingleton { | |
public fun foo() { | |
} | |
} | |
// And use it on Kotlin | |
MySingleton.foo() |
// Using Closure on Kotlin | |
button.setOnClickListener { | |
Thread { | |
// Amazing! Just 2 identations, 5 lines and 55 characters "lesser than a half of tweet" | |
}.start() | |
} | |
//------------------------------------------------------------------------------ | |
// Using the nearest from Closure in Java 7 |
// Using Lazy on Kotlin | |
private val foo by Delegates.lazy { Foo(getContext()) } | |
//------------------------------------------------------------------------------ | |
// Using the nearest from Lazy in Java 7 | |
private Foo mFoo; | |
public Foo getFoo() { | |
if (mFoo == null) { |
#!/usr/bin/env python | |
from time import time | |
''' | |
Verify if 0 + 1 + 2 + ... + n is equals to (n * (n + 1)) / 2, this | |
method is not using mathematical induction, it is using exhaustion | |
''' | |
def proof(n): | |
for i in range(n + 1): |