Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define (cuenta-atomos lista)
- (cond
- ((null? lista) 0)
- ((list? (car lista)) (+ (cuenta-atomos (car lista)) (cuenta-atomos (cdr lista))))
- (else (+ 1 (cuenta-atomos (cdr lista))))))
- (define (swap-up L)
- (if (null? (cdr L))
- L
- (if(< (car L) (cadr L))
- (cons (car L) (swap-up (cdr L)))
- (cons (cadr L) (swap-up (cons (car L) (cddr L)))))))
- (define (bubble-aux N L)
- (cond ((= N 1) L)
- (else (bubble-aux (- N 1) (swap-up L)))))
- (define (bubble L)
- (bubble-aux (length L) L))
- (define (countM R)
- (cond
- ( (null? R) 0)
- ((eq? (car (car R)) "m" ) (+ (countM (cdr R)) 1))
- (else (countM (cdr R) ))))
- (define (countF R)
- (cond
- ( (null? R) 0)
- ((eq? (car (car R)) "f" ) (+ (countF (cdr R)) 1))
- (else (countF (cdr R) ))))
- (define (sumM R)
- (cond
- ( (null? R) 0)
- ((eq? (car (car R)) "m" ) (+ (sumM (cdr R)) (cadar R) ))
- (else (sumM (cdr R) ))))
- (define (sumF R)
- (cond
- ( (null? R) 0)
- ((eq? (car (car R)) "f" ) (+ (sumF (cdr R)) (cadar R) ))
- (else (sumF (cdr R) ))))
- (define (promM R)
- (/ (sumM R) (countM R)))
- (define (promF R)
- (/ (sumF R) (countF R)))
- (define (Promedios R)
- (list (list "Masculino" (promM R)) (list "Femenino" (promF R))))
- (define (build tree left right)
- (list tree left right)
- )
- (define (value tree) (car tree))
- (define (left tree) (cadr tree))
- (define (right tree) (caddr tree))
- (define (insert x tree)
- (cond
- ((null? tree) (build x '() '()) )
- ((< x (value tree))
- (build (value tree) (insert x (left tree)) (right tree) ) )
- ((> x (value tree))
- (build (value tree) (left tree) (insert x (right tree))))))
- (insert 0 '(1 () (5 (3 () ()) (6 () ()))))
- (Promedios '( ("m" 13) ("f" 14) ("m" 12) ))
- (bubble (list 10 9 1 3 7 6))
- (cuenta-atomos '(a (b c (d))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement