Hello, 
I try to write a programme (a game), where I use lots of mutable lists (named 
environment).Something like this:
(define environment 
     (mcons (mcons  (mcons 1 (mcons (mcons 2(mcons 5(mcons 8 '())))'() ))
            (mcons  (mcons 2 (mcons (mcons 1(mcons 3(mcons 10 '()))) '() ))
      ......
      '() ))
It should represent a 2D dekadedron.
And for easy manipulation I wrote a procedure: select-room and set-symbol.

(define select-room (lambda (number rooms)
                      (let loop ((l (mcar rooms)))
                        (if (not (null? l))
                            (if (= (mcar(mcar l)) number)
                                (mcar l)
                                (loop (mcdr l)) )))))
(define set-symbol
  (lambda (symbol number_of_room)
    (let ((traps (mcdr(select-room number_of_room environment))  ))
          (set-mcdr! traps (mcons symbol (mcdr traps))  ))))

I use it without problems : (select-room 2 environment) in this case.
But when I use it in another procedure (for example: set-symbol), sometimes 
Racket returns this:

  mcdr: contract violation    ;;(mcdr in let in set-symbol)
  expected: mpair?
  given: #<void>        ;;(returned by select-room ?)

In Racket documentation I found : " #<void> is returned by most forms and 
procedures that have a side-effect and no useful result."

But for me it REALLY has useful result. It´s really strange it appears only 
sometimes. And select-room returns a mutable list, so I´m really confused.

I would be glad for any help.

Thanks 
Joan

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to