Blogs

How curried functions and partially-applied functions compile in Scala

This morning I was curious about how Scala curried functions and partially-applied functions are really compiled at a bytecode level. Earlier this morning I made this post that Higher order functions are the Haskell experience — which is also implicitly about curried functions — and it got me thinking about Scala, in particular why we might use one function syntax versus another, i.e., why would I use this syntax:

Facebook - How do I search the history of my own posts?

Facebook FAQ: How do I search the history of my own posts?

I was just looking for an old Facebook post I thought I made about five months ago, and scrolling through the history of my posts was very painful. It seems like Facebook gets slower and slower the farther back in your history that you go. This made me wonder, is there any way to easily search through the history of my past Facebook posts?

While it’s not obvious, the answer is that yes, you can search your Facebook posts history, and here’s how you do it, at least as of February, 2016.

How to use multiple generators in Scala 'for' expressions (loops)

A cool thing about Scala for loops — what I’ll more-accurately call for expressions in this article — is that you can have multiple generators. What’s also very cool about them is how they work.

For example, imagine that you have these two values:

val nums = Seq(1,2,3)
val letters = Seq('a', 'b', 'c')

An interesting question then becomes, “What is the type of res in this expression?”:

When you want to store static text in an Android file

As a note to self, when you’re writing an Android application and you think you want to store some static text in an external file, a better approach can be to create a resource file under res/values.

For example, I’m currently adding some help text to an Android app, and to do that I created a file named strings_help.xml under the res/values directory. That file contains HTML wrapped in an XML CDATA tag, like this:

A Java tuple class

After working with Scala for a long time, I had to come back to Java for a while to work on an Android app. Right away I missed a lot of things from the Scala world, including all of the built-in Scala collection methods, and other things as simple as the Scala Tuple classes.

If you haven’t used them before, a Scala Tuple class lets you write code like this:

Syndicate content