author | Christian Urban <urbanc@in.tum.de> |
Wed, 16 Nov 2016 14:37:18 +0000 | |
changeset 50 | 9891c9fac37e |
parent 39 | c6fe374a5fca |
child 51 | 0e60e6c24b99 |
permissions | -rw-r--r-- |
8 | 1 |
// sudoku |
13
0ce25f816414
updated
Christian Urban <christian dot urban at kcl dot ac dot uk>
parents:
8
diff
changeset
|
2 |
// some none |
37 | 3 |
// pattern matching |
36 | 4 |
|
39 | 5 |
//type abbreviations |
6 |
type Pos = (int, Int) |
|
7 |
||
8 |
//sorting, higher-order functions |
|
9 |
//lexicographic ordering |
|
36 | 10 |
|
11 |
||
12 |
// Implicits |
|
13 |
//=========== |
|
14 |
// |
|
15 |
// for example adding your own methods to Strings: |
|
16 |
// imagine you want to increment strings, like |
|
17 |
// |
|
18 |
// "HAL".increment |
|
19 |
// |
|
20 |
// you can avoid ugly fudges, like a MyString, by |
|
21 |
// using implicit conversions |
|
22 |
||
23 |
||
24 |
implicit class MyString(s: String) { |
|
25 |
def increment = for (c <- s) yield (c + 1).toChar |
|
26 |
} |
|
27 |
||
28 |
"HAL".increment |