MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Better way to write this

  • To: mathgroup at smc.vnet.net
  • Subject: [mg85058] Better way to write this
  • From: Louis Theran <theran at gmail.com>
  • Date: Sat, 26 Jan 2008 05:00:47 -0500 (EST)

I have the following function that takes as its input a number of
lists and returns the elements in each of them that appear exactly
once:

SpecialElements[lists:_List..]:=
Module[{l,n,Sower,Reaper},
l = {lists}; n = Length[l];
Sower[l_,{idx_}]:= Sow[idx,{#}] & /@ l;
Reaper[val_,{place_}] := Sow[val,place];
Reaper[val_,x_]:= Null;
Reap[Reap[MapIndexed[Sower, l],_,Reaper],Range[n]][[2]]]

This works pretty well, but since I am using it on rather large
inputs, I was wondering if there is a faster way to implement it than
Reap/Sow, which is sort of counting in unary.

^L


  • Prev by Date: Re: List complement operator
  • Next by Date: Re: How remove CellChangeTimes values?
  • Previous by thread: Legend Style
  • Next by thread: Re: Better way to write this