program that crashes or doesn't return if run on a any tail-recursive implementation of a language, but returns 0 if run on a any non tail-recursive

program that crashes or doesn't return 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 that any supplied implementation does not support tail recursion (this is a weaker condition because we do not require that the program correctly infer support of tail recursion, but only lack of support).


(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..