This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
lftp -u $FTP_USERNAME,$FTP_PASSWORD $FTP_SERVER/$FTP_DIRECTORY -e 'put -a filename;quit' |
flush tables; | |
reset query cache; |
a = null | |
b = 12 | |
println "a.compareTo(b) = " + (a <=> b) | |
println "a.compareTo(a) = " + (a <=> a) | |
println "b.compareTo(b) = " + (b <=> b) |
class Person { | |
String firstName | |
String lastName | |
int age | |
} |
class Person implements Comparable<Person> { | |
String firstName | |
String lastName | |
int age | |
int compareTo(Person other) { | |
... | |
} | |
} |
int compareTo(Person other) { | |
if (other == null) { | |
return 1; | |
} | |
int result = 0; | |
if (this.age > other.age) { | |
result = 1; | |
} | |
else if (this.age < other.age) { |
int compareTo(Person other) { | |
age <=> other.age ?: lastName <=> other.lastName ?: firstName <=> other.firstName | |
} |
def john = new Person(firstName: 'John', lastName: 'Doe', age: 25) | |
def mark = new Person(firstName: 'Mark', lastName: 'White', age: 25) | |
print "john <=> mark = " + (john <=> mark) |
This gist is part of a blog post. Check it out at:
http://jasonrudolph.com/blog/2011/08/09/programming-achievements-how-to-level-up-as-a-developer
(define (max x y z) | |
(define a (if (> x y) x y)) | |
(define c (if (> x y) y x)) | |
(define b (if (> c z) c z)) | |
(list a b)) |