// Map returns a copy of the string s with all its characters modified
// according to the mapping function. If mapping returns a negative value, the character is
// dropped from the string with no replacement.
func Map(mapping func(rune) rune, s string) string
strings.Map을 활용해서 string index를 들여다볼 수 있다.
forr을 활용해서 각 string을 보려고 하면 int32 type을 가지고 있어서 string과 비교할 수 없어서 strings.Map이 필요하다.
vps := func(r rune) rune{
if r == '(' {
s.push(1)
} else {
d := s.pop()
if d == -1 {
s.vps = false
}
}
return r
}
strings.Map(vps, ps)
백준 9012번을 풀면서 작성한 코드로
입력 받은 ps안에 (를 만나면 스택에 push를,
)를 만나면 stack에 pop을 하도록 만들었다.