Advertisement
Guest User

Untitled

a guest
Jan 11th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Racket 0.90 KB | None | 0 0
  1. (define prime-facts-degs
  2.   (lambda(x)
  3.    
  4.     (group 0(reverse(factorize-degs x 2 null)))
  5.  
  6.     )
  7.   )
  8.  
  9. (define factorize-degs
  10.   (lambda (x y lista)
  11.     (if (not(= x y))
  12.         (if (> x 1)
  13.             (if (=(remainder x y)0)
  14.                 (factorize-degs (quotient x y) y (cons y lista))
  15.                 (factorize-degs x (+ y 1) lista)
  16.                 )
  17.             lista
  18.             )
  19.         (cons y lista)
  20.         )
  21.    
  22.     )
  23.   )
  24. (define delete
  25.   (lambda (x lista)
  26.     (cond
  27.       ((= x (car lista)) (cdr lista))
  28.       (else (cons (car lista) (delete x (cdr lista)))))))
  29.  
  30. (define group
  31.   (lambda(x lista);;x è zero inizialmente
  32. (if (=(length lista)1)
  33.     '((list-ref lista 0) (x+1))
  34.     (if (=(list-ref lista 0)(list-ref lista 1))
  35.         (group (+ x 1) (cdr lista))
  36.         (cons (group 0 (cdr lista )) '((list-ref lista 0) (x+1)) )
  37.         )
  38.     )))
  39. (prime-facts-degs 12)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement