progs/lecture2.scala
author Christian Urban <christian dot urban at kcl dot ac dot uk>
Tue, 15 Nov 2016 23:08:09 +0000
changeset 49 fdc2c6fb7a24
parent 39 c6fe374a5fca
child 51 0e60e6c24b99
permissions -rw-r--r--
merged

// 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