Scala collections

Timon Gehr timon.gehr at gmx.ch
Fri Jun 17 17:15:57 PDT 2011


bearophile wrote:
> A nice video with readable slides, mostly about Scala collections:
> http://www.parleys.com/#id=2184&sl=71&st=5
>
> Martin Odersky looks like a very intelligent person (about as Hongwei Xi,
> author of ATS language).
>
> Scala collections look very integrated with each other and with
> functional-style programming. And they look good for parallelism too.
>
> A flatMap() sounds useful in Phobos. It means flat(map()) where map returns
> a small collection, and flat flattens them all in a single result. There is
> a similar function in Haskell too.
>
> Scala partition returns a 2-tuple. I'd like a similar functional function
> in Phobos too, that doesn't touch the input range.
>
> Bye,
> bearophile

Wow, neat. Thanks for sharing.
I'm hardly halfway through, but I think we need to steal some Scala features
sometime! =) It makes even D feel verbose.

What I especially like:
"var"/"val" are very short names for often used keywords. (not too descriptive though)

Scala's way of doing the equivalent of inline delegates. (_.age < 18) vs (at
least) (a){return a.age < 18;} or unaryFun!"a.age<18".

List comprehensions. Is it maybe possible to get equivalent functionality and
conciseness in a library solution?

auto-return of last statement / def foo():Type=result for short function definitions.

Infix functions and custom operators.

Simple pattern matching (bearophile's well-known tuple unpacking sugar)

Tuples. Tuples. Tuples.


Cheers,

Timon



More information about the Digitalmars-d mailing list