program that returns 1 if run on a any tail-recursive implementation of a language, but returns 0 if run on a any non tail-recursive implementation of

program that returns 1 if run on a any tail-recursive implementation of a language, but returns 0 if run on a any non tail-recursive implementation of that same language. The goal is not to find a program and language implementation pair that exhibit the behavior, but to design a program that can correctly infer whether on not any supplied language implementation supports tail recursion by examining its own behavior.


(define (smallest list predicate)
;; Returns the smallest element of list.
(if (null? list)
#f
(if (predicate (car list) (cadr list))
(smallest (cons (car list) (cddr list)) predicate)
(smallest (cdr list) predicate))))

(define (louis-sort list predicate)
(do ((remainder list (cdr remainder))
(answer '() (append answer (cons (smallest remainder predicate) '()))))
((null? remainder) answer)))

(define test-list
(do ((i 0 (+ i 1))
(answer '() (cons i answer)))
((>= i 100) answer)))

We Are Founder..