Re: Help to clarify 'Map', 'Apply', and 'Thread'.
- To: mathgroup at smc.vnet.net
- Subject: [mg15713] Re: Help to clarify 'Map', 'Apply', and 'Thread'.
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Fri, 5 Feb 1999 03:42:13 -0500 (EST)
- References: <795386$kd1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Ersek, Ted R wrote in message <795386$kd1 at smc.vnet.net>... >As I said at the beginning the third argument of Thread can be an >integer (positive or negative) or a list of such integers, but I don't >know what this might do for you. Ted, Hope these examples will help: Make h[ f threads through elements of f[..] with head h ] ( all other elements of f[..] regarded as atomic) In[1]:= Thread[ h[1, 2], k[1, 2], h[1, 2] ], h ] Out[1]= h[ f[1, k[1, 2], 1], f[2, k[1, 2], 2] ] Make h[ f threads through elements of f[..] with head h that are in positions 1 through 2] ( all other elements of f[..] regarded as atomic) In[2]:= Thread[ h[1, 2], k[1, 2], h[1, 2] ], h, {1,2} ] Out[2]= h[ f[1, k[1, 2], h[1, 2]], f[2, k[1, 2], h[1, 2]] ] Elements threaded through must be of same length. In[3]:= Thread[f[h[1, 2], h[1]], h] Thread::"tdlen": "Objects of unequal length in \!\(f[\(\(h[\(1, 2\)]\), \ \(h[1]\)\)]\) cannot be combined." Out[3]= f[h[1, 2], h[1]] Allan --------------------- Allan Hayes Mathematica Training and Consulting www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565