Dear useRs,
I'm pleased to announce that version 1.1.0 of lambda.r is now available on
CRAN (http://cran.r-project.org/web/packages/lambda.r/). This package provides a
complete functional programming environment within R (and is backwards
compatible with S3). Lambda.r introduces many concepts including:
. Multipart function definitions
. Guard statements to control execution of functions
. Pattern matching in function definitions
. An intuitive type system
. Optional strong typing via type constraints
. Type variables
. Cleaner syntax for attributes
Using these techniques, systems can be written more efficiently and with less
headache. Here is a brief example of what you can do with lambda.r.
fib(n) %::% numeric : numeric
fib(n) %when% { n < 0 } %as% { stop("Negative numbers not allowed")
}
fib(0) %as% 1
fib(1) %as% 1
fib(n) %as% { fib(n-1) + fib(n-2) }
> fib(-1)
Error in function (n) : Negative numbers not allowed> fib(5)
[1] 8
Documentation is available at the following locations:
. http://cartesianfaith.wordpress.com/category/r/lambda-r/
. https://github.com/muxspace/lambda.r
A more complete discussion on why analytical systems should be designed using
functional programming principles will be available in my forthcoming book on
functional programming and computational finance.
Warm Regards,
Brian Rowe