GitHub - calebcase/curry
source link: https://github.com/calebcase/curry
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Curry
Curry provides facilities for currying Go functions. The process
converts a single function like f(x, y, z)
into N many functions each taking
a single argument like h(x)(y)(z)
.
Currying can be useful as a way to provide partial function application. For
example, this takes a function that adds two integers and creates a new
function plus1
that increments the given value by 1.
package main import ( "fmt" "github.com/calebcase/curry" ) func Add(x, y int) int { return x + y } func main() { // Create a reusable function with the first argument bound to 1. plus1 := curry.A2R1(Add)(1) fmt.Println(plus1(2)) // 3 fmt.Println(plus1(3)) // 4 fmt.Println(plus1(4)) // 5 }
For more examples and usage see the go docs.
Build
The library is entirely generated with jennifer:
go generate
go test -v
Recommend
-
41
Note: This is part of the “Composing Software” series on learning functional programming and compositional software techniques in JavaScript ES6+ from the ground up. Stay tuned. There’s a lot more of this to come!...
-
2
-
7
Marijuana sold as Curry leaves( kadi patta) through Amazon
-
7
Essays on Combinatory Logic, Lambda Calculus and Formalism Can You Chip In?...
-
4
Nope nope nope nope — Steph Curry stars in new Nope teaser airing during NBA playoff games We still don't know much about the plot, but it's a savvy marketing move.
-
1
curry a iné príchute /home/robonovotny Funkcie s korením – curry a iné príchute 2021/09/13 Lemon cu...
-
2
Why Should You Curry? By Noam Yadgar [Sun, 04 Dec 2022 08:14:08 GMT] [email protected] Currying
-
3
How to Use Physics to Tell If That Steph Curry Video Is RealCould the Golden State Warriors legend really sink five full-court shots in a row? Some clever modeling can give fans a clue....
-
6
NBA star Steph Curry extends historic part...
-
1
Apple’s upcoming Steph Curry documentary is completely Underrated News
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK