Question

So I have written this function that returns a list of numbers in this format:

'(1 2 5 6 7 2)

Now I need to find the maximum value of this list, but the max function doesn't seem to work with this type of list. How would I go about solving this problem?

Was it helpful?

Solution

What you want is

> (max 1 2 5 6 7 2)
7

Since your arguments are in a list, use apply:

> (apply max '(1 2 5 6 7 2))
7

See also here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top