MathGroup Archive 1992

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

Search the Archive

Listable vs. Thread

  • To: mathgroup at
  • Subject: Listable vs. Thread
  • From: gaylord at
  • Date: Thu, 29 Oct 1992 15:06:54 -0600

on Tuesday, i posted the question as to why i got the error message below.

voteTuesday[1,0] := a
voteTuesday[0,1] := b
voteTuesday[x_,y_] := c
Attributes[voteTuesday] = Listable;

dog = {{1,1,0},{1,0,0}};

cat = {{1,0,0},{0,1,0}};

{{c, b, c}, {b, a, c}}

voteTwice[1,0] := a
voteTwice[0,1] := b
voteTwice[x_,y_] := c

Thread::normal: Normal expression expected at position 1 in Thread[c].


dan scott (thanks dan) pointed out that mathematica is pattern-matching the
entire expression voteTwice[cat,dog] to give c and of course, Thread[c]
then produces the message.

i thought i might avoid the problem using the following rule set:

vote[1,0] := a
vote[0,1] := b
vote[x_Integer,y_Integer] := c

but this produces:

{vote[{1, 0, 0}, {1, 1, 0}], vote[{0, 1, 0}, {1, 0, 0}]}

so what i've come up with is the incredibly ugly

{{c, b, c}, {b, a, c}}

so Listable is really different than just automatically Threading, i guess.

"if you're not programming functionally, then you must be programming

  • Prev by Date: Tables of special functions
  • Next by Date: RE: Uses in h.s.APcalculus
  • Previous by thread: Re: Tables of special functions
  • Next by thread: Listable vs. Thread