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

Re: things must be different..

No replies
anli 2
Joined: 2011-05-18,
User offline. Last seen 42 years 45 weeks ago.

On Mon, 25 Jul 2011 23:42:47 +0200
Sébastien Bocq wrote:
> This is what you expressed:
>
> val f:Data => Bag[Thing] = new Thing dress
> println(mapIt[Data,Thing](datas, f))
>
> So this is expected.

Aha, I see. On mapIt() call a second argument value (which is a function) is calculated once. To force without-underscore case to work I can, say, modify mapIt():

def mapIt[A,B](list : Seq[A], f : => A => Bag[B]) : Seq[B] = list.map(f(_).t)

Fine, thanks to all!

Andrew

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