Documentation ¶
Overview ¶
Package wordgame provides a dictionary search for word games. Given a dictionary and list of required characteds, the search returns list of matching words which include all the required characters.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilterFunc ¶
FilterFunc filtering function
func GivenWithExtra ¶
func GivenWithExtra(letters string, l int) FilterFunc
GivenWithExtra returns function matching all given characters plus any other character
func OnlyGiven ¶
func OnlyGiven(letters string, l int) FilterFunc
OnlyGiven returns function matching only the given characters
type WordList ¶
type WordList [][]rune
WordList holds the dictionary
func NewFromStrings ¶
NewFromStrings creates new dictionary and populates it with words
func (WordList) Filter ¶
func (wl WordList) Filter(ff FilterFunc) []string
Filter searches for matches by applying the filter function
Example ¶
package main import ( "fmt" "github.com/aquilax/wordgame" ) func main() { wl := wordgame.NewFromStrings([]string{ "cow", "chicken", "horse", "brocolly", }) result := wl.Filter(wordgame.GivenWithExtra("co", 0)) fmt.Printf("%+v", result) }
Output: [cow brocolly]
func (WordList) FilterConcurrent ¶
func (wl WordList) FilterConcurrent(ff FilterFunc, numWorkers int) []string
FilterConcurrent searches for matches by applying the filter function using pool of workers
Example ¶
package main import ( "fmt" "github.com/aquilax/wordgame" ) func main() { wl := wordgame.NewFromStrings([]string{ "cow", "chicken", "horse", "brocolly", }) result := wl.FilterConcurrent(wordgame.GivenWithExtra("co", 0), 2) fmt.Printf("%+v", result) }
Output: [cow brocolly]
Click to show internal directories.
Click to hide internal directories.