progs/lecture2.scala
changeset 329 828326d1b3b2
parent 323 93b6c16dded8
child 334 305e1dcdb3bc
equal deleted inserted replaced
328:b217232e9246 329:828326d1b3b2
   501   if (l == 0) List("")
   501   if (l == 0) List("")
   502   else for (c <- cs; s <- combs(cs, l - 1)) yield s"$c$s"
   502   else for (c <- cs; s <- combs(cs, l - 1)) yield s"$c$s"
   503 }
   503 }
   504 
   504 
   505 combs("abc".toList, 2)
   505 combs("abc".toList, 2)
       
   506 
       
   507 
       
   508 // When writing recursive functions you have to
       
   509 // think about three points
       
   510 // 
       
   511 // - How to start with a recursive function
       
   512 // - How to communicate between recursive calls
       
   513 // - Exit conditions
   506 
   514 
   507 
   515 
   508 
   516 
   509 // A Recursive Web Crawler / Email Harvester
   517 // A Recursive Web Crawler / Email Harvester
   510 //===========================================
   518 //===========================================