https://github.com/araujo88/lambda-go
A simple Go library based on functional programming (inspired by Haskell)
https://github.com/araujo88/lambda-go
functional-go functional-go-template go-functional go-functional-programming go-lib go-library golang-functional-programming golang-lib golang-library
Last synced: 5 months ago
JSON representation
A simple Go library based on functional programming (inspired by Haskell)
- Host: GitHub
- URL: https://github.com/araujo88/lambda-go
- Owner: araujo88
- License: mit
- Created: 2024-07-04T07:53:36.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-07-31T18:30:07.000Z (10 months ago)
- Last Synced: 2024-07-31T22:33:42.067Z (10 months ago)
- Topics: functional-go, functional-go-template, go-functional, go-functional-programming, go-lib, go-library, golang-functional-programming, golang-lib, golang-library
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 18
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Lambda-Go
[](https://raw.githubusercontent.com/araujo88/lambda-go/main/LICENSE)
[](https://github.com/araujo88/lambda-go/actions/workflows/go.yml)## Overview
Lambda-Go is a library designed to extend Go's capabilities with functional programming techniques inspired by Haskell. It aims to provide Go developers with tools to write cleaner, more expressive code while leveraging Go's strong typing and efficiency.
## Features
- **Core Functional Constructs**: Implements fundamental functional programming operations like `map`, `foldl`, `foldr`, and more.
- **Tuples Support**: Generic tuple data structure for handling paired data.
- **Utilities**: A collection of utilities such as `reverse`, `concat`, and `unique` to manipulate slices.
- **Predicate Functions**: Includes functions like `filter`, `any`, `all`, and `find` to work with predicates effectively.
- **Sorting and Grouping**: Functions for sorting slices and grouping elements based on specified criteria.## Getting Started
### Prerequisites
- Go 1.18 or higher (requires support for generics)
### Installing
To use Lambda-Go in your project, start by cloning the repository:
```bash
git clone https://github.com/araujo88/lambda-go.git
```Then, import the required subpackages in your Go application:
```go
import (
"github.com/araujo88/lambda-go/pkg/core"
"github.com/araujo88/lambda-go/pkg/utils"
)
```### Usage Examples
Here are some simple examples to get you started:
**Using `Map` to double the values in a slice:**
```go
package mainimport (
"fmt"
"github.com/araujo88/lambda-go/pkg/core"
)func main() {
slice := []int{1, 2, 3, 4, 5}
doubled := core.Map(slice, func(x int) int { return x * 2 })
fmt.Println(doubled)
}
```**Filtering a slice of integers:**
```go
package mainimport (
"fmt"
"github.com/araujo88/lambda-go/pkg/predicate"
)func main() {
slice := []int{1, 2, 3, 4, 5}
filtered := predicate.Filter(slice, func(x int) bool { return x > 3 })
fmt.Println(filtered)
}
```## Contributing
We welcome contributions! If you have suggestions or want to improve the library, feel free to make a pull request.
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.