mit-scheme-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MIT-Scheme-users] Useless parts of code


From: razvanflorea
Subject: [MIT-Scheme-users] Useless parts of code
Date: Mon, 19 Mar 2012 10:51:18 -0700 (PDT)

I have to implement a program which finds useless parts of code and replace
its with some better code. I'll give you an example:
;;(define (positive-odd? n)
;;  (if (and (odd? n) (positive? n)) #t #f))

should be replaced with:

;;(define (positive-odd? n)
;;  (and (odd? n) (positive? n)))

I also have a list with rules. I'll give you an example of rule which will
help us for the the example for bellow:

;;(define redundant-if
;;  '((WHEN (if ?cond #t #f))
;;    (THEN ?cond)))

So, I have to iterate on this list of rules and find matching between rules
and my function with useless code. To do that i have only an idea, but i
don't think it's a good one: I take very rule from the list of rules, then I
iterate on the body of my function and look up for similarities and when I
find one, I replace the code. But I think it's quite difficult to do this.
Please give me any idea of this problem's implementation.
Thank you! 
-- 
View this message in context: 
http://old.nabble.com/Useless-parts-of-code-tp33533547p33533547.html
Sent from the Gnu - MIT Scheme - Users mailing list archive at Nabble.com.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]