Latkoski

Dekart

May 5th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.45 KB | None | 0 0
  1. (defun dekartSpom (lista1 lista2 pomLista1)
  2.     (cond
  3.        ((and(null lista1)(null lista2))nil)
  4.        ((null lista1)(dekartSpom pomLista1 (cdr lista2) lista1))
  5.        ((not (null lista1))(cons(pom (car lista2)(car lista1))(dekartSpom (cdr lista1) lista2 pomLista1)))
  6.     )  
  7. )
  8. (defun dekartS (lista1 lista2)
  9.     (dekartSpom lista1 lista2 lista1)    
  10. )
  11. (defun pom (x y)
  12.     (list x y)    
  13. )
  14. (print(dekartS '(a b c) '(1 2)))
  15. ;((1 a)(1 b)(1 c)(2 a)(2 b)(2 c))
Advertisement
Add Comment
Please, Sign In to add comment