Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
(write (member 'zara '(ayan abdul zara riyan nuha)) )
(terpri)
(write (member-if #'evenp '(3 5 2 5/6 'a)))
(terpri)
(write (member-if-not #'numberp '(3 5 2 5/6 'a 'b 'c)))
; ezek a #' kezdésűek ilyen &key-ek, valamilyen tulajdonságát határozzák meg az értéknek
;Course: CSCI 450
;By: Eric Frey
;Due: 9/11/2018
;Program: Lab 1
(defun my-rotate (x)(append(cdr x) (list (car x))))
; (write(my-rotate '(a b c)))
(defun my-rotate-n (a tempList)
(if (< a 1) (return-from my-rotate-n tempList))(
my-rotate-n (- a 1) (append (cdr tempList)
(list (car tempList)))
)
)
; (write(my-rotate-n 3 '(a b c d)))
(defun first-sat (listA listB foo)
(if (null listB)()(
if (null listA)()(
if (funcall foo(car listA) (car listB))(
;if function returns true
append (list(car listA)) (list(car listB)))(
;if function returns false
first-sat(cdr listA) (cdr listB) foo)
)
))
)
(write(first-sat '() '() (function (lambda (x y) (> x y)))))
(defun my-remove (a myList)
(if (null myList) (return-from my-remove nil) (
;if list is not empty
if (equal a (car myList))(
;if atom equals mylist
my-remove a (cdr myList)
)(
; if atom does not equal list
if (atom (car myList)) (
;if atom is a list
append (list (car myList)) (my-remove a (cdr myList))
)(
;if atom is not a list
append (list(my-remove a (car myList))) (my-remove a (cdr myList))
)
)
))
)
; (write (my-remove 'b '((a b) b (c b d e a) (b) (a) c)))
(defun remove-last (myList)
;helper function for palindromep to slice off end atom
(if ( > (length myList) 1)(
append (list (car myList)) (remove-last(cdr myList))
))
)
(defun palindromep (myList)
(if ( < (length myList) 2) (
return-from palindromep t
)(
if (equal(list(car myList)) (last myList))()(
;first and last atoms are not equal, return false
return-from palindromep nil
))
)
(palindromep (remove-last (cdr myList)))
)
(setq a (make-array 5 :fill-pointer 0))
; a fill-pointer az azt mutatja, hogy mennyi tagja engedett a vektornak\
;csak egydimenziós make-array-nél (?) működik
(write a)
(vector-push 'a a);ez a végére teszi az adott dolgot (az a vektornak)
(vector-push 'b a)
(vector-push 'c a)
(terpri)
(write a)
(terpri)
(vector-push 'd a)
(vector-push 'e a)
(vector-push 'f a); itt ez nem megy be a végére, mivel a vektor csak 5-ös
(write a)
(terpri)
(vector-pop a); ez letöröl egyet a végéről
(vector-pop a)
(vector-pop a)
(write a)
(write (setf (get 'konyv'cim) '(iskola a határon)))
(terpri)
(write (setf (get 'konyv'szerzo)'(ottlik geza)))
(terpri)
(write (setf (get 'konyv 'kiado) '(mittom)))
(terpri)
(write (get 'konyv 'cim))
;szóval a get az meghatároz egy dolgot, annak a tulajdonságát, s a setf meg
;hozzárendel egy értéket
(write (car '(a b c d e f)))
(terpri)
(write (cdr '(a b c d e f))); minden, kivéve az első
(terpri)
(write (cons 'a '(b c)))
(terpri)
(write (list 'a '(b c) '(e f))); ez itt egy lista sok listáról (?)
;lehet, hogy csak meghagyja a zárójeleket
(terpri)
(write (append '(b c) '(e f) '(p q) '() '(g))); ez meg simán egy lista
(terpri)
(write (last '(a b c d (e f)))); !
(terpri)
(write (reverse '(a b c d (e f))))
; a lista is szekvencia