packagemaintypestatestruct{counties[]county}typecountystruct{towns[]town}typetownstruct{people[]string}funcmain(){s:=state{counties:[]county{{towns:[]town{{people:[]string{"tony","tom","mike"},},{people:[]string{"kelly","sara","tony"},},},},{towns:[]town{{people:[]string{"tony","amanda"},},{people:[]string{"john","katie","tony"},},},},},}_=allTownsContainPerson(s,"tony")_=allTownsContainPersonWithFunc(s,"tony")}funcallTownsContainPerson(sstate,personstring)bool{for_,c:=ranges.counties{townLevel:for_,t:=rangec.towns{for_,p:=ranget.people{ifp==person{// This town has the person, so no need to check remaining populationcontinuetownLevel}}}}returnfalse}funcallTownsContainPersonWithFunc(sstate,personstring)bool{townContainsPerson:=func(ttown,personstring)bool{for_,p:=ranget.people{ifp==person{returntrue}}returnfalse}for_,c:=ranges.counties{for_,t:=rangec.towns{if!townContainsPerson(t,person){returnfalse}}}returntrue}
Contrived example:
```go
package main
type state struct {
counties []county
}
type county struct {
towns []town
}
type town struct {
people []string
}
func main() {
s := state{
counties: []county{
{
towns: []town{
{
people: []string{"tony", "tom", "mike"},
},
{
people: []string{"kelly", "sara", "tony"},
},
},
},
{
towns: []town{
{
people: []string{"tony", "amanda"},
},
{
people: []string{"john", "katie", "tony"},
},
},
},
},
}
_ = allTownsContainPerson(s, "tony")
_ = allTownsContainPersonWithFunc(s, "tony")
}
func allTownsContainPerson(s state, person string) bool {
for _, c := range s.counties {
townLevel:
for _, t := range c.towns {
for _, p := range t.people {
if p == person {
// This town has the person, so no need to check remaining population
continue townLevel
}
}
}
}
return false
}
func allTownsContainPersonWithFunc(s state, person string) bool {
townContainsPerson := func (t town, person string) bool {
for _, p := range t.people {
if p == person {
return true
}
}
return false
}
for _, c := range s.counties {
for _, t := range c.towns {
if !townContainsPerson(t, person) {
return false
}
}
}
return true
}
```
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Contrived example: