mirror of
https://github.com/rwxrob/bonzai
synced 2024-11-16 21:25:44 +00:00
Add mapf for map functions
This commit is contained in:
parent
d1cb39cdac
commit
e38023c38c
10
mapf/mapf.go
Normal file
10
mapf/mapf.go
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
Package mapf contains nothing but map functions suitable for use with
|
||||
the fn.Map generic function or the equivalent fn.A method. See the maps
|
||||
package for functions that accept entire generic slices to be
|
||||
transformed with mapf (or other) functions.
|
||||
*/
|
||||
package mapf
|
||||
|
||||
// HashComment adds a "# " prefix.
|
||||
func HashComment(i string) string { return "# " + i }
|
13
mapf/mapf_test.go
Normal file
13
mapf/mapf_test.go
Normal file
@ -0,0 +1,13 @@
|
||||
package mapf_test
|
||||
|
||||
import (
|
||||
"github.com/rwxrob/bonzai/fn"
|
||||
"github.com/rwxrob/bonzai/mapf"
|
||||
)
|
||||
|
||||
func ExampleHashComment() {
|
||||
fn.A[string]{"foo", "bar"}.M(mapf.HashComment).P()
|
||||
// Output:
|
||||
// # foo
|
||||
// # bar
|
||||
}
|
Loading…
Reference in New Issue
Block a user