An additional example, I hope it's useful.
I think it's easy to explain if we replace (random) with a new
function (get-counter!) that instead of generating a random number, it
provides an increasing sequence.
#lang racket
(define secret-counter 0)
(define (get-counter!)
Or:
(build-list n (lambda (dont-care) (make-random-string)))
On Tue, Oct 25, 2016 at 10:42 PM, Robby Findler wrote:
> I would probably write that function like this:
>
> #lang racket
>
> (provide
> (contract-out
> [make-a-string (-> non-empty-string?
I would probably write that function like this:
#lang racket
(provide
(contract-out
[make-a-string (-> non-empty-string? string?)]))
(define (make-a-string candidates)
(apply
string
(for/list ([i (in-range (random 100))])
(string-ref candidates (random (string-length
Hi,
I want to create a list of random strings.
For that I have created a function, which returns a string
of random length and random contents.
Then I used
make-list n (make-random-string)
to create that listand get back a list filled with n
identical strings.
h...
make-list
4 matches
Mail list logo