~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to doc/codewalk/markov.xml

  • Committer: Package Import Robot
  • Author(s): Ondřej Surý
  • Date: 2012-05-02 15:44:59 UTC
  • mfrom: (14.1.12 sid)
  • Revision ID: package-import@ubuntu.com-20120502154459-wcmy8ao1325ml619
Tags: 2:1.0.1-1
* Imported Upstream version 1.0.1
* Apply godoc patch to display package list correctly (Closes: #669354)

Show diffs side-by-side

added added

removed removed

Lines of Context:
215
215
 
216
216
<step title="Choosing a suffix at random" src="doc/codewalk/markov.go:/next := choices/,/Shift/">
217
217
        To choose a suffix we use the
218
 
        <code><a href="/pkg/rand/#Intn">rand.Intn</a></code> function.
 
218
        <code><a href="/pkg/math/rand/#Intn">rand.Intn</a></code> function.
219
219
        It returns a random integer up to (but not including) the provided
220
220
        value. Passing in <code>len(choices)</code> gives us a random index
221
221
        into the full length of the list.
287
287
        Here's a transcript of generating some text using the Go distribution's
288
288
        README file as source material:
289
289
        <pre>
290
 
$ ./markov -words=10 &lt $GOROOT/go/README
 
290
$ ./markov -words=10 &lt; $GOROOT/README
291
291
This is the source code repository for the Go source
292
 
$ ./markov -prefix=1 -words=10 &lt $GOROOT/go/README
 
292
$ ./markov -prefix=1 -words=10 &lt; $GOROOT/README
293
293
This is the go directory (the one containing this README).
294
 
$ ./markov -prefix=1 -words=10 &lt $GOROOT/go/README
 
294
$ ./markov -prefix=1 -words=10 &lt; $GOROOT/README
295
295
This is the variable if you have just untarred a</pre>
296
296
</step>
297
297