Skip to content

gmcmacran/functional_playground

Repository files navigation

Overview

R-CMD-check Codecov test coverage

The package explores functional programming. Motivating questions include:

  • Can I implement standard higher order functions like map, fold, and filter from scratch?
  • Can I combine higher order functions to make something meaningful?
  • Is factoring out looping w/ map truly better than having loops within each function?
  • If I come back to the code after 3 months, can I understand it?
  • Is there some aspect of R’s language definition that prevent functional implementations?

This package implements standard algorithms using a functional programming approach to answer these questions.

Higher Order Functions

  • Functionals
    • fold
    • map
  • Function Operators
    • cumulative_f
    • negate
    • recursive_none
    • filter
    • first
    • last
    • nth
    • compose
    • memoize
    • time_f
    • negate

Standard Algorithms

  • Using Fold
    • recursive_add
    • recursive_multiply
    • recursive_max
    • recursive_min
    • recursive_all
    • recursive_any
  • Using Function Operator
    • hofstadter_g
    • hofstadter_h
    • hofstadter_q
  • Using Map and Function Operator
    • cumulative_add
    • cumulative_multiply
    • cumulative_max
    • cumulative_min
    • cumulative_all
    • cumulative_any
    • cumulative_none
  • Using Map and Fold
    • recursive_is_in
  • Using Mutual Recursion
    • is_even
    • is_odd
    • hofstadter_female
    • hofstadter_male
  • Using Recursion
    • recursive_reverse
    • ackermann
    • recursive_length
    • recursive_sort
    • recursive_gcd
    • recursive_lcm

Installation

This package will not be on cran. A stable version can be installed with:

# install.packages("devtools")
devtools::install_github("gmcmacran/functionalPlayground")

About

Odds and ends of functional programming ideas

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages