You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please check out the examples to see how to use the library.
package main
import (
"fmt"
u "github.com/rjNemo/underscore"
)
funcmain() {
numbers:= []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
// filter even numbers from the sliceevens:=u.Filter(numbers, func(nint) bool { returnn%2==0 })
// square every number in the slicesquares:=u.Map(evens, func(nint) int { returnn*n })
// reduce to the sumres:=u.Reduce(squares, func(n, accint) int { returnn+acc }, 0)
fmt.Println(res) // 120
}
Getting Started
These instructions will get you a copy of the project up and running on your local
machine for development and testing purposes.
Prerequisites
You need at least go1.24 for development. The project is shipped with a Dockerfile
based on go1.24.
If you prefer local development, navigate to the official
download page and install version 1.24 or beyond.
underscore provides many of functions that support your favorite functional helpers
Collections
All
Any
Contains (only numerics values at the moment)
Each
Filter
Flatmap
GroupBy
Find
Map
Max
Min
Partition
Reduce
Pipe
Calling NewPipe will cause all future method calls to return wrapped values. When
you've finished the computation, call Value to retrieve the final value.
Methods not returning a slice such as Reduce, All, Any, will break the Chain
and return Value instantly.
Built With
Go - Build fast, reliable, and efficient software at scale
Contributing
Please read CONTRIBUTING.md for details on our code of conduct,
and the process for submitting pull requests to us.