Scala funny symbols

One of the things that can be annoying with perl is that there is more than eight ways to do the same thing, some far more cryptic than others. You can do some crazy things with scala too.

val x = List(2,3,5)

//This is how it should be done.
x.foldLeft(0)( (a,b) =>; b + a  )

//This is how it can be done foldLeft
(0 /: x) ( (a,b) => b+a )

//This is the foldRight alternative to the above foldLeft.
(x :\ 0) ( (a,b) => b + a )

// YUCK //
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s