[ { "state": "start", "data": [ [ "comment", "// Concurrent computation of pi." ] ] }, { "state": "start", "data": [ [ "comment", "// See http://goo.gl/ZuTZM." ] ] }, { "state": "start", "data": [ [ "comment", "//" ] ] }, { "state": "start", "data": [ [ "comment", "// This demonstrates Go's ability to handle" ] ] }, { "state": "start", "data": [ [ "comment", "// large numbers of concurrent processes." ] ] }, { "state": "start", "data": [ [ "comment", "// It is an unreasonable way to calculate pi." ] ] }, { "state": "start", "data": [ [ "keyword", "package" ], [ "text", " " ], [ "identifier", "main" ] ] }, { "state": "start", "data": [] }, { "state": "start", "data": [ [ "keyword", "import" ], [ "text", " " ], [ "paren.lparen", "(" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "string", "\"fmt\"" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "string", "\"math\"" ] ] }, { "state": "start", "data": [ [ "paren.rparen", ")" ] ] }, { "state": "start", "data": [] }, { "state": "start", "data": [ [ "keyword", "func" ], [ "text", " " ], [ "identifier", "main" ], [ "paren.lparen", "(" ], [ "paren.rparen", ")" ], [ "text", " " ], [ "paren.lparen", "{" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "identifier", "fmt" ], [ "punctuation.operator", "." ], [ "identifier", "Println" ], [ "paren.lparen", "(" ], [ "identifier", "pi" ], [ "paren.lparen", "(" ], [ "constant.numeric", "5000" ], [ "paren.rparen", ")" ], [ "paren.rparen", ")" ] ] }, { "state": "start", "data": [ [ "paren.rparen", "}" ] ] }, { "state": "start", "data": [] }, { "state": "start", "data": [ [ "comment", "// pi launches n goroutines to compute an" ] ] }, { "state": "start", "data": [ [ "comment", "// approximation of pi." ] ] }, { "state": "start", "data": [ [ "keyword", "func" ], [ "text", " " ], [ "identifier", "pi" ], [ "paren.lparen", "(" ], [ "identifier", "n" ], [ "text", " " ], [ "identifier", "int" ], [ "paren.rparen", ")" ], [ "text", " " ], [ "identifier", "float64" ], [ "text", " " ], [ "paren.lparen", "{" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "identifier", "ch" ], [ "text", " " ], [ "punctuation.operator", ":" ], [ "keyword.operator", "=" ], [ "text", " " ], [ "identifier", "make" ], [ "paren.lparen", "(" ], [ "keyword", "chan" ], [ "text", " " ], [ "identifier", "float64" ], [ "paren.rparen", ")" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "keyword", "for" ], [ "text", " " ], [ "identifier", "k" ], [ "text", " " ], [ "punctuation.operator", ":" ], [ "keyword.operator", "=" ], [ "text", " " ], [ "constant.numeric", "0" ], [ "punctuation.operator", ";" ], [ "text", " " ], [ "identifier", "k" ], [ "text", " " ], [ "keyword.operator", "<=" ], [ "text", " " ], [ "identifier", "n" ], [ "punctuation.operator", ";" ], [ "text", " " ], [ "identifier", "k" ], [ "keyword.operator", "++" ], [ "text", " " ], [ "paren.lparen", "{" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "keyword", "go" ], [ "text", " " ], [ "identifier", "term" ], [ "paren.lparen", "(" ], [ "identifier", "ch" ], [ "punctuation.operator", "," ], [ "text", " " ], [ "identifier", "float64" ], [ "paren.lparen", "(" ], [ "identifier", "k" ], [ "paren.rparen", ")" ], [ "paren.rparen", ")" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "paren.rparen", "}" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "identifier", "f" ], [ "text", " " ], [ "punctuation.operator", ":" ], [ "keyword.operator", "=" ], [ "text", " " ], [ "constant.numeric", "0.0" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "keyword", "for" ], [ "text", " " ], [ "identifier", "k" ], [ "text", " " ], [ "punctuation.operator", ":" ], [ "keyword.operator", "=" ], [ "text", " " ], [ "constant.numeric", "0" ], [ "punctuation.operator", ";" ], [ "text", " " ], [ "identifier", "k" ], [ "text", " " ], [ "keyword.operator", "<=" ], [ "text", " " ], [ "identifier", "n" ], [ "punctuation.operator", ";" ], [ "text", " " ], [ "identifier", "k" ], [ "keyword.operator", "++" ], [ "text", " " ], [ "paren.lparen", "{" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "identifier", "f" ], [ "text", " " ], [ "keyword.operator", "+" ], [ "keyword.operator", "=" ], [ "text", " " ], [ "keyword.operator", "<" ], [ "keyword.operator", "-" ], [ "identifier", "ch" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "paren.rparen", "}" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "keyword", "return" ], [ "text", " " ], [ "identifier", "f" ] ] }, { "state": "start", "data": [ [ "paren.rparen", "}" ] ] }, { "state": "start", "data": [] }, { "state": "start", "data": [ [ "keyword", "func" ], [ "text", " " ], [ "identifier", "term" ], [ "paren.lparen", "(" ], [ "identifier", "ch" ], [ "text", " " ], [ "keyword", "chan" ], [ "text", " " ], [ "identifier", "float64" ], [ "punctuation.operator", "," ], [ "text", " " ], [ "identifier", "k" ], [ "text", " " ], [ "identifier", "float64" ], [ "paren.rparen", ")" ], [ "text", " " ], [ "paren.lparen", "{" ] ] }, { "state": "start", "data": [ [ "text", " " ], [ "identifier", "ch" ], [ "text", " " ], [ "keyword.operator", "<" ], [ "keyword.operator", "-" ], [ "text", " " ], [ "constant.numeric", "4" ], [ "text", " " ], [ "keyword.operator", "*" ], [ "text", " " ], [ "identifier", "math" ], [ "punctuation.operator", "." ], [ "identifier", "Pow" ], [ "paren.lparen", "(" ], [ "constant.numeric", "-1" ], [ "punctuation.operator", "," ], [ "text", " " ], [ "identifier", "k" ], [ "paren.rparen", ")" ], [ "text", " / " ], [ "paren.lparen", "(" ], [ "constant.numeric", "2" ], [ "keyword.operator", "*" ], [ "identifier", "k" ], [ "text", " " ], [ "keyword.operator", "+" ], [ "text", " " ], [ "constant.numeric", "1" ], [ "paren.rparen", ")" ] ] }, { "state": "start", "data": [ [ "paren.rparen", "}" ] ] }, { "state": "start", "data": [] } ]