help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: member returns list


From: Emanuel Berg
Subject: Re: member returns list
Date: Wed, 02 Sep 2015 23:47:12 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux)

Michael Heerdegen <michael_heerdegen@web.de> writes:

> The `car' of the result of `member' is the actual
> element you were searching. Since `member' tests
> with `equal', that can be a different object.

OK, so the `car' is the object, however ELT is
searched for with `equal', which compares objects'
"structure and contents". An object obviously have the
same structure and contents when compared to itself,
but nonetheless two objects can have the same
structure and contents in what case the `car' and ELT
are identical but still two objects. Ha! I'm smart...

So then, is there a "member-whatever" that doesn't use
`equal' but one of the many other functions available
to compare items? Is there a "member" to which you can
provide this function yourself?

> But `member' returns a whole sublist. This gives you
> also a simple mean to modify a list, like in this
> example:
>
> (let ((list '(1 2 3 4 5))) (let ((list1 (member 3
> list))) (when list1 (setcar list1 -3)) list))
>
>    ==> (1 2 -3 4 5)

Yes, already mentioned but true nonetheless. It would
be interesting to see what programs you guys write
because I never did stuff like that. Perhaps in HPC
with tons of data, or old-school batch "data
processing", this type of stuff is/was legio?

-- 
underground experts united
http://user.it.uu.se/~embe8573




reply via email to

[Prev in Thread] Current Thread [Next in Thread]