scheme - Accessing a variable field within a node -


hi new racket using binary tree structure.

using following structure

(define-struct human(age hight)) 

i have created following object/variable/human

(define james(make-human 10 50)) 

if have node in binary tree structure

(define-struct node (left human right)) 

how can compare different object's hight (say michael) james given james within node, example:

 (define (insert-human-into-tree human node)   (cond     [(empty? node)(make-node empty human empty)]     [(<= human-hight( **node-human-hight**)) 

i need know how access hight field of human object within node ( node-human-hight).

use accessor procedures in struct, example:

(define-struct human(age hight)) (define james (make-human 10 50)) (define-struct node (left human right))  (define anode (make-node null james null)) ; access human in node, , height of human (human-hight (node-human anode)) => 50 

... , it's spelled "height", not "hight". so, answer question, comparison this:

(<= (human-hight (node-human node)) (human-hight human)) 

Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -