progs/lecture2.scala
changeset 329 8a34b2ebc8cc
parent 323 1f8005b4cdf6
child 334 841727e27252
equal deleted inserted replaced
328:0e591f806290 329:8a34b2ebc8cc
   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 //===========================================