I have a cond-and statement, and it gets triggered, even though it is f. It displays f with my display command. Statement 1 is true, statement 2 is false. Can you spot the error?:
Repl link:
(cond
((null? polyL) varL)
((and (var? (car polyL)) (sign? (next polyL)))
(display "T1, ")
(display (sign? (next polyL))) ;f
1 Like
Welcome to the forums!
Hmm… I don’t know Scheme, but just looking here, should your conditions look more like this:
(cond
(condition (action)))
Not this:
(cond
((action) condition))
Thanks for the try, but the Scheme way is:
(cond
((condition) (action))
So this:
(and (var? (car polyL)) (sign? (next polyL)))
Is something like:
(var? (car polyL)) && (sign? (next polyL))
And are the ?
checking for like non null values or something?
So this:
(cond
((null? polyL) varL)
((and (var? (car polyL)) (sign? (next polyL)))
(display "T1, ")
(display (sign? (next polyL)))
Is something like:
(cond
((condition) action)
((and (condition) (condition))
(action)
(action)
Yes, is this a variable? Is this a sign? Are both of these true?
1 Like
Like this:
(car is variable) && (next is sign)
Roughly, (car polyL) and (next polyL), polyL being a list / array. The additional () are for the cond. I’m thinking that it’s a) Something wrong somewhere else in the code, though I have looked, or b) My compiler.
1 Like
I found it. It’s to do with and not wanting to execute mutlitple return values, but I can’t find a way around this.
1 Like