sharkman Posted May 4, 2010 Posted May 4, 2010 This problem involves arithmetic expressions, which may or may not be numbered. You may need to use the following help functions in addition to the buit-in functions including eval which evaluates an arithmetic expression. For example, (eval ‘(+ 1 2)) returns 3. (define (atom? x) (not (list? x))) (define build-aexp (lambda (op sub1 sub2) (cons op (cons sub1 (cons sub2 '()))))) (define numbered? (lambda (aexp) (cond ((atom? aexp) (number? aexp)) (else (and (numbered? (cadr aexp)) (numbered? (caddr aexp))))))) a)Write a function simplify which evaluates as much of an arithmetic expression as possible. For example, (simplify '(* 2 (+ (* a (+ 3 5)) (+ 1 4)))) should return (* 2 (+ (* a 5)) b)Write a function remove-noops which eliminates any additions of 0 or multiplications by 1. For example, both (remove-noops '(* 3 (* 1 (+ a 0)))) and (remove-noops (simplify '(* 3 (* 1 (+ a (- 1 1)))))) should return (* 3 a). Thank you for your help Quote
sharkman Posted May 4, 2010 Author Posted May 4, 2010 Yes scheme issue, I don't know what does SICP stand for, but it's for compiler's course, can you help me with this problem ?? Quote
Se7en Posted May 4, 2010 Posted May 4, 2010 SCIP = Structure and Interpretation of Computer programs. ( http://mitpress.mit.edu/sicp/full-text/book/book.html ) Compiler course? School or something like the Digital Mars Compiler weekend seminar thing? I'm not a CS. I'm self taught. Ive taken the SCIP course when MIT put it up on the Free courseware section and read a lot of books on programing but... Its been a long time since ive done scheme and or taken that course. I know we touched on that in one of the chapters...but the only help i would be able to offer you help now a days would be general and or broad in nature (academic if you would) on this kinda problem. Well, do you need actual code or just theory? BTW, you found a site which has users that use AutoLisp. AL is Scheme like but not really. AL is based upon a language called XLisp which was like a striped down version of Common lisp. This would be a translation from Scheme to Autolisp so you can see the different syntax's. Scheme: (define (atom? x) (not (list? x)) ) AutoLisp: (defun atom? ( x / ) (not (eq (type x) 'LIST)) ) Of course this is a direct translation and there are other ways of doing this same task in AutoLisp but you get the idea. I would recommend that you find a newsgroup for Scheme instead of here because I think I may be the only one who has taken a Scheme class. I gotta run now so good luck and i hope to talk to you later. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.