Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (define prime-facts-degs
- (lambda(x)
- (group 0(reverse(factorize-degs x 2 null)))
- )
- )
- (define factorize-degs
- (lambda (x y lista)
- (if (not(= x y))
- (if (> x 1)
- (if (=(remainder x y)0)
- (factorize-degs (quotient x y) y (cons y lista))
- (factorize-degs x (+ y 1) lista)
- )
- lista
- )
- (cons y lista)
- )
- )
- )
- (define delete
- (lambda (x lista)
- (cond
- ((= x (car lista)) (cdr lista))
- (else (cons (car lista) (delete x (cdr lista)))))))
- (define group
- (lambda(x lista);;x è zero inizialmente
- (if (=(length lista)1)
- '((list-ref lista 0) (x+1))
- (if (=(list-ref lista 0)(list-ref lista 1))
- (group (+ x 1) (cdr lista))
- (cons (group 0 (cdr lista )) '((list-ref lista 0) (x+1)) )
- )
- )))
- (prime-facts-degs 12)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement