3 ms·
In Scala using the par function: https://gist.github.com/4199415 https://gist.github.com/4199415 def ip(host:String)=java.net.InetAddress.getAllByName(host
by dxbydt 14y ago
In Scala using the par function: https://gist.github.com/4199415 https://gist.github.com/4199415
def ip(host:String)=java.net.InetAddress.getAllByName(host)(0).getHostAddress
var map = Map[String,String]()
val hosts = List("google.com","twitter.com","facebook.com")
hosts.par.map(host => (host,ip(host))).foreach(hostip => map+=(hostip._1->hostip._2))
scala> map
res1: scala.collection.immutable.Map[String,String]
=Map(google.com -> 74.125.224.71,
twitter.com -> 199.59.150.7,
facebook.com -> 69.171.229.16)