Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
awall
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
alpine
awall
Commits
8d83347b
Commit
8d83347b
authored
Jul 13, 2012
by
Kaarle Ritvanen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
util.filter method for filtering lists
parent
d2e2fdf0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
awall/model.lua
awall/model.lua
+5
-7
awall/util.lua
awall/util.lua
+6
-0
No files found.
awall/model.lua
View file @
8d83347b
...
...
@@ -265,13 +265,11 @@ function Rule:trules()
local
function
ffilter
(
ofrags
)
if
not
ofrags
or
not
ofrags
[
1
]
or
not
families
then
return
ofrags
end
local
res
=
{}
for
i
,
ofrag
in
util
.
listpairs
(
ofrags
)
do
if
not
ofrag
.
family
or
util
.
contains
(
families
,
ofrag
.
family
)
then
table.insert
(
res
,
ofrag
)
end
end
return
res
return
util
.
filter
(
ofrags
,
function
(
of
)
return
not
of
.
family
or
util
.
contains
(
families
,
of
.
family
)
end
)
end
local
function
appendtarget
(
ofrag
,
target
)
...
...
awall/util.lua
View file @
8d83347b
...
...
@@ -18,6 +18,12 @@ function listpairs(var)
return
ipairs
(
list
(
var
))
end
function
filter
(
var
,
func
)
local
res
=
{}
for
i
,
v
in
ipairs
(
var
)
do
if
func
(
v
)
then
table.insert
(
res
,
v
)
end
end
return
res
end
function
map
(
var
,
func
)
local
res
=
{}
for
k
,
v
in
pairs
(
var
)
do
res
[
k
]
=
func
(
v
)
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment