mv /ana, /ledger to /src/

This commit is contained in:
bel
2023-10-28 09:29:39 -06:00
parent ec6d868ff7
commit ea13bf7e4a
35 changed files with 12 additions and 11 deletions

49
src/ledger/like.go Normal file
View File

@@ -0,0 +1,49 @@
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) Any(delta Delta) bool {
for i := range likes {
if likes[i](delta) {
return true
}
}
return false
}
func (likes Likes) All(delta Delta) bool {
for i := range likes {
if !likes[i](delta) {
return false
}
}
return true
}