Re: Array of Functions

2015-05-26 Thread Gary Herron
t those two functions in a list. Then, with appropriate parameters, I called one of the functions in the list, associated the formal parameter with the function in a call to the array, and presto, it performs the function. The more advanced problem I wanted to solve, a two dimensional arr

Re: Array of Functions

2015-05-26 Thread Laura Creighton
hose two functions in a list. Then, with appropriate parameters, I >called one of the functions in the list, associated the formal parameter with >the function in a call to the array, and presto, it performs the function. > >The more advanced problem I wanted to solve, a two dimen

Re: Array of Functions

2015-05-26 Thread richard_riehle
ith the function in a call to the array, and presto, it performs the function. The more advanced problem I wanted to solve, a two dimensional array of functions, once this example is understood, becomes trivial to implement. In fact, the more interesting problem I wanted to solve invo

Re: Array of Functions

2014-11-17 Thread Anton
On Friday, November 14, 2014 2:17:38 PM UTC-8, Richard Riehle wrote: > In C, C++, Ada, and functional languages, I can create an array of functions, > albeit with the nastiness of pointers in the C family. For example, an > array of functions where each function is an active butt

Re: Array of Functions

2014-11-16 Thread Richard Riehle
On Friday, November 14, 2014 4:13:28 PM UTC-8, Dennis Lee Bieber wrote: > On Fri, 14 Nov 2014 14:17:23 -0800 (PST), Richard Riehle > declaimed the following: > > >In C, C++, Ada, and functional languages, I can create an array of > >functions, albeit with the nastiness

Re: Array of Functions

2014-11-14 Thread Terry Reedy
On 11/14/2014 5:17 PM, Richard Riehle wrote: In C, C++, Ada, and functional languages, I can create an array of functions, albeit with the nastiness of pointers in the C family. For example, an array of functions where each function is an active button, or an array of functions that behave like

Re: Array of Functions

2014-11-14 Thread MRAB
On 2014-11-14 22:17, Richard Riehle wrote: In C, C++, Ada, and functional languages, I can create an array of functions, albeit with the nastiness of pointers in the C family. For example, an array of functions where each function is an active button, or an array of functions that behave like

Re: Array of Functions

2014-11-14 Thread Ian Kelly
On Fri, Nov 14, 2014 at 3:17 PM, Richard Riehle wrote: > In C, C++, Ada, and functional languages, I can create an array of functions, > albeit with the nastiness of pointers in the C family. For example, an > array of functions where each function is an active button, or an

Re: Array of Functions

2014-11-14 Thread Sam Raker
functions properties, which is Python for 'preprocessed attributes.' On Friday, November 14, 2014 5:17:38 PM UTC-5, Richard Riehle wrote: > In C, C++, Ada, and functional languages, I can create an array of functions, > albeit with the nastiness of pointers in the C family. For exam

Re: Array of Functions

2014-11-14 Thread Marko Rauhamaa
Richard Riehle : > Example: > > r1c1 r1c2 r1c3 > r2c1 r2c2 r2c3 > r3c1 r3c2 r3c3 > > where r1 is row 1 and c1 is column 1. Suppose I want an array where the > colum three is a set of functions that operates on the other two > columns, depending on the v

Array of Functions

2014-11-14 Thread Richard Riehle
In C, C++, Ada, and functional languages, I can create an array of functions, albeit with the nastiness of pointers in the C family. For example, an array of functions where each function is an active button, or an array of functions that behave like formulae in a spreadsheet. I am finding

Re: Array of functions, Pythonically

2008-02-25 Thread Paul McGuire
On Feb 25, 11:53 am, [EMAIL PROTECTED] wrote: > >  { '+': operator.add, '-': operator.sub, ... } > > Then EXPR OPER EXPR -> ops[ OPER ]( EXPR, EXPR ), right? I think this is the most Pythonic idiom. You can even define your own custom binary operators, such as '$' to convert dollars and cents to

Re: Array of functions, Pythonically

2008-02-25 Thread castironpi
>  { '+': operator.add, '-': operator.sub, ... } Then EXPR OPER EXPR -> ops[ OPER ]( EXPR, EXPR ), right? -- http://mail.python.org/mailman/listinfo/python-list

