Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43842
| Date | 2013-04-18 19:17 +0200 |
|---|---|
| From | Karim <kliateni@gmail.com> |
| Subject | Re: equivalent to C pointer |
| References | <CAF3f0sQ_rsdKwaEOCmFHEeEwpVUaNUo-pOYgoqYA_F-k0CftcA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.781.1366305472.3114.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
Hello,
There is no such notion in python.
But the closest are iterators and generator functions.
Cheers
Karim
On 18/04/2013 19:06, abdelkader belahcene wrote:
> Hi everybody,
>
> I am new to python and I am discovering it.
> I know C well,
> and want to know if python knows how to manage Pointers
> like pointer to function here is a C example how to write it in python
> Intergration with trapeze method
>
> When we write Trapeze ( at the compilation level) we don't know
> which functions
> Fonc to handle. Here for example we use sin and a user defined F1
> The program is attached too
>
> #include <stdio.h>
> #include <math.h>
>
> double F1 (double x){
> return x*x;
> }
> double Trapeze(double Fonc(double ),
> double left, double right, double step){
> double X1, X0, Y0, Y1, Z = 0;
> for(X0=left; X0 < right ; X0 = X0 + step) {
> X1 = X0 + step;
> Y1 = Fonc(X1); Y0 = Fonc(X0);
> Z += (Y1 + Y0) * step * 0.5;
> }
> return Z;
> }
> int main(){
> double y;
> y=Trapeze(sin, -2.5, 3.2, 0.1);
> printf("\n\tValue for sin is : \t %8.3lf ", y);
> y=Trapeze(F1, 0, 3, 0.1);
> printf("\n\tValue for F1 is : \t %8.3lf ", y);
> return 0;
> }
> /**
> Value for sin is : 0.197
> Value for F1 is : 9.005
> */
> thanks a lot
>
>
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: equivalent to C pointer Karim <kliateni@gmail.com> - 2013-04-18 19:17 +0200
csiph-web