progs/lecture2.scala
author Christian Urban <urbanc@in.tum.de>
Sat, 12 Nov 2016 15:20:56 +0000
changeset 39 c6fe374a5fca
parent 37 38f3868891f0
child 51 0e60e6c24b99
permissions -rw-r--r--
updated

// sudoku
// some none
// pattern matching

//type abbreviations
type Pos = (int, Int)

//sorting, higher-order functions
//lexicographic ordering


// Implicits
//===========
//
// for example adding your own methods to Strings:
// imagine you want to increment strings, like
//
//     "HAL".increment
//
// you can avoid ugly fudges, like a MyString, by
// using implicit conversions


implicit class MyString(s: String) {
  def increment = for (c <- s) yield (c + 1).toChar 
}

"HAL".increment