[Date Index]
[Thread Index]
[Author Index]
Re: Re: Intersection of lists of lists based on the first term
*To*: mathgroup at smc.vnet.net
*Subject*: [mg87533] Re: [mg87492] Re: Intersection of lists of lists based on the first term
*From*: "Szabolcs HorvÃt" <szhorvat at gmail.com>
*Date*: Sat, 12 Apr 2008 07:00:13 -0400 (EDT)
*References*: <ftmu64$50i$1@smc.vnet.net> <200804110956.FAA08360@smc.vnet.net>
On Fri, Apr 11, 2008 at 9:46 PM, Stern <nycstern at gmail.com> wrote:
> Thank you, but I think I am not understanding the second bit -- what is
> (isCommon[#] = True) & /@ timeStampsInCommon supposed to achieve other than
> a list of True equal to the length of timeStampsInCommon in every case?
>
Perhaps I should have written it as
Scan[(isCommon[#] = True) &, timeStampsInCommon]
to emphasize that the function (isCommon[#] = True) & is only invoked
for its side effects, i.e. defining new DownValues for the symbol
isCommon.
This will set the value of isCommon[ ... ] to True for each of the
elements in timeStampsInCommon. Thus, isCommon[elem] is equivalent to
MemberQ[timeStampsInCommon, elem], but it is much faster if
timeStampsInCommon has many elements (because Mathematica will use a
hash table for looking up elements instead of simply iterating through
timeStampsInCommon). Note that isCommon[] needs to be Clear[]ed after
each use (a better solution is encapsulating the whole thing into a
Module where isCommon is a local symbol).
Prev by Date:
**Re: Tilted decimals on the x-axis to avoid overlapping**
Next by Date:
**Re: Appearance of DendrogramPlot**
Previous by thread:
**Re: Intersection of lists of lists based on the first term**
Next by thread:
**Grade calculation tool for students....**
| |