Java
Some are more equal than others
"And to avoid the tedious repetition of these words: is equal to: I will set as I do often in work use, a pair of parallels, or Gemowe lines of one length, thus: =, because no 2 things, can be more equal." -- Robert Recorde, The Whetstone of Witte (1557)
public class Equality {
public Equality() {
Integer a1 = 100, a2 = 100;
Integer b1 = 200, b2 = 200;
if (a1 == a2) System.out.println("a1 == a2");
if (b1 == b2) System.out.println("b1 == b2");
}
public static void main(String[] args) {new Equality(); }
}…Regex prime checker
This Java snippet uses a regular expression for something way different than they were designed for: a primality check.
public static boolean prime(int n) {
return !new String(new char[n]).matches(".?|(..+?)\\1+");
}…