Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
a5e10edc
Commit
a5e10edc
authored
Nov 26, 2012
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
doc/play: don't use println in examples
R=golang-dev, rsc CC=golang-dev
https://golang.org/cl/6849105
parent
2e73453a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
9 deletions
+13
-9
doc/play/fib.go
doc/play/fib.go
+3
-1
doc/play/sieve.go
doc/play/sieve.go
+3
-1
doc/play/solitaire.go
doc/play/solitaire.go
+7
-7
No files found.
doc/play/fib.go
View file @
a5e10edc
package
main
import
"fmt"
// fib returns a function that returns
// successive Fibonacci numbers.
func
fib
()
func
()
int
{
...
...
@@ -13,5 +15,5 @@ func fib() func() int {
func
main
()
{
f
:=
fib
()
// Function calls are evaluated left-to-right.
p
rintln
(
f
(),
f
(),
f
(),
f
(),
f
())
fmt
.
P
rintln
(
f
(),
f
(),
f
(),
f
(),
f
())
}
doc/play/sieve.go
View file @
a5e10edc
...
...
@@ -2,6 +2,8 @@
package
main
import
"fmt"
// Send the sequence 2, 3, 4, ... to channel 'ch'.
func
Generate
(
ch
chan
<-
int
)
{
for
i
:=
2
;
;
i
++
{
...
...
@@ -26,7 +28,7 @@ func main() {
go
Generate
(
ch
)
// Launch Generate goroutine.
for
i
:=
0
;
i
<
10
;
i
++
{
prime
:=
<-
ch
print
(
prime
,
"
\n
"
)
fmt
.
Println
(
prime
)
ch1
:=
make
(
chan
int
)
go
Filter
(
ch
,
ch1
,
prime
)
ch
=
ch1
...
...
doc/play/solitaire.go
View file @
a5e10edc
...
...
@@ -89,7 +89,7 @@ func solve() bool {
// see if this new board has a solution
if
solve
()
{
unmove
(
pos
,
dir
)
p
rintln
(
string
(
board
))
fmt
.
P
rintln
(
string
(
board
))
return
true
}
unmove
(
pos
,
dir
)
...
...
@@ -102,7 +102,7 @@ func solve() bool {
// tried each possible move
if
n
==
1
&&
(
center
<
0
||
last
==
center
)
{
// there's only one peg left
p
rintln
(
string
(
board
))
fmt
.
P
rintln
(
string
(
board
))
return
true
}
// no solution found for this board
...
...
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