Hi , I am new to LISP and on my exam I had to write a function that I would pass a list as an argument and it would return a list without duplicates.
please help me
please help me
Discuss and learn Lisp programming of all dialects
This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.
10 posts · 1586 views
misha1988 wrote:we didn't learn hashtable.You've gotta learn using the documentation, 'i haven't learned it yet' is kindah a defeatist position, go learn it then
misha1988 wrote:please help me and write a simple function.First write a recursive function that can print each element of the list. (output is useful for testing)
blocks so we can comment.nuntius wrote:misha1988 wrote:please help me and write a simple function.First write a recursive function that can print each element of the list. (output is useful for testing)
Then add an optional parameter called output; have it initialize to an empty list, and push each element onto it.
Then augment your function to only push when the element is new.
Then remove, comment out, or (when nil ...) the debug output.
If you get stuck, ask detailed questions or post what you have inblocks so we can comment.
Jasper wrote:(send-to-lector #'remove-duplicates)Or, if you want to be a smart-arse, (send-to-lector (constantly nil))...the specification only asked for the returned list have no duplicates, not that it have the same elements as the input otherwise, so there's no point wasting time looking at the argument: just return NIL -- that's a list with no duplicates!
Anyway, send us your attempts..
Jasper wrote:(send-to-lector #'remove-duplicates)
Anyway, send us your attempts..