progs/lecture2.scala
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--
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