Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defun my-index (findMe mylist)
- (let ((counter 0) (found 1))
- (dolist (item mylist)
- (cond
- ((eq item findMe) ;this works because 'eq' checks place in memory,
- ;and as long as 'findMe' was from the original list, this will work.
- (setq found nil)
- (found (incf counter))))
- counter))
- (let ((myList '(1 2 3 4 5 6)))
- (setf (nth 4 myList) 101); <----
- myList)
- (1 2 3 4 101 6)
- (let ((myList '(1 2 3 4 5 6)))
- (setf (nth 4 myList) 101)
- (list myList (position 101 myList)))
- ((1 2 3 4 101 6) 4)
- > (setq numbers (list 1 2 3 4))
- (1 2 3 4)
- > (position 3 numbers)
- 2
- (define list-position
- (lambda (o l)
- (let loop ((i 0) (l l))
- (if (null? l) #f
- (if (eqv? (car l) o) i
- (loop (+ i 1) (cdr l)))))))
- ----------------------------------------------------
- > (define numbers (list 1 2 3 4))
- > (list-position 3 numbers)
- 2
- >
- (defun my-attr (list)
- (nth 4 list))
- (defun (setf my-attr) (new list)
- (setf (nth 4 list) new))
Add Comment
Please, Sign In to add comment