# list

Android: How to convert a list of strings or objects to a single string alvin August 2, 2017 - 4:39pm

Android FAQ: How do I convert a list of strings (or a list of objects) to a single, combined string?

In Android, if you want to convert a list of strings to a `String`, I just saw this approach:

## How to create multiline strings in Scala

This is an excerpt from the Scala Cookbook (partially modified for the internet). This is Recipe 1.2, “How to Create Multiline Strings in Scala.”

## Problem

You want to create multiline strings within your Scala source code, like you can with the “heredoc” syntax of other languages.

## Solution

In Scala you create multiline strings by surrounding your text with three double quotes:

## Recursion: How Recursive Function Calls Work

An important point to understand about recursive function calls is that just as they “wind up” as they are called repeatedly, they “unwind” rapidly when the function’s end condition is reached.

In the case of the `sum` function, the end condition is reached when the `Nil` element in a `List` is reached. When `sum` gets to the `Nil` element, this pattern of the `match` expression is matched:

## Recursion: How to Write a ‘sum’ Function

With all of the images of the previous lesson firmly ingrained in your brain, let’s write a `sum` function using recursion!

## Sketching the `sum` function signature

Given a `List` of integers, such as this one:

``val list = List(1, 2, 3, 4)``

let’s start tackling the problem in the usual way, by thinking, “Write the function signature first.”

## Recursion: Let’s Look at Lists

“In computer science, a linked list is a linear collection of data elements, called nodes, each pointing to the next node by means of a pointer.”

Wikipedia’s Linked List entry

## Recursion: Introduction

As you may have noticed from this book’s index, you’re about to jump into a series of lessons on recursive programming. I separated this text into a series of small lessons to make the content easier to read initially, and then easier to refer to later.

Using Scala Methods As If They Were Functions (Eta Expansion) alvin May 28, 2017 - 6:44pm

“The owls are not what they seem.”

From the television series, Twin Peaks

## Goals

Have you noticed that the Scaladoc for the `List` class `map` method clearly shows that it takes a function?

But despite that, you can somehow pass it a method, and it still works, as shown in this code: