문제

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