943,568 Members | Top Members by Rank

Ad:
Dec 11th, 2007
0

Stupid Scheme and Let statements

Expand 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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nanaman is offline Offline
8 posts
since Nov 2007
Dec 11th, 2007
0

Re: Stupid Scheme and Let statements

Click to Expand / Collapse  Quote originally posted by nanaman ...
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
nanaman is offline Offline
8 posts
since Nov 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Legacy and Other Languages Forum Timeline: How to implement heap in lisp?
Next Thread in Legacy and Other Languages Forum Timeline: read old basic files into vb6





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC