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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top