8000
Skip to content
This repository was archived by the owner on Nov 6, 2023. It is now read-only.

maeda6uiui/go-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-counter

Overview

Returns the frequency of each element in a string slice.

Usage

Installation

go get github.com/maeda6uiui/go-counter

Code sample

package main

import (
	"fmt"

	"github.com/maeda6uiui/go-counter"
)

func main() {
	ss := []string{"a", "a", "a", "b", "c", "d", "a", "a", "d", "c"}
	c := counter.NewCounter(ss)

	keys, freqs := c.MostCommon()
	for i := 0; i < len(keys); i++ {
		fmt.Printf("%v %v\n", keys[i], freqs[i])
	}
}
a 5
d 2
c 2
b 1

About

Golangで実装されたCounter

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

0