Thanks a lot nuntius!
works perfectly now!
Search found 5 matches
- Wed Aug 01, 2012 1:42 pm
- Forum: Homework
- Topic: intersection of two lists
- Replies: 2
- Views: 14658
- Wed Aug 01, 2012 8:29 am
- Forum: Homework
- Topic: intersection of two lists
- Replies: 2
- Views: 14658
intersection of two lists
Hi, I'm trying to write a recursive function returning the intersection of two given lists... I can't figure out why I'm getting the error message: void function. I'd be grateful for help! (defun intersect(A B) (if (eq A ()) A (if (member (car A) B) (push (car A) (intersect(cdr A) B)) (intersect(cdr...
- Sun Jun 10, 2012 6:23 am
- Forum: Homework
- Topic: Code for calculating difference of sets not working
- Replies: 4
- Views: 12525
Re: Code for calculating difference of sets not working
Tanks so much, that realy is so much more simple than my version...
Code: Select all
; calculates A\B
(let (C)
(dolist (element A)
(if (not (member element B))
(push element C)
)
)
C
)
)
(diff '(a b a c d) '(c d e d e f))
- Sun Jun 10, 2012 2:04 am
- Forum: Homework
- Topic: Code for calculating difference of sets not working
- Replies: 4
- Views: 12525
Re: Code for calculating difference of sets not working
Thanks a lot Ramarren, you really helped me out there... I see I made quite some mistakes; I think I've got rid of them now although I'm still using the setq command within the while-loop, because I can't quite figure out where I should put the end-bracket of let otherwise (- perhaps after the end-b...
- Sat Jun 09, 2012 8:42 am
- Forum: Homework
- Topic: Code for calculating difference of sets not working
- Replies: 4
- Views: 12525
Code for calculating difference of sets not working
Hi everyone, I'm trying to write a program (in emacslisp) to calculate the difference of two lists; could someone give me a hint as to why my code is returning an error saying "invalid function...", when I try it on an example? I'd be grateful for help, Thanks (defun diff (A B) ; calculate...