Skip to content

rShetty/functional-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

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

About

Functional Programming Higher order functions in golang

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages