Functional Programming in R: Advanced Statistical Programming for Data Science, Analysis and Finance

Thomas Mailund

  • 出版商: Apress
  • 出版日期: 2017-03-29
  • 定價: $1,575
  • 售價: 5.0$788
  • 語言: 英文
  • 頁數: 104
  • 裝訂: Paperback
  • ISBN: 148422745X
  • ISBN-13: 9781484227459
  • 相關分類: R 語言Data Science
  • 立即出貨 (庫存 < 3)

買這商品的人也買了...

相關主題

商品描述

Master functions and discover how to write functional programs in R. In this concise book, you'll make your functions pure by avoiding side-effects; you’ll write functions that manipulate other functions, and you’ll construct complex functions using simpler functions as building blocks.
 
In Functional Programming in R, you’ll see how we can replace loops, which can have side-effects, with recursive functions that can more easily avoid them. In addition, the book covers why you shouldn't use recursion when loops are more efficient and how you can get the best of both worlds.
 
Functional programming is a style of programming, like object-oriented programming, but one that focuses on data transformations and calculations rather than objects and state. Where in object-oriented programming you model your programs by describing which states an object can be in and how methods will reveal or modify that state, in functional programming you model programs by describing how functions translate input data to output data. Functions themselves are considered to be data you can manipulate and much of the strength of functional programming comes from manipulating functions; that is, building more complex functions by combining simpler functions.
 
What You'll Learn
  • Write functions in R including infix operators and replacement functions 
  • Create higher order functions
  • Pass functions to other functions and start using functions as data you can manipulate
  • Use Filer, Map and Reduce functions to express the intent behind code clearly and safely
  • Build new functions from existing functions without necessarily writing any new functions, using point-free programming
  • Create functions that carry data along with them
 
Who This Book Is For
 
Those with at least some experience with programming in R.

 

商品描述(中文翻譯)

在這本簡明的書籍中,您將學習主要功能並探索如何在R中撰寫函數式程式。您將通過避免副作用使函數純凈;您將撰寫操作其他函數的函數,並使用較簡單的函數作為構建塊來構建複雜函數。

在《R中的函數式程式設計》中,您將看到我們如何用遞迴函數取代可能具有副作用的迴圈,以更輕鬆地避免副作用。此外,本書還介紹了為什麼不應該在效率更高的迴圈存在時使用遞迴,以及如何兼顧兩者的最佳方法。

函數式程式設計是一種程式設計風格,類似於面向對象的程式設計,但它更關注數據轉換和計算,而不是對象和狀態。在面向對象的程式設計中,您通過描述對象可能處於的狀態以及方法如何顯示或修改該狀態來建模程序,而在函數式程式設計中,您通過描述函數如何將輸入數據轉換為輸出數據來建模程序。函數本身被視為可以操作的數據,函數式程式設計的強大之處在於操作函數;也就是說,通過組合較簡單的函數來構建更複雜的函數。

您將學到什麼:
- 在R中撰寫函數,包括中綴運算符和替換函數
- 創建高階函數
- 將函數傳遞給其他函數,並開始使用函數作為可以操作的數據
- 使用Filer、Map和Reduce函數清晰且安全地表達代碼的意圖
- 使用無參數編程從現有函數構建新函數,而無需撰寫任何新函數
- 創建可以攜帶數據的函數

適合閱讀對象:
- 至少具有一些R程式設計經驗的讀者。