在树中创建列表

时间:2018-05-05 15:53:16

标签: scheme racket

它无法正常工作

(define (tree-insert v t)
  (cond((null? t)(make-tree v '() '()))
   ((eq? v (value t)) t)
   ((< v (value t)) (make-tree (value t)
                               (tree-insert v (left t))
                               (right t)))
   ((> v (value t)) (make-tree (value t)
                               (tree-insert v (right t))
                               (left t)))))
(define (insert-list l t)
  (if (null? l)
     t
     (insert-list (cdr l)
               (tree-insert(car l)t))))
(insert-list '(5 2 1 3 11 8 6 9 15 17) '())
; ==> (5 (2 (1 (17 () ()) (8 () ())) (3 (9 () ()) ())) (11 (15 () ()) (6 () ()))) 

1 个答案:

答案 0 :(得分:3)

你在&gt;中左右交换案件。试试这个:

using UnityEngine;
using System.Collections;

public class slicer : MonoBehaviour {

public int damage = 5;
private foeHP foe;
private goblin gobby;
public float timer;



void Update()
{
    Destroy ();
    timer -= Time.deltaTime;

}

public void OnTriggerEnter2D (Collider2D other)
{

    if (other.gameObject.tag == "Enemy") {

        other.gameObject.GetComponent<foeHP> ().takeDamage (damage);
        var foe = other.GetComponent<foeHP> ();
        other.gameObject.GetComponent<goblin> ().takeDamage (damage);
        var gobby = other.GetComponent<goblin> ();

    }



    if (foe == null) {
        return;
    }
    if (gobby == null) {
        return;
    }
}

public void Destroy(){
    if (timer <=0)
        Destroy(gameObject);
}
}