Hello there, I am a beginner in Lisp, I am currently practicing XLisp, so I have this little program to find the maximum of a given list,recursively. So i came up with this so far, I am quite sure this is the correct solution, except there is one problem - I do not have a clue what should i put in the terminating case, when the list is null, what should I return after I checked the whole list, so the program could end? Thanks in advance

(defun maxim(list)

(cond

((null list) (???))

((> (car list)(car(cdr list)) (car list) (maxim(cdr list))))

)

)

## XLisp Maximum of a list

### Re: XLisp Maximum of a list

Recursion in programming is similar to mathematical induction. You should not think about terminating case as such, although it certainly has to terminate to work, but about a base case, which is the simplest case for a given function.

For a maximum function on a list one formulation of a simplest case is, that given a number and nothing, the number is returned. An empty list would then be checked, if ever, as argument consistency check, not recursion case. You might also consider using an accumulator argument, which would allow the function to be written tail recursively.

I am not sure how to explain this better. If you have problems, try to express the operation in words first, before writing code. In particular, your COND condition expression, unless XLisp is very different from CL, doesn't really make sense.

For a maximum function on a list one formulation of a simplest case is, that given a number and nothing, the number is returned. An empty list would then be checked, if ever, as argument consistency check, not recursion case. You might also consider using an accumulator argument, which would allow the function to be written tail recursively.

I am not sure how to explain this better. If you have problems, try to express the operation in words first, before writing code. In particular, your COND condition expression, unless XLisp is very different from CL, doesn't really make sense.

### Re: XLisp Maximum of a list

Maybe important to know (if you run across XLisp for the first time) is that there exist several different XLisp versions, which are unfortunately more or less incompatible to each other. The "X" in XLisp stands for "experimental" and that's what XLisp is most about.

XLisp_2.0 then was further developed by a group of programmers around by Tom Almy, who tried to make XLisp_2.0 more compatible with Common Lisp. They released several XLisp_2.0 derivates under Names like "XLisp_2.1" and "XLisp-Plus", which are only partially backwards compatible with XLisp_2.0.

The official XLisp Homepage of David Betz (original author of XLisp) can be found here:

I myself have worked several years with XLisp as part of the "Nyquist" programming language for sound synthesis and music composition by Roger Dannenberg, which is based on XLisp_2.0 by David Betz:

Over the years I have collected and HTML-ified all documents and papers I could find in the net about XLisp_2.0. You can read and download the XLisp_2.0 documents collection for free from the german Audacity forum. Audacity is a free audio editor with an integrated Nyquist/XLisp interpreter.

Please note that this document collection is not very useful with the current XLisp_3.0 version, which is based on Scheme. The XLisp_3.0 documentation can be downloaded from David Betz's homepage (see above).

For the sake of completeness and because there are still many XLisp_2.1.x (the "x" is a lowercase letter from "a" to "g") and XLisp-Plus versions around in the net, here the link to Tom Almy's XLisp-Plus page:

There also exist several other XLisp derivates:

To answer Paul's "maximum of a list" question it would be very helpful to know the exact XLisp version number and wether it's one of the David Betz original versions or one of the many derivates.

**XLisp 1.x**- I have never worked with this version and cannot tell much about it.**XLisp 2.x**- is an object-oriented Lisp and one of the predecessors of Common Lisp, but instead of CLOS, XLisp_2.0 uses a SmallTalk-like message passing object model. Shortly after the release of XLisp_2.0 by David Betz (original author of XLisp) in the early 1980s, the Common Lisp discussions began.XLisp_2.0 then was further developed by a group of programmers around by Tom Almy, who tried to make XLisp_2.0 more compatible with Common Lisp. They released several XLisp_2.0 derivates under Names like "XLisp_2.1" and "XLisp-Plus", which are only partially backwards compatible with XLisp_2.0.

**XLisp 3.x**- is a complete rewrite of XLisp_2.0 to Scheme, again by David Betz, but more or less fully backwards incompatible to XLisp_2.x.The official XLisp Homepage of David Betz (original author of XLisp) can be found here:

**XLisp 3.0**homepage: http://www.xlisp.org/I myself have worked several years with XLisp as part of the "Nyquist" programming language for sound synthesis and music composition by Roger Dannenberg, which is based on XLisp_2.0 by David Betz:

**Nyquist**homepage: http://www.cs.cmu.edu/~music/music.software.htmlOver the years I have collected and HTML-ified all documents and papers I could find in the net about XLisp_2.0. You can read and download the XLisp_2.0 documents collection for free from the german Audacity forum. Audacity is a free audio editor with an integrated Nyquist/XLisp interpreter.

**XLisp_2.0**documents collection: http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/xlisp/xlisp-index.htmPlease note that this document collection is not very useful with the current XLisp_3.0 version, which is based on Scheme. The XLisp_3.0 documentation can be downloaded from David Betz's homepage (see above).

For the sake of completeness and because there are still many XLisp_2.1.x (the "x" is a lowercase letter from "a" to "g") and XLisp-Plus versions around in the net, here the link to Tom Almy's XLisp-Plus page:

**XLisp Plus**homepage: http://almy.us/xlisp.htmlThere also exist several other XLisp derivates:

**S-Lisp**documentation: http://sig.biostr.washington.edu/share/skandha4/html/slisp_toc.html - XLisp + the skandha4 3d-graphics library**Winterp**homepage: http://nielsmayer.com/winterp/ - XLisp + the Motif graphics toolkit**(X)Lisp-Stat**homepage: http://www.stat.uiowa.edu/~luke/xls/xlsinfo/xlsinfo.html - using XLisp for statistical computationsTo answer Paul's "maximum of a list" question it would be very helpful to know the exact XLisp version number and wether it's one of the David Betz original versions or one of the many derivates.