Menu

[Solved]Lang Racket Define Buildst X Null X Null Null X Cons Car X Cons Root X Buildst Cdr X Null Q37153721

#lang racket
(define (buildst x)
(if(null? x)
null
(if(not(null? x))
(cons(car x)(cons(root x)(buildst (cdr x))))
null
)
)
)

(define (root x)
(if(null? x)
null
(cons(car x)(cons ‘() (cons ‘() ‘())))
)
)

I’m getting this output

Welcome to DrRacket, version 7.2 [3m].
Language: racket, with debugging; memory limit: 128 MB.
> (buildst ‘(3 1 7 5))
‘(3 (3 () ()) 1 (1 () ()) 7 (7 () ()) 5 (5 () ()))
>

Instead ->

(buildbst ’(3 1 7 5) )

should produce this.

( 3 (1 () ()) (7 (5 () ()) () )

Expert Answer


Answer to #lang racket (define (buildst x) (if(null? x) null (if(not(null? x)) (cons(car x)(cons(root x)(buildst (cdr x)))) null )… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *