[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.lisp

Returning the larger functions

gengyangcai

11/15/2015 11:48:00 AM


I wrote a function that takes 2 arguments and returns the larger one.

CL-USER 4 : 2 > (defun greater (x y)
(if (> x y) x y))
GREATER

CL-USER 5 : 2 > (greater 5 6)
6

2 Answers

rpw3

11/15/2015 12:02:00 PM

0

CAI GENGYANG <gengyangcai@gmail.com> wrote:
+---------------
| I wrote a function that takes 2 arguments and returns the larger one.
| CL-USER 4 : 2 > (defun greater (x y)
| (if (> x y) x y))
| GREATER
|
| CL-USER 5 : 2 > (greater 5 6)
| 6
+---------------

Wasted effort. CL already has a builtin MAX function:

> (max 5 6)

6
>

See:

http://www.lispworks.com/documentation/HyperSpec/Body/f...


-Rob

-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <http://rpw...
San Mateo, CA 94403

Norbert_Paul

11/15/2015 12:03:00 PM

0

Great! See http://clhs.lisp.se/Body/f...

CAI GENGYANG wrote:
>
> I wrote a function that takes 2 arguments and returns the larger one.
>
> CL-USER 4 : 2> (defun greater (x y)
> (if (> x y) x y))
> GREATER
>
> CL-USER 5 : 2> (greater 5 6)
> 6
>