Functional Programming support for golang.(Streaming API)

Funtional Api for Golang

Functional Programming support for golang.(Streaming API)

The package can only be used with go 1.18. Do not try in lower version of go.

Examples

Map

data := []int{1, 2, 3, 4, 5}
res := Map(Stream(data), func(i int) string { return strconv.Itoa(i + 1) }).Collect()

fmt.Println(res)
fmt.Println(reflect.TypeOf(res))

//output:
//[2 3 4 5 6]
//[]string

Filter

data := []int{1, 2, 3, 4, 5, 6, 7, 8}
res := Filter(Stream(data), func(i int) bool { return i%2 == 0 }).Collect()
fmt.Println(res)

//output:
//[2 4 6 8]

combine use map and filter

data := []int{1, 2, 3, 4, 5, 6, 7, 8}
res := Map(Filter(Stream(data), func(i int) bool { return i%2 == 0 }), func(i int) string { return strconv.Itoa(i + 1) }).Collect()
fmt.Println(res)
fmt.Println(reflect.TypeOf(res))

//output:
//[3 5 7 9]
//[]string

Reduce

data := []int{1, 2, 3, 4, 5, 6, 7, 8}
res1 := ReduceFromZero(Filter(Stream(data), func(i int) bool { return i%2 == 0 }), func(i, j int) int { return i + j })
fmt.Println(res1)

res2 := Reduce(Filter(Stream(data), func(i int) bool { return i%2 == 0 }), "0", func(i string, j int) string { return i + ", " + strconv.Itoa(j) })
fmt.Println(res2)
//output:
//20
//0, 2, 4, 6, 8
Owner
Similar Resources

FreeSWITCH Event Socket library for the Go programming language.

eventsocket FreeSWITCH Event Socket library for the Go programming language. It supports both inbound and outbound event socket connections, acting ei

Dec 11, 2022

Simple interface to libmagic for Go Programming Language

File Magic in Go Introduction Provides simple interface to libmagic for Go Programming Language. Table of Contents Contributing Versioning Author Copy

Dec 22, 2021

A library for parallel programming in Go

pargo A library for parallel programming in Go Package pargo provides functions and data structures for expressing parallel algorithms. While Go is pr

Nov 28, 2022

The Gorilla Programming Language

The Gorilla Programming Language

Gorilla Programming Language Gorilla is a tiny, dynamically typed, multi-engine programming language It has flexible syntax, a compiler, as well as an

Apr 16, 2022

Elastic is an Elasticsearch client for the Go programming language.

Elastic is an Elasticsearch client for the Go programming language.

Jan 9, 2023

👩🏼‍💻A simple compiled programming language

👩🏼‍💻A simple compiled programming language

The language is written in Go and the target language is C. The built-in library is written in C too

Nov 29, 2022

Welcome to the future of programming languages: OK?

Welcome to the future of programming languages: OK?

OK? Try it out on the playground OK?'s mascot: Quentyn Questionmark. Programming Is Simple Again OK? is a modern, dynamically typed programming langua

Jan 1, 2023

Examples on different options for implementing Flow Based Programming

Flow Based Programming This repository contains fragments and ideas related to Flow Based Programming. It shows different ways of implementing differe

Sep 22, 2022

accessor methods generator for Go programming language

accessory accessory is an accessor generator for Go programming language. What is accessory? Accessory is a tool that generates accessor methods from

Nov 15, 2022
Lithia is an experimental functional programming language with an implicit but strong and dynamic type system.

Lithia is an experimental functional programming language with an implicit but strong and dynamic type system. Lithia is designed around a few core concepts in mind all language features contribute to.

Dec 24, 2022
Go module that provides primitive functional programming utilities.

Functional Functional provides a small set of pure functions that are common in functional programming languages, such as Reduce, Map, Filter, etc. Wi

Jun 12, 2022
The package manager for macOS you didn’t know you missed. Simple, functional, and fast.
The package manager for macOS you didn’t know you missed. Simple, functional, and fast.

Stew The package manager for macOS you didn’t know you missed. Built with simplicity, functionality, and most importantly, speed in mind. Installation

Mar 30, 2022
Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved in any programming language you like.

Advent of Code 2021 Advent of Code is an Advent calendar of small programming puzzles for a variety of skill sets and skill levels that can be solved

Dec 2, 2021
Jan 4, 2022
Flow-based and dataflow programming library for Go (golang)
Flow-based and dataflow programming library for Go (golang)

GoFlow - Dataflow and Flow-based programming library for Go (golang) Status of this branch (WIP) Warning: you are currently on v1 branch of GoFlow. v1

Dec 30, 2022
A modern programming language written in Golang.

MangoScript A modern programming language written in Golang. Here is what I want MangoScript to look like: struct Rectangle { width: number he

Nov 12, 2021
Support CI generation of SBOMs via golang tooling.

Software Package Data Exchange (SPDX) is an open standard for communicating software bill of materials (SBOM) information that supports accurate identification of software components, explicit mapping of relationships between components, and the association of security and licensing information with each component.

Jan 3, 2023
Support CI generation of SBOMs via golang tooling.
Support CI generation of SBOMs via golang tooling.

SPDX Software Bill of Materials (SBOM) Generator Overview Software Package Data Exchange (SPDX) is an open standard for communicating software bill of

Jan 3, 2023
Unit tests generator for Go programming language
Unit tests generator for Go programming language

GoUnit GoUnit is a commandline tool that generates tests stubs based on source function or method signature. There are plugins for Vim Emacs Atom Subl

Jan 1, 2023