reset password
Author Message
lhairap
Posts: 11
Posted 00:28 Oct 23, 2015 |

(define (incerement ticks-pair)
  (if(and (<= (first ticks-pair) 400) (= ball1-going-up 1))
     (list (+ 2 (first ticks-pair)) (second ticks-pair))
     (block
      (set! ball1-going-up 0)
      (if (> (first ticks-pair) 0)
          (list (- 2 (first ticks-pair)) (second ticks-pair))
          (set! ball1-going-up 1)))))

-This function should check the ball which is going from bottom to top. 

-When the ball is going up 'ball1-going-up' is 1. And it will be 0 when '(first ticks-pair)' gets to 400, and thats when the ball should come from top to bottom.

-When the ball gets to that point I'm getting the following error:

first: contract violation
  expected: (and/c list? (not/c empty?))
  given: #<void>

Cannot figure out what is causing the error. Is subtracting from 'tick' allowed?

 

dle35
Posts: 22
Posted 08:14 Oct 23, 2015 |

I have this problem before to solve it u have to switch between Tick and 2 in your case.

(- 2 (first ticks-pair)) this mean u use 2 - tick and it will be out of bound

try to switch - Tick and 2.

 

 

lhairap
Posts: 11
Posted 18:07 Oct 23, 2015 |

Thank you.