Guest User

Untitled

a guest
Dec 10th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 0.54 KB | None | 0 0
  1. #lang racket
  2.  
  3. (define (interseccion lista1 lista2)
  4.   (if (null? lista1) '()
  5.       (let ((include (Esta? (car lista1)lista2)))
  6.         (if (null? (cdr lista1))
  7.             (if include lista1 '())
  8.             (if include
  9.                 (cons (car lista1) (interseccion (cdr lista1)lista2))
  10.                 (interseccion (cdr lista1)lista2))))))
  11.  
  12. (define (Esta? L x)
  13.   (if (null? L)
  14.       false
  15.       (or (= (car L) x) (Esta? (cdr L) x))))
  16.  
  17.  
  18.  
  19.  
  20. (define lista1 (list 1 2 3 4 5))
  21. (define lista2 (list 2 3 5 6 7))
  22. (interseccion lista1 lista2)
Add Comment
Please, Sign In to add comment