0

Hi again, new assignment is to creat a spynetwork (where does he get his ideas?) anyway the program is supposed to take a code (i.e. caesars code) as a list of 2 lists, store the code (i've used a table for mine) then use it to decode and encode messages..... I have got all of this working, however, you are supposed to be able to use

(define (a-ciphermachine mapping)
  (let
	(
	(temp-table (a-table))
	)
  (put-code mapping)
  (define (the-ciphermachine op)
        (cond ((eq? op 'encode)      encode)
              ((eq? op 'decipher)    decipher)
              ((eq? op 'destroy)     destroy)
              (else (error "ciphermachine: unknown operation" op))
        )
  )
  
  (define (encode message)
     (change message)
     )
     

  
  (define (decipher message)
  (dechange message)
  )
  
 (define (destroy)
 (sequence
 (put-code destroy-code)
 #t
 )
)
				   
 the-ciphermachine
)
)

to be able to create different machines, i.e. enigma, tom, fred, whatever. all with different codes, and them all work at the same time.
I figured the Let statement would mean that they create their own tables, and would only use their own, however I am getting an unbound variable for temp-table when I run it and try to do anything.
If i declare the table in the main body, it will work, but all machines will use the same code. HELP!

thanks :)

1
Contributor
1
Reply
4
Views
9 Years
Discussion Span
Last Post by nanaman
0

Hi again, new assignment is to creat a spynetwork (where does he get his ideas?) anyway the program is supposed to take a code (i.e. caesars code) as a list of 2 lists, store the code (i've used a table for mine) then use it to decode and encode messages..... I have got all of this working, however, you are supposed to be able to use

(define (a-ciphermachine mapping)
  (let
	(
	(temp-table (a-table))
	)
  (put-code mapping)
  (define (the-ciphermachine op)
        (cond ((eq? op 'encode)      encode)
              ((eq? op 'decipher)    decipher)
              ((eq? op 'destroy)     destroy)
              (else (error "ciphermachine: unknown operation" op))
        )
  )
  
  (define (encode message)
     (change message)
     )
     

  
  (define (decipher message)
  (dechange message)
  )
  
 (define (destroy)
 (sequence
 (put-code destroy-code)
 #t
 )
)
				   
 the-ciphermachine
)
)

to be able to create different machines, i.e. enigma, tom, fred, whatever. all with different codes, and them all work at the same time.
I figured the Let statement would mean that they create their own tables, and would only use their own, however I am getting an unbound variable for temp-table when I run it and try to do anything.
If i declare the table in the main body, it will work, but all machines will use the same code. HELP!

thanks :)

nevermind got this working

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.