Skip to content

Instantly share code, notes, and snippets.

@macalinao
Created August 4, 2016 19:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save macalinao/caa9e7105864ce03835ecd32ce4499b6 to your computer and use it in GitHub Desktop.
Save macalinao/caa9e7105864ce03835ecd32ce4499b6 to your computer and use it in GitHub Desktop.
i cry every time
// StatusesWithIds finds all condition statuses that match the given ids.
func StatusesWithIds(in []*cpb.ConditionStatus, ids []*cpb.ConditionId) []*cpb.ConditionStatus {
// create our filter set
set := map[string]bool{}
for _, id := range ids {
set[util.StringifyID(id)] = true
}
// i.e. ids.map(util.StringifyID).toSet
// filter stuff out
var ret []*cpb.ConditionStatus
for _, status := range in {
if set[util.StringifyID(status.Id)] {
ret = append(ret, status)
}
}
// i.e. in.filter(set[util.StringifyID(_.Id)])
return ret
}
@aranibatta
Copy link

what is wrong with you ian, haha

@maplant
Copy link

maplant commented Aug 4, 2016

0/10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment