Tenth. Efficiency of data structure

Source: Internet
Author: User

Tenth. Efficiency of data structure

This chapter describes

optimizing and improving recursive functions

Use tail recursion (tail-recursion) and continuous (continuations)

Efficient use of lists and arrays

So far, the functional approach that we've used in this book has recursive and functional data structures, such as immutable lists. The simplest code we can write is to use the basic F # collection type (list) to express our intentions directly. In many cases, this approach is appropriate, but when it comes to working with large datasets, it is "obvious" that code can sometimes cause performance problems. In this chapter, we will learn some ways to write code, regardless of the size of the input data, and the performance of the processing data function is optimized. We will still try to keep the code as readable as possible.

If you have developed any long-running programs, it is almost certain that a program that is written usually causes a stack overflow exception. In function programming, it is possible that this error is due to the immature recursive function, so we will explore several ways to solve the problem that can cause this error when dealing with large amounts of data. This is the topic we started with, and we'll go back to that topic at the end of this chapter.

In the middle of the discussion about recursion, we focus on the functional list and the array. Working with functional lists, the most important way to understand their principles is that they can be used effectively; F # also supports arrays and, in some cases, provides better performance. Although the array is primarily an imperative data type, you will find that we can also use it in a very functional way.

Tenth. Efficiency of data structure

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.