Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43841
| Path | csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <abelahcene@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.016 |
| X-Spam-Evidence | '*H*': 0.97; '*S*': 0.00; 'everybody,': 0.07; '#include': 0.09; 'pointers': 0.09; 'received:209.85.219': 0.09; 'python': 0.11; '/**': 0.16; '0.1);': 0.16; '0.5;': 0.16; 'left,': 0.16; 'x1,': 0.16; 'y1,': 0.16; '<': 0.19; 'example': 0.22; 'compilation': 0.24; 'pointer': 0.24; 'defined': 0.27; 'function': 0.29; 'message-id:@mail.gmail.com': 0.30; 'received:209.85': 0.35; 'knows': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'charset:us-ascii': 0.36; 'thanks': 0.36; 'too': 0.37; 'received:209': 0.37; 'step': 0.37; 'skip:& 10': 0.38; 'to:addr :python-list': 0.38; '\xa0\xa0\xa0': 0.39; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'how': 0.40; 'new': 0.61; 'here': 0.66; 'use\xa0': 0.84; 'discovering': 0.91 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=B6PR7Tz0YyNaOsiKjdG6by2oMFJLvf9ujBz3d9Mij6w=; b=ozD2iYuzvlU47p/bWo3zlL1HMkubgwVXx9tvb/OuG0rP0FFUwCfEweiDaSHj2w0H1A yuIaYYvvoqt7nZBxbdMqv7BYRHb2VQ64qfAJh38d0oY9tqUs6eT9msb3jAZ6l0rwelSs P29BcZAz/MW535eQIFs4mqZ1m4agGST6+eVqsOjq+EZfYinuBqcgULE8/T5HKk2yzug8 qrSFdykunUOwGyONx6stlRsjoHN/G5Z6F3+Dc39Kozvse7OmcC5UtIQXTEULYBKIYtdy jROxLbsYuHXW61/+G78vwEHFN9FLZ2IjMvIWJ4at0sE4rLDYOT+P+GPDBA+DtNiSPBml Gadg== |
| MIME-Version | 1.0 |
| X-Received | by 10.60.83.70 with SMTP id o6mr944583oey.81.1366304765504; Thu, 18 Apr 2013 10:06:05 -0700 (PDT) |
| Date | Thu, 18 Apr 2013 18:06:05 +0100 |
| Subject | equivalent to C pointer |
| From | abdelkader belahcene <abelahcene@gmail.com> |
| To | python-list@python.org |
| Content-Type | multipart/mixed; boundary=089e01176ceb34402804daa59e0c |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.780.1366304774.3114.python-list@python.org> (permalink) |
| Lines | 102 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1366304774 news.xs4all.nl 2265 [2001:888:2000:d::a6]:50164 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:43841 |
Show key headers only | View raw
[Multipart message — attachments visible in raw view] - view raw
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
equivalent to C pointer abdelkader belahcene <abelahcene@gmail.com> - 2013-04-18 18:06 +0100
csiph-web