This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
value fiboLoop = curry(loop<Integer[2]>)([0,1]); | |
{Integer[2]+} fibonaccIterable = | |
fiboLoop((pair) => let([current, next] = pair) [next, current+next] ); | |
printAll(fibonaccIterable.take(100)*.first); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# resolve links - $0 may be a softlink | |
PRG="$0" | |
while [ -h "$PRG" ]; do | |
ls=`ls -ld "$PRG"` | |
link=`expr "$ls" : '.*-> \(.*\)$'` | |
if expr "$link" : '/.*' > /dev/null; then | |
PRG="$link" | |
else |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Create a comparator from an Iterable of Comparators" | |
shared class Comparing<Element>({Comparison(Element,Element)+} comparators){ | |
alias Comparator => Comparison(Element,Element); | |
Comparator accumulating(Comparator partial, Comparator elem) { | |
Comparison newPartial(Element x, Element y){ | |
value comparison = partial(x,y); | |
return comparison != equal then comparison else elem(x,y); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"zip two already sorted `Iterables` using the `comparing` method | |
to match the elements of the Iterables. All elements are kept. | |
The original sort (ascending) of the two Iterables must be consistent with the `comparing` | |
method." | |
shared {[First?, Second?]*} smartZipOr<First, Second> | |
( Comparison comparing(First x, Second y)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"Create comparators a la Java 8 Comparator#comparing" | |
class Comparing<Element>(_comparator){ | |
variable Comparison(Element,Element) _comparator; | |
shared Comparison(Element,Element) comparator => _comparator; | |
shared Comparing<Element> thenComparing(Comparison comparing(Element x, Element y)){ | |
value currentComparator = comparator; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.yammer.dropwizard {...} | |
import com.yammer.dropwizard.config { ... } | |
import com.fasterxml.jackson.annotation {jsonProperty} | |
import org.hibernate.validator.constraints {notEmpty} | |
import java.lang { JavaString = String , ObjectArray} | |
import ceylon.interop.java { ... } | |
import java.util.concurrent.atomic { ... } | |
import javax.ws.rs { get = gET, ... } | |
import com.google.common.base { Optional } | |
import com.yammer.metrics.core { HealthCheck } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage : save this script as 'build.gradle' and run 'gradle' in the directory of this script | |
configurations { compile } | |
dependencies{ | |
//compile 'com.yammer.dropwizard:dropwizard-core:0.6.2' | |
compile 'com.octo.android.robospice:robospice-spring-android:1.4.9' | |
//compile 'org.hibernate:hibernate-core:4.3.0.Final' | |
} | |
repositories{ mavenCentral() } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// enum 1 of application i18n keys | |
abstract class AppKeyi18n() | |
of title | description {} | |
object title extends AppKeyi18n() {} | |
object description extends AppKeyi18n() {} | |
// enum 2 of user i18n keys | |
abstract class UserKeyi18n() | |
of fieldText1 | fieldText2 | fieldText3 {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.app { Activity } | |
import android.os { Bundle } | |
import android.view { Menu } | |
import android.widget { TextView } | |
import java.lang { JString=String } | |
shared class Foo() extends Activity() { | |
shared actual void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); |