package ledger import ( "regexp" ) type Like func(Delta) bool type likes []Like func LikeBefore(date string) Like { return func(d Delta) bool { return date >= d.Date } } func LikeAfter(date string) Like { return func(d Delta) bool { return date <= d.Date } } func LikeName(pattern string) Like { return func(d Delta) bool { return like(pattern, d.Name) } } func like(pattern string, other string) bool { return regexp.MustCompile(pattern).MatchString(other) } func (likes likes) all(delta Delta) bool { for i := range likes { if !likes[i](delta) { return false } } return true }