...
- We need some data to use for our timing experiments. Write a function
up: nat -> (list-of nat)
which constructs a list of naturals starting with0
in ascending order or retrieve it from a previous lab. For example,(up 7)
returns(list 0 1 2 3 4 5 6)
. You can probably write it faster usingbuild-list
that you can retrieve it. Similarly, write a functiondown: nat -> (list-of nat)
that constructs a list of naturals ending in0
in descending order. For example,(nums-down 7)
returns(list 6 5 4 3 2 1 0)
.
Now write a functionCode Block rands
Wiki Markup that constructs a list of random numbers in the range from {{0}} to {{32767}}. To create a single random number in the range from {{0}} to {{_n_}}, compute {{(random _n+1_)}}. For larger numbers in the range {{\[0, 32768)}}, try:
Note:Code Block (define max-rand 32768) (random max-rand) ; random is built-in
is a function in the Scheme library, but it is not a mathematical function, since the output is not determined by the input.Code Block random
HTML </li>
HTML </ol>
...