| | |
Stupid Scheme and Let statements
Thread Solved |
•
•
Join Date: Nov 2007
Posts: 8
Reputation:
Solved Threads: 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
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
(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
•
•
Join Date: Nov 2007
Posts: 8
Reputation:
Solved Threads: 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
![]() |
Other Threads in the Legacy and Other Languages Forum
- Previous Thread: How to implement heap in lisp?
- Next Thread: read old basic files into vb6
| Thread Tools | Search this Thread |





