This page is no longer maintained — Please continue to the home page at www.scala-lang.org

(Set[K], Function1[K,V]) => Map[K,V]

6 replies
vpatryshev
Joined: 2009-02-16,
User offline. Last seen 1 year 24 weeks ago.
Could not find such a constructor... does it exist? Should not it exist? (I believe it should.)

--
Thanks,
-Vlad
Colin Bullock
Joined: 2009-01-23,
User offline. Last seen 42 years 45 weeks ago.
Re: (Set[K], Function1[K,V]) => Map[K,V]
Perhaps you mean something like:

scala> import scala.collection.breakOut
import scala.collection.breakOut

scala> val s = Set(1, 2, 3)           
s: scala.collection.immutable.Set[Int] = Set(1, 2, 3)

scala> val m: Map[Int, Int] = s.map(k => (k, k * 10))(breakOut)
m: Map[Int,Int] = Map((1,10), (2,20), (3,30))

- Colin
ounos
Joined: 2008-12-29,
User offline. Last seen 3 years 44 weeks ago.
Re: (Set[K], Function1[K,V]) => Map[K,V]
Anyone cares to put few more words around breakOut and betray perhaps its meaning? :)

2010/6/15 Colin Bullock <cmbullock [at] gmail [dot] com>
Perhaps you mean something like:

scala> import scala.collection.breakOut
import scala.collection.breakOut

scala> val s = Set(1, 2, 3)           
s: scala.collection.immutable.Set[Int] = Set(1, 2, 3)

scala> val m: Map[Int, Int] = s.map(k => (k, k * 10))(breakOut)
m: Map[Int,Int] = Map((1,10), (2,20), (3,30))

- Colin

Kevin Wright 2
Joined: 2010-05-30,
User offline. Last seen 26 weeks 4 days ago.
Re: (Set[K], Function1[K,V]) => Map[K,V]
ScalaDoc is here: http://www.scala-lang.org/archives/downloads/distrib/files/nightly/docs/library/scala/collection/package.html

for what it's worth :)


On 15 June 2010 15:05, Dimitris Andreou <jim [dot] andreou [at] gmail [dot] com> wrote:
Anyone cares to put few more words around breakOut and betray perhaps its meaning? :)

2010/6/15 Colin Bullock <cmbullock [at] gmail [dot] com>
Perhaps you mean something like:

scala> import scala.collection.breakOut
import scala.collection.breakOut

scala> val s = Set(1, 2, 3)           
s: scala.collection.immutable.Set[Int] = Set(1, 2, 3)

scala> val m: Map[Int, Int] = s.map(k => (k, k * 10))(breakOut)
m: Map[Int,Int] = Map((1,10), (2,20), (3,30))

- Colin




--
Kevin Wright

mail/google talk: kev [dot] lee [dot] wright [at] gmail [dot] com
wave: kev [dot] lee [dot] wright [at] googlewave [dot] com
skype: kev.lee.wright
twitter: @thecoda

Seth Tisue
Joined: 2008-12-16,
User offline. Last seen 34 weeks 3 days ago.
Re: (Set[K], Function1[K,V]) => Map[K,V]

>>>>> "Dimitris" == Dimitris Andreou writes:

Dimitris> Anyone cares to put few more words around breakOut and betray
Dimitris> perhaps its meaning? :)

http://stackoverflow.com/questions/1715681/scala-2-8-breakout

Kevin Wright 2
Joined: 2010-05-30,
User offline. Last seen 26 weeks 4 days ago.
Re: (Set[K], Function1[K,V]) => Map[K,V]
Yup, that there is a mighty fine answer :)

On 15 June 2010 15:13, Seth Tisue <seth [at] tisue [dot] net> wrote:
>>>>> "Dimitris" == Dimitris Andreou <jim [dot] andreou [at] gmail [dot] com> writes:

 Dimitris> Anyone cares to put few more words around breakOut and betray
 Dimitris> perhaps its meaning? :)

http://stackoverflow.com/questions/1715681/scala-2-8-breakout

--
Seth Tisue @ Northwestern University | http://tisue.net
lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/



--
Kevin Wright

mail/google talk: kev [dot] lee [dot] wright [at] gmail [dot] com
wave: kev [dot] lee [dot] wright [at] googlewave [dot] com
skype: kev.lee.wright
twitter: @thecoda

ounos
Joined: 2008-12-29,
User offline. Last seen 3 years 44 weeks ago.
Re: (Set[K], Function1[K,V]) => Map[K,V]
Thanks Seth, that should have been the first (or second) place to look. Scaladoc + breakOut source were unfortunately not too revealing, at least for me.

2010/6/15 Seth Tisue <seth [at] tisue [dot] net>
>>>>> "Dimitris" == Dimitris Andreou <jim [dot] andreou [at] gmail [dot] com> writes:

 Dimitris> Anyone cares to put few more words around breakOut and betray
 Dimitris> perhaps its meaning? :)

http://stackoverflow.com/questions/1715681/scala-2-8-breakout

--
Seth Tisue @ Northwestern University | http://tisue.net
lead developer, NetLogo: http://ccl.northwestern.edu/netlogo/

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland