I am trying to create a truth table generator for a digital electronics course, because this is how I have fun in my free time and do not judge myself.
Anywho, I decided that I would have a hash with the equivalent of operator strings as keys and procedure schemas that match these operators as values.
eg.
(define operator-table #hash (("+". or)
("*". and)))
So that I could do something like
(lambda (ab) ((hash-ref operator-table (string-ref input-str i)) ab))
Now I understand that the above probably won't work right, but since I can't even mess around with it until I get it right, because obviously and and or are special in the Scheme. In REPL, if I type not , it answers #<procedure:not> . But if I give him and or or , he says and: bad syntax in: and . Is there a version of and procedure that I can use? Or do I need to do one with lambda ? Or am I missing something?
The only reason I donβt just go with the lambda from get-go is because I donβt want to lose the ability of the -arity variable of the built-in and [I can do (and #t #f) as well (and #t #f #f #t #f #t) ].
source share