Final recursion.
Posted: Sat Jan 05, 2013 1:00 pm
Here is the baby end of the parser.
It treats one 'begin ' implicit.
He must be, roughly, the first call to whom l 'on pass:
- the name of function
- the list of the expressions of the body of function
ignorable (c 'est-Ã -dire an interlocking of 'if ' or.
Lorsqu 'il is wrong, he points out qu 'on is " under " a function not - ignorable (as 'pus ' for instance).
It determines this qu 'on must go back if they meet function in the course of the parsing.
more precisely, the function which really turns stocks and determines if c 'est recursive - terminal or not resembles this:
(and not trec-yew tree), as well as all other parsers for special forms remains to make, as well as 'trec-cond ' in the 14th line: 'trec-apply ' 'trec-hut ' 'trec-define ' 'trec-do ' 'trec-fluid-let ' 'trec-lambda ' 'trec-let ' 'trec-let* ' 'trec-named-lambda ' etc .
Can you help Me Please to finish this program ?!
I must write a program which takes in argument a list corresponding to a function and returns ' * #t ' s 'il s 'agit d 'une final recursion and ' * #f ' otherwise.
Thanks
It treats one 'begin ' implicit.
He must be, roughly, the first call to whom l 'on pass:
- the name of function
- the list of the expressions of the body of function
Code: Select all
(define (trec-body fun body term)
(if (null? body) #t
(if (null? (cdr body))
;; Last expression of body
(trec-expr fun (car body) (and term #t))
(and
;; Some non-last expression
(trec-expr fun (car body) (and term #f))
;; Continue with the other expressions
(trec-body fun (cdr body) term)))))
Lorsqu 'il is wrong, he points out qu 'on is " under " a function not - ignorable (as 'pus ' for instance).
It determines this qu 'on must go back if they meet function in the course of the parsing.
more precisely, the function which really turns stocks and determines if c 'est recursive - terminal or not resembles this:
Code: Select all
(define (trec-expr fun expr term)
(cond
((not (pair? expr)) #t)
((eq? fun (car expr))
;; Found a call to 'fun'
(if (not term) #f ;; No need to continue
;; Checks 'fun's args, but with 'term' set to false
(trec-body fun (cdr expr) #f)))
;; This is not a call to fun. Go inside.
(else
(case (car expr)
((if) (trec-if fun (cdr expr) term))
((cond) (trec-cond fun (cdr expr) term))
;; Idem for every special form like:
;; apply case cond define do fluid-let lambda let let* letrec named-lambda etc.
((let) (trec-let fun (cdr expr) term))
...
(else
;; This is a normal function (like '+' 'cons' etc.)
;; Checks its args, with 'term' set to false
(trec-body fun (cdr expr) #f))))))
Can you help Me Please to finish this program ?!
I must write a program which takes in argument a list corresponding to a function and returns ' * #t ' s 'il s 'agit d 'une final recursion and ' * #f ' otherwise.
Thanks