Tutorials about the Scala programming language.
Li Haoyi has a nice blog post titled, Strategic Scala Style: Principle of Least Power.
While doing some crazy things with SARAH, I realized that the best way to solve a particular problem was to use remote Akka actors. I haven’t had the opportunity to work with Akka much since finishing the Scala Cookbook, so I dug around trying to find a simple Akka remote “Hello, world” example. Unable to find a good one, I read some stuff, and created it myself.
I may explain this more in the future, but for now, here’s some source code for an example of how to use Quicklens in a Scala functional programming project.
Given some model/ADT definitions like this:
As I was researching who might be using an “IO Monad” in Scala, I found this quote from Martin Odersky in the Google Group titled “scala-debate”:
“The IO monad was a neat trick for combining side effects with lazy evaluation ... there is only one lazily evaluated language in wide usage today and even its creators have said that laziness was probably a mistake. Strict languages don’t need the IO monad, and generally don’t have it, even though they could. Bob Harper’s posts in his ‘existential type’ series are a good explanation on why not.”
Here’s a link to Bob Harper’s The Point of Laziness article.
As a short note, here’s some Scala source code that shows how to write a
foldLeft function using recursion:
If you like old research papers, here’s a link to a 1999 article titled, A tutorial on the universality and expressiveness of ‘fold’.
This image comes from a reactivesystems.eu article titled, Things I wish I knew when I started building reactive systems.
Table of Contents
- Background: What is a Cons cell?
- What it might look like in Scala
- Starting to create my own Cons class
- My second effort
- Defining my nil value
- Defining Cons
- Replacing the NilCons method bodies
- Adding a toString method to Cons
- The complete code at this point
- I’d really like a :: method
- See also
For some examples in my new book on functional programming in Scala I needed to create a collection class of some sort. Conceptually an immutable, singly-linked list is relatively easy to grok, so I decided to create my own Scala list from scratch. This tutorial shows how I did that.Back to top
Background: What is a Cons cell?
The first time I learned about linked lists was in a language named Lisp. In Lisp, a linked list is created as a series of “Cons” cells. A cons cell is simple, it contains only two things: