Issue 33: Finished most aspects of the expression language (#38)

- Most aspects of scans and queries can now be represented using the expression language
- All constructs of the expression language can be used to evaluate items
This commit is contained in:
Leon Mika 2022-11-18 07:31:15 +11:00 committed by GitHub
parent 7d2817812c
commit 917663fac0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 1815 additions and 370 deletions

View file

@ -8,6 +8,19 @@ func Map[T, U any](ts []T, fn func(t T) U) []U {
return us
}
func MapWithError[T, U any](ts []T, fn func(t T) (U, error)) ([]U, error) {
us := make([]U, len(ts))
for i, t := range ts {
var err error
us[i], err = fn(t)
if err != nil {
return nil, err
}
}
return us, nil
}
func Filter[T any](ts []T, fn func(t T) bool) []T {
us := make([]T, 0)
for _, t := range ts {