Functional Programming Higher order functions in golang
Branch: master
Clone or download
Rajeev N B
Rajeev N B Fixes #1
Latest commit 69a8008 Jul 15, 2015
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
README.md Fixes #1 Jul 15, 2015
functional.go Fixes #1 Jul 15, 2015
functional_test.go Fixes #1 Jul 15, 2015

README.md

Functional Programming Constructs in Golang

These functions where coded to understand the difficulty of implementing these functions in golang. I do not recommend you use it. A simple for loop will do and work in most of the cases.

Check out the test file to see the usage of these

FUNCTIONS

// Definition of Filter function
type filterFunc func(interface{}) bool

func Filter(fn filterFunc, array interface{}) []interface{}
    Filter filters the array based on the predicate
// Definition of Foldl function
type foldlFunc func(interface{}, interface{}) interface{}

func Foldl(fn foldrFunc, array interface{}, accumulator interface{}) interface{}
    Folds left the array values (reduction) based on the function
// Definition of Map function
type mapFunc func(interface{}) interface{}

func Map(fn mapFunc, array interface{}) []interface{}
    Map maps the function onto the array