Skip to content

Latest commit

 

History

History
37 lines (23 loc) · 938 Bytes

README.md

File metadata and controls

37 lines (23 loc) · 938 Bytes

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