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) (/ 2 3)) 5/2 > (define y "This is a string") > (define z 'x) > z x > y "This is a string" > (number? x) #t > (symbol? x) #f > (number? z) #f > (symbol? z) #t > (symbol? y) #f > (string? y) #t > (zero? x) #f > (positive? x) #t > (even? x) #t > (define a (list 2 3 4)) > (define c a) > (define b '(2 3 4)) > a (2 3 4) > b (2 3 4) > c (2 3 4) > (equal? a b) #t > (eq? a b) #f > (eq? a c) #t > (2 3 4) Exception: attempt to apply non-procedure 2 > + #<procedure +> > (define / *) > / #<procedure *> > (/ 4 7) 28 > (Max 4 7 9 2) Exception: variable Max is not bound > (max 4 7 9 2) 9 > (+) 0 > (= 2 5) #f > (define r (+ 3 5)) > r 8 > (define s '(+ 3 5)) > s (+ 3 5) > (eval s) 8 > (if (< 4 x) 5 7) 5 > (if 5 6 7) 6 > a (2 3 4) > (define d (cons 1 a)) > d (1 2 3 4) > a (2 3 4) > (car a) 2 > (cdr a) (3 4) > (car (cdr a)) 3 > (cadr a) 3 > (cddr a) (4) > (cdddr a) () > (cddddr a) Exception in cddddr: incorrect list structure (2 3 4) > (cdddddr a) Exception: variable cdddddr is not bound > (define times3 (lambda (n) (* 3 n))) > (define times6 (lambda (m) (+ (times3 m) (times3 m)))) > (times6 7) 42 > (trace times6 times3) (times6 times3) > (times6 7) |(times6 7) | (times3 7) | 21 | (times3 7) | 21 |42 42 > (define times3 (lambda (n) (* 3 n))) > (define fact (lambda (n) (if (zero? n) 1 (* n (fact (- n 1)))))) > (fact 6) 720 > (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) "error" (if (zero? n) (car ls) (nth-element (cdr ls) (- n 1)))))) > (nth-element '(a b c d e f) 4) e > (trace nth-element) (nth-element) > (nth-element '(a b c d e f) 4) |(nth-element (a b c d e f) 4) |(nth-element (b c d e f) 3) |(nth-element (c d e f) 2) |(nth-element (d e f) 1) |(nth-element (e f) 0) |e e >