fork download
  1. (print 1)
  2. (defun S (x)
  3. (if (EQUAL (CDR x) '())
  4. (CAR x)
  5. (S (cdr x))
  6. )
  7. )
  8.  
  9. (print (S '(1 2 3 4 6 7 8)))
  10.  
  11. (print 2)
  12. (defun R (a n x)
  13. (cond
  14. ( (= n 1) (cons a x) )
  15. ( (= n 0) (cons a (R a (- n 1) (cdr x) )) )
  16. ( T (cons (car x) (R a (- n 1) (cdr x))))
  17. )
  18. )
  19.  
  20. (print (R 8 2 '(7 2 3 4)))
  21.  
  22. (print 3)
  23.  
  24. (defun S ( n x)
  25. (cond
  26. ( (EQUAL x NIL) Nil )
  27. ( (= (CAR x) n) T )
  28. ( T (S n (cdr x)))
  29. )
  30. )
  31.  
  32. (print (S 7 '()))
  33. (print (S 70 '(1 2 3 4 6 7 8)))
  34. (print (S 7 '(1 2 3 4 6 7 8)))
  35.  
  36.  
  37.  
  38. (print 4)
  39. (defun Del (x s)
  40. (COND
  41. ((EQUAL s NIL) NIL)
  42. ((EQUAL x (car s)) (Del x (cdr s)))
  43. (T (CONS (car s) (Del x (cdr s))))
  44. )
  45.  
  46. )
  47.  
  48. (print (Del 'a '(a n a x)))
  49.  
  50. (print 5)
  51. (defun Neg (x)
  52. (cond
  53. ((EQUAL x NIL) 0)
  54. ((+ (if (< (car x) 0) 1 0) (Neg (cdr x))))
  55. (T (Neg (cdr x)))
  56. )
  57. )
  58.  
  59. (print (Neg '(-1 4 9 -8 3)))
  60.  
  61. (print 6)
  62. ( defun Max(x)
  63. (cond
  64. ((EQUAL x NIL) NIL)
  65. ((EQUAL (CDR x) NIL) (car x))
  66. ((> (car x) (cadr x)) (Max (cons (car x) (cddr x))))
  67. ( T (Max (cdr x) ))
  68. )
  69. )
  70.  
  71. (print (Max '(-1 4 9 -8 3)))
  72.  
  73.  
  74. (print 7)
  75. ( defun Vloj(n)
  76. (cond
  77. ( (= n 0) 'A)
  78. ( (= n 1) (cons 'A '()))
  79. ( T (cons (Vloj (- n 1)) '()))
  80. )
  81. )
  82.  
  83. (print (Vloj 0 ))
  84. (print (Vloj 1 ))
  85. (print (Vloj 4 ))
  86.  
  87. (print 8)
  88. (defun Pow (n)
  89. (cond
  90. ((= n 0) '())
  91. ((= n 1) '(A))
  92. ( T (cons 'A (Pow (- n 1) ) ) )
  93. )
  94. )
  95. (print (Pow 0 ))
  96. (print (Pow 1 ))
  97. (print (Pow 8 ))
  98.  
  99.  
  100. (print 10)
  101. (defun P ( x)
  102. (cond
  103. ((EQUAL x NIL) NIL)
  104. ((EQUAL (cddr x) NIL) (list (cadr x) (car x) ) )
  105. ( T (cons (cadr x) (cons (car x) (P(cddr x)) ) ) )
  106. )
  107. )
  108.  
  109. (print (P '(1 2 3 4 5 6 ) ))
  110.  
  111. (print 12)
  112. (defun Obed (x y)
  113. (cond
  114. ( (null x) y)
  115. ( (null y) x)
  116. (T (cons (car x) (cons (car y) (Obed (cdr x) (cdr y)))) )
  117. )
  118. )
  119.  
  120. (print (Obed '() '(A B C)))
  121. (print (Obed '(1 2 3) '()))
  122. (print (Obed '(1 2 3) '(A B C)))
Success #stdin #stdout #stderr 0.02s 10400KB
stdin
Standard input is empty
stdout
1 
8 
2 
(7 8 2 3 4) 
3 
NIL 
NIL 
T 
4 
(N X) 
5 
2 
6 
9 
7 
A 
(A) 
((((A)))) 
8 
NIL 
(A) 
(A A A A A A A A) 
10 
(2 1 4 3 6 5) 
12 
(A B C) 
(1 2 3) 
(1 A 2 B 3 C) 
stderr
WARNING: DEFUN/DEFMACRO(MAX): #<PACKAGE COMMON-LISP> is locked
         Ignore the lock and proceed
WARNING: DEFUN/DEFMACRO: redefining function MAX in /home/ImmurM/prog.lisp,
         was defined in C