Is it possible to do the same in Racket?
What I would like to obtain is, based on a given list of symbols, a generator that produces new lists by inserting e.g. the symbols
* at varying places in the given list.
You don't need to declare the function differently. You can just use generators in Racket; the docs are here: 4.15.3 Generators
I think this may be the way to write a function
seq-gen that produces a generator, in this case a generator that generates the elements given in the
(require racket/generator) (define (seq-gen seq) (generator () (let loop ([x seq]) (if (null? x) 0 (begin (yield (car x)) (loop (cdr x))))))) (let ([sgen (seq-gen '(A B C))]) (list (sgen) (sgen) (sgen) (sgen)))
The reason I had problem with this in the beginning was that I forgot to specify