I am writing a program which takes in a list and outputs true if the elements in the list alternate signs. For example if the first number is positive, the second number must be negative and then the third number must be positive again and so on.
I've tried implementing a simple cond statement (shown in the code) but keep coming across an error in my check-expect. The error states: first: expects only 1 argument, but found 2.
(define (alternating? lst)
(cond [(empty? lst) true]
[(> (first lst) 0)
(cond [(< (first (rest lst) 0)) (alternating? (rest lst))])]
[(< (first lst) 0)
(cond [(> (first (rest lst) 0)) (alternating? (rest lst))])]
[else false]))
When looking at the code, it looks like first does in fact only take in one argument from the list, but the error says that this is not the case.