(defparameter *simple-sandwich* '((sandwich (wrapper filling)) (filling (spread veg sauces herbs meat-filling)) (spread butter olive-oil margarine olive-spread) (veg (salads vegetable)) (salads iceburg-lettuce spinach rocket) (vegetable tomato pickles red-onion white-onion cucumber olives) (meat-filling (cheese meat)) (meat bacon ham chicken prawns shrimp salmon) (herbs rosemary sage thyme) (sauces horseraddish ketchup mayo saladcream saladdressing) (cheese cheddar edam swiss feta) (wrapper white-bread brown-bread))) (defun entry-p (entry) "Checks if entry is a category of an entry to a category" (assoc entry *simple-sandwich*)) (defun lhs (list) "Returns the first of a list" (first list)) (defun rhs (list) "Returns the rest of a list" (rest list)) (defun entry (entry) (rhs (assoc entry *simple-sandwich*))) (defun random-entry (list) "Returns a random entry of a list" (elt list (random (length list)))) (defun generate (phrase) (cond ((listp phrase) (apply #'append (mapcar #'generate phrase))) ((entry-p phrase) (generate (random-entry (entry phrase)))) (t (list phrase))))