I am using a function that takes arguments as follows:
(test-function '((gate 1) (gate 3) (gate 2)))
The list argument can contain any number of elements where each element is of the form (gate x)
where x
can be an integer from 0 to 8. I have a function, generate-gate-list
, that generates lists of random length (up to 10) and content, although they are ALWAYS of the form above.
Example output of generate-gate-list: ((gate 2))
, (())
, ((gate 1) (gate 6))
, etc.
I would like to be able to nest generate-gate-list
inside test-function
so that I can test a bunch of randomly generated lists without generating them all beforehand. In other words, I'd like something like this: (test-function '(generate-gate-list))
except where generate-gate-list has been evaluated. I've tried some sort of macro syntax-quote and unquoting, but that leads to resolved variables, like (user/gate 3)
which screws up test-function. Here's my generate-gate-list code:
(defn generate-gate-list []
(map symbol (repeatedly (rand-int 10) #(random-gate))))
random-gate
outputs a gate element as a string, i.e "(gate 3)"
or "(gate 2)"
.
So in short, I'd like (test-function (something-here (generate-gate-list)))
or (test-function (modified-generate-gate-list))
to be equivalent to (test-function '((gate 1) (gate 4) (gate 2)))
or some other arbitrary output of generate-gate-list. Thanks!
gate
a function? If so, what does it do? – Thumbnailgate
is a function, but I can't modify it. – user3225710