templates2/knight2.scala
changeset 147 3e5d8657302f
parent 146 ed68f7239293
equal deleted inserted replaced
146:ed68f7239293 147:3e5d8657302f
     9 type Path = List[Pos]    // a path...a list of positions
     9 type Path = List[Pos]    // a path...a list of positions
    10 
    10 
    11 
    11 
    12 //(2a) Implement a first-function that finds the first 
    12 //(2a) Implement a first-function that finds the first 
    13 //     element, say x, in the list xs where f is not None. 
    13 //     element, say x, in the list xs where f is not None. 
    14 //     In that case return f(x), otherwise None. If possible,
    14 //     In that case Return f(x), otherwise None. If possible,
    15 //     calculate f(x) only once.
    15 //     calculate f(x) only once.
    16 
    16 
    17 //def first(xs: List[Pos], f: Pos => Option[Path]) : Option[Path] = ...
    17 //def first(xs: List[Pos], f: Pos => Option[Path]) : Option[Path] = ...
    18 
    18 
    19 //(2b) Implement a function that uses the first-function for
    19 //(2b) Implement a function that uses the first-function for