Define functions in Common Lisp

1

I'm trying to understand how Common Lisp works, and looking at some exercises. I find that a max-min tree is defined, as follows:

(max ((min (4 5))
(min (6
(max (3 4))
(max (7 9))))
(min (3 8)))))

You are asked to define several functions in Common Lisp.

The first one asks to return a boolean that tells us if the tree is a leaf (number) or not.

I have written something like this, looking at several manuals that I have found on the internet, but I do not know if it is correct, or not.

 (defun hoja-arbol (hoja)
 (numerp hoja))

Others that are asked are:

  • returns a number if the tree is a leaf, otherwise returns nil

  • returns a Boolean, indicates if the root of the tree is min

  • returns a Boolean, indicates if the root of the tree is max

  • returns the list of children if the tree is not a leaf, otherwise returns nil

If someone could guide me, to try to generate the functions that they ask me, I would be very grateful.

    
asked by gonzalo perl 03.04.2017 в 11:20
source

0 answers