Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top