2022-01-29 08:26:45 -08:00
|
|
|
(define is-number
|
|
|
|
(lambda (x)
|
2022-03-08 08:48:01 -08:00
|
|
|
(if (eq (type-of x) type-i28)
|
2022-01-29 08:26:45 -08:00
|
|
|
't
|
2022-03-08 08:48:01 -08:00
|
|
|
(if (eq (type-of x) type-u28)
|
2022-01-29 08:26:45 -08:00
|
|
|
't
|
2022-03-08 08:48:01 -08:00
|
|
|
(if (eq (type-of x) type-float)
|
2022-01-29 08:26:45 -08:00
|
|
|
't
|
2022-03-08 08:48:01 -08:00
|
|
|
(if (eq (type-of x) type-i32)
|
2022-01-29 08:26:45 -08:00
|
|
|
't
|
2022-03-08 08:48:01 -08:00
|
|
|
(if (eq (type-of x) type-u32)
|
2022-01-29 08:26:45 -08:00
|
|
|
't
|
|
|
|
'nil)))))))
|
|
|
|
|
|
|
|
|
|
|
|
(define sumtree
|
|
|
|
(lambda (x)
|
|
|
|
(if (is-number x)
|
|
|
|
x
|
2022-03-08 08:48:01 -08:00
|
|
|
(if (eq x 'nil)
|
2022-01-29 08:26:45 -08:00
|
|
|
0
|
|
|
|
(let ((a (sumtree (car x)))
|
|
|
|
(b (sumtree (cdr x))))
|
|
|
|
(+ a b)
|
|
|
|
)))))
|
|
|
|
|
|
|
|
|
|
|
|
(= (sumtree (list (list 1u32 1i32 1u28 1 1 1 1 1 1 1) (list 1 2.0) (list 3 4.0))) 20.0)
|