Petite Chez Scheme Version 9.5 Copyright 1984-2017 Cisco Systems, Inc. > (+ 4 (* 2 3 5)) 34 > x Exception: variable x is not bound > (define x 6) > x 6 > (+ (/ 11 x) (/ 5 7)) 107/42 > (define y "This is a string") > (define z 'x) > (number? x) #t > (symbol? x) #f > (number? z) #f > (symbol? z) #t > (string? y) #t >(zero? x) #f > (positive? x) #t > (> x 0) #t > (define a (list 2 3 4)) > a (2 3 4) > (define b '(2 3 4)) > (equal? a b) #t > (eq? a b) #f > (define c a) > + #<procedure +> > (define / *) > (/ 4 7) 28 > (= 2 5) #f > (= (2) (5)) Exception: attempt to apply non-procedure 5 > (define r (+ 3 5)) > r 8 > (define s '(+ 3 5)) > s (+ 3 5) > (eval s) 8 > (if 5 6 7) 6 > a (2 3 4) >(define c (cons 1 a)) > c (1 2 3 4) > a (2 3 4) > (car a) 2 > (cdr a) (3 4) > (car (cdr a)) 3 > (cadr a) 3 > (caddr a) 4 > (cddr a) (4) > (cdddr a) () > (cddddr a) Exception in cddddr: incorrect list structure (2 3 4) > (cdddddr a) Exception: variable cdddddr is not bound > '() () > () Exception: invalid syntax () > (define times (lambda (n) ((* n 3)))) > times #<procedure> > (times 4) Exception: attempt to apply non-procedure 12 > (define times3 (lambda (n) (* n 3))) > (times3 4) 12 > (define times6 (lambda (n) (+ (times3 n) (times3 n)))) > (times6 5) 30 > (trace times3 times6) (times3 times6) > (times6 5) |(times6 5) | (times3 5) | 15 | (times3 5) | 15 |30 30 > (untrace) (times3 times6) > (define fact (lambda (n) (if (zero? n) 1 (* n (fact (- n 1)))))) > (trace fact) (fact) > (fact 6) |(fact 6) | (fact 5) | |(fact 4) | | (fact 3) | | |(fact 2) | | | (fact 1) | | | |(fact 0) | | | |1 | | | 1 | | |2 | | 6 | |24 | 120 |720 720 (define nth-element (lambda (ls n) (if (null? ls) #f (if (zero? n) (car ls) (nth-element (cdr ls) (- n 1)))))) > (nth-element '(a b c d e) 4) e > (trace nth-element) (nth-element) > (nth-element '(a b c d e) 4) |(nth-element (a b c d e) 4) |(nth-element (b c d e) 3) |(nth-element (c d e) 2) |(nth-element (d e) 1) |(nth-element (e) 0) |e e >