Skip to content

Instantly share code, notes, and snippets.

View mknudsen's full-sized avatar

Martin Knudsen mknudsen

View GitHub Profile
http://support.apple.com/kb/ht1573?viewlocale=de_DE
http://support.apple.com/kb/ht1379?viewlocale=de_DE
http://support.apple.com/kb/ht3964?viewlocale=de_DE
func recursiveAdder(list:[Int]) -> Int {
switch list.count {
case 0:
return 0
case 1:
return list.first!
case 2:
@mknudsen
mknudsen / Currying.java
Created January 10, 2015 18:07
currying in java 8
import java.util.function.BiFunction;
import java.util.function.Function;
public class Currying {
// A,B -> C
// A -> B -> C
public static BiFunction<Integer, Integer, Integer> add = (a, b) -> a + b;
@mknudsen
mknudsen / homebrew netpbm error
Created October 26, 2012 09:23
netpbm failed to build on 10.8.2
======= Library/Logs/Homebrew/netpbm/02.make : =======
/private/tmp/netpbm-chao/netpbm-10.35.77/Makefile.common:551: Makefile.depend: No such file or directory
make: libpng-config: Command not found
cat /dev/null >Makefile.depend
make: libpng-config: Command not found
/usr/bin/make -C /private/tmp/netpbm-chao/netpbm-10.35.77/buildtools/ -f /private/tmp/netpbm-chao/netpbm-10.35.77/buildtools/Makefile \
SRCDIR=/private/tmp/netpbm-chao/netpbm-10.35.77 BUILDDIR=/private/tmp/netpbm-chao/netpbm-10.35.77 typegen
/private/tmp/netpbm-chao/netpbm-10.35.77/Makefile.common:551: Makefile.depend: No such file or directory
cat /dev/null >Makefile.depend
fun main(args: Array<String>) {
// Starte mit "rats live on arona no evil star"
val sentence = "rats live on arona no evil star"
// 1. change all letters with their counterparts in the alphabet
val alphabetCounterparts: String = sentence.split(' ').map { word -> word.map { ch -> (122 - (ch.toInt() - 97)).toChar().toLowerCase() }.joinToString("") }.joinToString(" ")
// 2. convert all letters to their numeric value in the alphabet (a = 1)
val lettersToNumericValues:List<List<Int>> = alphabetCounterparts.split(' ').map { word -> word.map { ch -> ch.toInt() - 96 } }