i understood Listable to be an attribute which automatically threads a function.
I therefore expect that i could either makea function Listable or I could
'manually' Thread it to its arguments.
However, as the example below shows, using Thread with the function does
not work the same as maing the function Listable (in fact using Thread
appears to go to too low a level producing an error message.
could someone please explain exactly what's going on here (i don't
understand why using Thread produced an error) and what functions need to
be 'manually' applied to a function for it to work the same way as it does
when its Listable.
thanks.
dog = {{1,0,1,1},{1,1,1,0}};
cat = {{1,1,0,1},{1,1,0,0}};
doIt[x_,0] := a
doIt[0,y_] := b
doIt[x_,y_] := c
Attributes[doIt] = Listable
Listable
doIt[dog,cat]
{{c, b, a, c}, {c, c, a, a}}
dontDoIt[x_,0] := a
dontDoIt[0,y_] := b
dontDoIt[x_,y_] := c
Thread[dontDoIt[dog,cat]]
Thread::normal:
Normal expression expected at position 1 in Thread[c].
Thread[c]
richard j. gaylord, university of illinois, gaylord at ux1.cso.uiuc.edu
"if you're not programming functionally, then you must be programming
dysfunctionally"