Re: Array of functions, Pythonically

2008-02-25 Thread Bruno Desthuilliers
[EMAIL PROTECTED] a écrit : > My parser has found an expression of the form CONSTANT_INTEGER > OPERATOR CONSTANT_INTEGER. I want to fold this into a single > CONSTANT_INTEGER. > > The OPERATOR token has an intValue attribute, '+' == 0, '-'== 1, etc. > In C I'd put functions Add, Subtract, ... into

Re: Array of functions, Pythonically

2008-02-25 Thread Duncan Booth
[EMAIL PROTECTED] wrote: > My parser has found an expression of the form CONSTANT_INTEGER > OPERATOR CONSTANT_INTEGER. I want to fold this into a single > CONSTANT_INTEGER. > > The OPERATOR token has an intValue attribute, '+' == 0, '-'== 1, etc. > In C I'd put functions Add, Subtract, ... into a

Array of functions, Pythonically

2008-02-25 Thread MartinRinehart
My parser has found an expression of the form CONSTANT_INTEGER OPERATOR CONSTANT_INTEGER. I want to fold this into a single CONSTANT_INTEGER. The OPERATOR token has an intValue attribute, '+' == 0, '-'== 1, etc. In C I'd put functions Add, Subtract, ... into an array and call ArithmeticFunctions[

Re: How do I create an array of functions?

2007-02-19 Thread Steven D'Aprano
On Mon, 19 Feb 2007 05:17:03 -0800, Rob Wolfe wrote: >> > # test.py >> > >> > def fun1(): return "fun1" >> > def fun2(): return "fun2" >> > def fun3(): return "fun3" >> > >> > # list of functions >> > dsp = [f for fname, f in sorted(globals().items()) if callable(f)] >> >> Hmmm... when I try that,

Re: How do I create an array of functions?

2007-02-19 Thread John Machin
On Feb 19, 11:47 pm, Steven D'Aprano <[EMAIL PROTECTED]> wrote: > On Mon, 19 Feb 2007 00:16:39 -0800, Rob Wolfe wrote: > > > Steven W. Orr wrote: > >> I have a table of integers and each time I look up a value from the table > >> I want to call a function using the table entry as an index into an a

Re: How do I create an array of functions?

2007-02-19 Thread Rob Wolfe
Steven D'Aprano wrote: > On Mon, 19 Feb 2007 00:16:39 -0800, Rob Wolfe wrote: > > > > > Steven W. Orr wrote: > >> I have a table of integers and each time I look up a value from the table > >> I want to call a function using the table entry as an index into an array > >> whose values are the diffe

Re: How do I create an array of functions?

2007-02-19 Thread Steven D'Aprano
On Mon, 19 Feb 2007 00:16:39 -0800, Rob Wolfe wrote: > > Steven W. Orr wrote: >> I have a table of integers and each time I look up a value from the table >> I want to call a function using the table entry as an index into an array >> whose values are the different functions. I haven't seen anyt

Re: How do I create an array of functions?

2007-02-19 Thread Paul Rubin
thing on how to do this in python. func_array = [f1, f2, f3]# array of functions index = table_lookup() func_array[index](x,y,z) # select a function and call it -- http://mail.python.org/mailman/listinfo/python-list

Re: How do I create an array of functions?

2007-02-19 Thread Rob Wolfe
Steven W. Orr wrote: > I have a table of integers and each time I look up a value from the table > I want to call a function using the table entry as an index into an array > whose values are the different functions. I haven't seen anything on how > to do this in python. Do you mean something li

Re: How do I create an array of functions?

2007-02-19 Thread Diez B. Roggisch
Steven W. Orr schrieb: > I have a table of integers and each time I look up a value from the > table I want to call a function using the table entry as an index into > an array whose values are the different functions. I haven't seen > anything on how to do this in python. def f(): pass f

How do I create an array of functions?

2007-02-18 Thread Steven W. Orr
I have a table of integers and each time I look up a value from the table I want to call a function using the table entry as an index into an array whose values are the different functions. I haven't seen anything on how to do this in python. TIA -- Time flies like the wind. Fruit flies like