Re: Function for complex polynomial with variable number of arguments
- To: mathgroup at smc.vnet.net
- Subject: [mg123557] Re: Function for complex polynomial with variable number of arguments
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Sun, 11 Dec 2011 03:46:50 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
> I'm not sure what's going on with the Fold here. Would the #2 slot refer > to the entry from the list, and the #1 slot to the "1"? At any rate, > very interesting. #1 refers to 1 on the first iteration. It refers to the first result on the second iteration. And so on. Bobby On Sat, 10 Dec 2011 06:31:38 -0600, Christopher Young <cy56 at comcast.net> wrote: > > From: Heike Gramberg <heike.gramberg at gmail.com> > Subject: Re: Function for complex polynomial with variable > number of arguments > Date: December 8, 2011 5:38:34 AM EST > To: Chris Young <cy56 at comcast.net> > Cc: mathgroup at smc.vnet.net > >> You could do something like this >> >> poly[z_, p___] := Fold[(z - #2) #1 &, 1, {p}] >> >> This works for p=={} as well, i.e. >> >> poly[x+I y] >> >> returns 1. > > I'm not sure what's going on with the Fold here. Would the #2 slot refer > to the entry from the list, and the #1 slot to the "1"? At any rate, > very interesting. > > -- DrMajorBob at yahoo.com