I am trying to create a random tree from lists in Racket.
The tree is made from a list of operators and a list of terminals.
The output will look like this:
'(* (+ 2 4) 2)
So the list can be called with the eval function.
Further there should be a maximum level specified.
So my guess is the procedure will look like the following.
(define (make-tree tree level) ... )
I thought about using the map function and expanding each level at depth, but I'm new to lisp-likes so I'm finding it hard to figure the algorithm I need.
At the moment each operator only takes two parameters (essentially the generated trees are binary trees), but it would be useful to include in any answer how to expand the function to enable three or more parameters.
'(* (+ (2 4) 2))represent ? - Kevin*is the root and has 2 children,(+ 2 4)and2, shouldn't it be'(* (+ 2 4) 2)? - Kevin