hi,
I have three programs to writ in three different languages for my final exam.
Was wondering if anyone could help with lisp code that removes duplicate
entries in a list. e.g. [d a c a d d ] returns [a c d].
>>>>> "vmackeen" == vmackeen <········@aol.com> writes:
vmackeen> hi, I have three programs to writ in three different
vmackeen> languages for my final exam. Was wondering if anyone could
vmackeen> help with lisp code that removes duplicate entries in a
vmackeen> list. e.g. [d a c a d d ] returns [a c d].
this is easy in Common Lisp!
(remove-duplicate-entries-from-list '(d a c a d d))
dave
p.s. look up the rest
········@aol.com (Vmackeen) writes:
> hi,
> I have three programs to writ in three different languages for my final exam.
> Was wondering if anyone could help with lisp code that removes duplicate
> entries in a list. e.g. [d a c a d d ] returns [a c d].
In Lisp you write
(defvar l '(d a c a d d))
(defun I-should-read-the-manual (l)
(remove-duplicates l))
(I-should-read-the-manual l)
Enjoy.
--
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488
719 Broadway 12th Floor fax +1 - 212 - 995 4122
New York, NY 10003, USA http://bioinformatics.cat.nyu.edu
"Hello New York! We'll do what we can!"
Bill Murray in `Ghostbusters'.
Hello!
In article <···············@octagon.mrl.nyu.edu>,
Marco Antoniotti <·······@cs.nyu.edu> wrote:
>[...]
>(defvar l '(d a c a d d))
>(defun I-should-read-the-manual (l)
> (remove-duplicates l))
>(I-should-read-the-manual l)
Then do
(let ((symbol (find-symbol "L")))
(setf (symbol-name symbol)
"*I-SHOULD-CONSIDER-WHETHER-I-SHOULD-USE-GLOBAL-VARIABLES-ESPECIALLY-WITHOUT-STARS-AROUND-THE-NAME*"))
Kind regards,
Hannah.
> Hello!
>
> In article <···············@octagon.mrl.nyu.edu>,
> Marco Antoniotti <·······@cs.nyu.edu> wrote:
>
> >[...]
>
> >(defvar l '(d a c a d d))
>
> >(defun I-should-read-the-manual (l)
> > (remove-duplicates l))
>
> >(I-should-read-the-manual l)
>
> Then do
>
> (let ((symbol (find-symbol "L")))
> (setf (symbol-name symbol)
> "*I-SHOULD-CONSIDER-WHETHER-I-SHOULD-USE-GLOBAL-VARIABLES-ESPECIALLY-WITHOUT-STARS-AROUND-THE-NAME*"))
Please excuse me if I misunderstood, but shouldn't it be;
(let ((symbol (find-symbol "L")))
(setf (symbol-value symbol)
"*I-SHOULD-CONSIDER-WHETHER-I-SHOULD-USE-GLOBAL-VARIABLES-ESPECIALLY-WITHOUT-STARS-AROUND-THE-NAME*"))
this one replaces the value of 'l' with the long, interesting string, the other gave an error for me..
Gregm
Hello!
In article <··············@europa.mindspring.com>,
Greg Menke <··········@mindspring.com> wrote:
>[...]
>> (let ((symbol (find-symbol "L")))
>> (setf (symbol-name symbol)
>>
>"*I-SHOULD-CONSIDER-WHETHER-I-SHOULD-USE-GLOBAL-VARIABLES-ESPECIALLY-WITHOUT-STARS-AROUND-THE-NAME*"))
>Please excuse me if I misunderstood, but shouldn't it be;
> (let ((symbol (find-symbol "L")))
> (setf (symbol-value symbol)
>"*I-SHOULD-CONSIDER-WHETHER-I-SHOULD-USE-GLOBAL-VARIABLES-ESPECIALLY-WITHOUT-STARS-AROUND-THE-NAME*"))
>this one replaces the value of 'l' with the long, interesting string,
>the other gave an error for me..
It was rather meant for human consumption. Though a function
(setf symbol-name) for renaming a symbol could be interesting *g*.
Kind regards,
Hannah.
······@schlund.de (Hannah Schroeter) writes:
> Hello!
>
> In article <···············@octagon.mrl.nyu.edu>,
> Marco Antoniotti <·······@cs.nyu.edu> wrote:
>
> >[...]
>
> >(defvar l '(d a c a d d))
>
> >(defun I-should-read-the-manual (l)
> > (remove-duplicates l))
>
> >(I-should-read-the-manual l)
>
> Then do
>
> (let ((symbol (find-symbol "L")))
> (setf (symbol-name symbol)
> "*I-SHOULD-CONSIDER-WHETHER-I-SHOULD-USE-GLOBAL-VARIABLES-ESPECIALLY-WITHOUT-STARS-AROUND-THE-NAME*"))
Good point.
What about constants defined with DEFCONSTANT?
Cheers
--
Marco Antoniotti ========================================================
NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488
719 Broadway 12th Floor fax +1 - 212 - 995 4122
New York, NY 10003, USA http://bioinformatics.cat.nyu.edu
"Hello New York! We'll do what we can!"
Bill Murray in `Ghostbusters'.
Hello!
In article <···············@octagon.mrl.nyu.edu>,
Marco Antoniotti <·······@cs.nyu.edu> wrote:
>[...]
>"*I-SHOULD-CONSIDER-WHETHER-I-SHOULD-USE-GLOBAL-VARIABLES-ESPECIALLY-WITHOUT-STARS-AROUND-THE-NAME*"))
>Good point.
>What about constants defined with DEFCONSTANT?
I'd mark them too, however, my preference in this is not soo strong,
as the system hinders you in rebinding them anyway, so you will not
get strange errors in constructs like
(let ((foo ...))
...)
if foo is constant, compared to the occasional special proclamation
of foo if you don't use the "*" convention or similar for global
variables.
The precedent set by the standard, however, contradicts my preference,
as there are predefined constants without any special marks.
Kind regards,
Hannah.