Forum archive 2000-2006

Kenneth Appel - Where did you hide your language?

Kenneth Appel - Where did you hide your language?

by Arnold Pizer -
Number of replies: 0
inactiveTopicWhere did you hide your language? topic started 3/15/2001; 4:37:01 PM
last post 3/15/2001; 5:20:20 PM
userKenneth Appel - Where did you hide your language?  blueArrow
3/15/2001; 4:37:01 PM (reads: 970, responses: 1)
Since I am a Perl novice, I have been trying to learn more of the language by reading your problems. I am also reading Wall and Schwartz's Programming Perl and it is clear that you are not just using vanilla Perl. For instance, I assume that random(2,15,1) probably means pick a number in the range 2-15 (does the 1 mean an integer?) Where would I find the descriptions of such things?

<| Post or View Comments |>


userArnold K. Pizer - Re: Where did you hide your language?  blueArrow
3/15/2001; 5:20:20 PM (reads: 1162, responses: 0)
Just as you guessed random(a,b,c) picks a random number between a and b with step size c. This is an example of a WeBWorK macro which was written to make it easier to write problems. Most of these macros are contained in the files PGbasicmacros.pl, PGchoicemacros.pl, PGgraphmacros.pl and PGnumericalmacros.pl.

One way to find information is to type e.g. "random" in the search box to the left. This may bring up helpful information. Unfortuately, the real documentation for random is contained in the script itself and a nice version is created on the fly when you access it. However, this means the search routine doesn't find it so you have to know where to look. So I finally come to the answer to your question.

Start at the left and follow the path: Write-modify problems/PG advanced reference/Macros in the file PGbasicmacros.pl. Then use your web brower to search for random on this page. You will find:

 

Pseudo-random number generator
Usage:
random(0,5,.1) # produces a random number between 0 and 5 in increments
of .1
non_zero_random(0,5,.1) # gives a non-zero random number

Another good reference is Tom Shemanske's WeBWorK Newbie Guide.

<| Post or View Comments |>