You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Welcome to Scala version 2.10.0.r0-b20110601223329 (JavaHotSpot(TM) 64-BitServerVM, Java1.6.0_23).
Type in expressions to have them evaluated.
Type:help for more information.
scala>1
res0:Int=1
scala>2
res1:Int=2
scala>:history
1380for (Regex.Groups(url) <- hrefs) yield url
1381Source.fromURL
1382importscala.io.Source1383importscala.util.matching.Regex1384importscala.util.matching.Regex._1385valhrefRegex=newRegex("""\<a.*?href=\"(http:.*?)\".*?\>.*?\</a>""") // no semi-colons1386deflinksFromUrl(sourceUrl:String) :List[String] =try { // don't use { } for single-statement methods -- the original was { try { } catch { }
}
1387valsource=Source fromURL sourceUrl // infix notation for infix methods1388valhrefs= hrefRegex findAllIn source.mkString // don't convert from Iterator to List prematurely, for performance reasons1389valurls=for (Groups(url) <-hrefs matchData ) yield url // as described before1390 urls.toList // change to list before returning1391 } catch {
1392case _ =>Nil1393 }
13941139521396:history
1397 exit
139821399:history
The text was updated successfully, but these errors were encountered:
REPL is not adding the first line to history:
The text was updated successfully, but these errors were encountered: