Stupid Scheme and Let statements

Thread Solved

Join Date: Nov 2007
Posts: 8
Reputation: nanaman is an unknown quantity at this point 
Solved Threads: 0
nanaman nanaman is offline Offline
Newbie Poster

Stupid Scheme and Let statements

 
0
  #1
Dec 11th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Nov 2007
Posts: 8
Reputation: nanaman is an unknown quantity at this point 
Solved Threads: 0
nanaman nanaman is offline Offline
Newbie Poster

Re: Stupid Scheme and Let statements

 
0
  #2
Dec 11th, 2007
Originally Posted by nanaman View Post
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
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the Legacy and Other Languages Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC