**Function as parameter of a function with parameters**Hello,
I can do :
void DoFunct(void (*funcp)());
void MyFunct()
{
//...
}
DoFunct(MyFunct);
but is it possible to pass to DoFunct() a function MyFunct with
parameters ?
Thanks in advance.
marc wrote:
> Hello,
>
> I can do :
>
> void DoFunct(void (*funcp)());
>
> void MyFunct()
> {
> //...
> }
>
> DoFunct(MyFunct);
>
> but is it possible to pass to DoFunct() a function MyFunct with
> parameters ?
>
> Thanks in advance.
void DoFunct(void(*funcp)(int));
void MyFunct(int i)
{
// ...
}
int main(void)
{
DoFunct(MyFunct);
// ...
...

**How to pass a parameter for a function parameter in a function**
function foo(msg)
{
alert(msg);
}
var insertForm = function()
{
this.button = $('add_customer');
this.button.observe('click', foo('hello world'));
}
The above line ' this.button.observe('click', foo('hello world'));'
does not really work. It will work if I don't pass any parameters.
AzamSharp a �crit :
> function foo(msg)
> {
> alert(msg);
> }
>
>
>
> var insertForm = function()
> {
> this.button = $('add_customer');
> this.button.observe('click', foo('hello ...

**restriction of a two-parameters function to a one-parameter function**Hi,
suppose we have these two functions (not very interesting, but this is for
clarity) :
-) a function Primitive that computes at t the primitive of a function
f :
double Primitive ( double(*f)(double), t);
-) a function Indicatrice that defines if the parameter t is in the
interval [i, i+1] :
double Indicatrice ( int, double );
I'd like to write a function Indicatrice_i, restriction of Indicatrice to
i, like this :
double (*Indicatrice_i)(double) = Indicatrice(i);
to use it such this manner :
...

**Functions as function parameter**Hi,
I want to pass a C-function as a function parameter but I don't know
how to that correctly. In the example below how would I have to declare
the function argument in the my_sort function definition?
Thank you in advance for any help.
Regards
Rolf
int comp_func1(double * a1, double * a2)
{
...
}
void my_qsort(double * a, int n, (* comp_func))
{ ???????
...
comp_func(&a[i], &a[j]);
...
}
int main()
{
...
my_qsort(a,n,comp_func1);
}
Rolf Wester <rolf.wester@ilt.fraunhofer.de> scribbled the following:
> Hi,
> I want to ...

**function with parameters of function**Hi there,
I'm studying dynamic data structure (simple & double linked list,
heap, cola, tree, etc) but the teacher obviated the namespaces and
others declarations that I don't know their names, old students call
it demons inside functions. I'm writing here hoping for you can help
me.
I've downloaded a tuto where is explained what are the namespace, so,
I don't have doubts about it.
The other thing is something like a function with parameters of
function (called demons), here, I write you the classes declaration
that he wrote on the blackboard, unfortunately he didn&#...

**defining a function whose parameter must be a function with two parameters**Dear all,
I am trying to define a function F which will only execute if its parameter is a function with two parameters. Let's say I define it thus, without any checks on the parameter pattern f:
In[1] := F[f_] := f[2,3]
There are several ways of calling F:
1) pass it a function of two parameters:
In[2] := F[Function[{a,b},a^2-b^2]]
Out[2] = -5
2) pass it an anonymous function of two parameters:
In[3] := F[#1^2-#2^2 &]
Out[3] = -5
3) pass it a pre-defined function:
In[4] := g[a_,b_] = a^2-b^2;
In[5] := F[g]
Out[5] = -5
My question is: how can I define a pattern ...

**Given function of single parameter function, to find function and**By what Mathematica procedures is it possible to solve for function f
and the parameter/argument linking relation UV [u,v] = 0 from a given
relation f[v]= 4 f[u]^3 - 3 f[u] ? Known answer for this case is
function f = cos, argument link relation v =3 u respectively.
For another simpler case f(u)^2 + f(v)^2 =1, one solution is u + v =
(2 k-1) pi/2, for f = cos or sin.
Best Regards
Narasimham
...

**How to pass a function pointer to a function with std::function parameters**{ Reformatted; please limit your lines to 70 characters -mod }
Hi,
I am trying to write a little helper template function which takes a
std::function object and a parameter and calls the function object and
does some additional work. This all works fine until I try to call the
template function with a function pointer directly without first
creating a temporary std::function object: #include <functional>
void globalF(int)
{
}
struct A
{
void memberF(int);
};
template<typename T>
void call(std::function<void (A*, T)> func, T x)
{
A a;
fu...

**function pointers as function parameters**I am experimenting with function pointers. Unfortunately, my C book has
nothing on function pointers as function parameters. I want to pass a
pointer to ff() to f() with the result that f() prints the return value
of ff(). The code below seems to work, but I would appreciate your
comments. Have I got it right? Does the function name "decay" to a pointer?
#include <stdio.h>
/* declares a function which takes an argument
that is a pointer to a function returning an int */
void f(int (*fptr)());
/* function returning an int */
int ff(void);
int main(void)
{
f(ff); ...

**m-function with function parameter**How to write a matlab function which its
parameter is a function?
thanks a lot!
su flora wrote:
>
>
> How to write a matlab function which its
> parameter is a function?
> thanks a lot!
Read the help entry
Programming and Data Types: Function Handles
/ per
...

**mapping functions with functions as parameters?**Hi!
does anybody know how to use a mapping function with functions instead
of lists?
I've written some auxiliary functions and instead of calling them
separately with many conditions I want to use a mapping function like
that:
(map #' (lambda (i) (do-something)) '(test1 test2 test3 test4))
My code looks like:
(test1)
(when (=T found-nothing)
(test2)
(when (=T found-nothing)
(test3)....
Thanks!
Daniela
In article <1174979567.153752.98330@d57g2000hsg.googlegroups.com>,
Daniela.Nitsch@web.de wrote:
> Hi!
>
> does anybody know how to use a mappi...

**Function pointer as function parameter**I've developed an application using both Fortran and C languages.
Fortran layer is the upper layer and uses C functions to perform low
level operations.
I need to supply a Fortran function to a C function as parameter (C
function has a pointer to function as parameter) in order to let the C
function call the Fortran one.
It creates me some problems... function pointer is not correctly
passed to C function...
Can someone give me some advice to solve this problem ???
// This is the fortran call where createthread is the C function and
proc_x_dsv2 is the fortran function supplied as param...

**template function as function parameter**Hi all,
I was wondering if anyone had dealt with a similar problem. I need to use a
template function as the parameter for a particular function (also template
function).
The program compiles into an object file but then at the final stage it says
that it can't find template function. The platform is WindowsXP Pro, MSCV++
..Net.
More specifically what I want to do is write an atl algorithm that will also
accept another algorithm as a function parameter. This is inteface of the
outer algorithm:
template <class iterator, class outiterator, class Alg>
void transform_slide ( itera...

**write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter**hi all
basically my problem is i have to write a function such that when ever
i call this function in some other function .it should give me tha data
type and value of calling function parameter.and no of parameter is
calling function can be anything.
for example.suppose my function is function2.
then when i call
function1(int i ,char j,float d)
{
function2()
}
ouput should be
i is integer
j is char
d is float
and data type can be anything
On 24 Jan 2005 20:47:35 -0800, "komal" <avinash.gangwal@gmail.com>
wrote:
>hi all
>basically my problem is i have to write a func...

**Define PostgreSQL Function (View w/ Parameters) in DCT**In PostgreSQL, a view requiring parameters gets defined as a function that returns a table. Has anyone successfully defined this type of return table in a Clarion DCT?
I get a file open error but believe the table name variable must be set to something like - MyPGFunctionName(INT,INT) - in order to be recognized in PostgreSQL.
On 17/05/14 05:26, Douglas Johnson wrote:
> In PostgreSQL, a view requiring parameters gets defined as a function that returns a table. Has anyone successfully defined this type of return table in a Clarion DCT?
>
> I get a file open error but believe ...

**How to create a function that makes a .txt file w/ file name as parameter**Hello folks, in need of a little help.
I'm trying to construct a function that would create datapoints according to some equations and rules I've entered & parameters that are given by user. Everything works fine, but with the current code I can only make a file "testdata.txt". I'd like to change this so that the user could give the desired file name as an input parameter. How on earth can I do this? Current code is:
function z=CreateTPs(Form,R,maxstress,minstress,totalN,kNperV,c)
%(blablabla)
fid = fopen('testdata.txt', 'w');
fprintf(fid,...

**Change function parameter from inside the function**Hi,
Is there a way to change a parameter to a function in the body of the
function? For instance, I have this function
(defun add-to-population (rs1 population)
(adjoin rs1 population :test #'equal)
)
That I use this way
(setq current-population (add-to-population result current-population))
But since I always use this same form (return a value, and then use setq
to assign this return value to the function parameter), I would like to do
this operation this way:
(add-to-population result current-population)
Basically, whatever is passed as the population argument should be
assigne...

**Passing parameter to function not expecting parameter**I have come across some code that has been working for years, in which
function A calls function B and passes a parameter, but function B
does not expect any parameters!
(Obviously there was no prototype for B, an oversight which is being
corrected. With full warnings on, gcc warns of "implicit declaration"
which was the clue).
Anyway, my question is: what type of problems might this have been
causing?
I know, I know, you'll tell me nasal daemons and anything at all etc
etc, but thnking about some typical implementations, might there be
some data hanging around on ...

**pass function into another function as parameter?**hi,
is it possible to pass a function into another function as a
parameter? Say i have these:
function SaveMe(text)
{...}
function SaveMeNow(text)
{...}
function WhichToSave(x, y, z)
{...}
a button will call WhichToSave, that function will perform some logic
and then call one of the Save methods, can i pass that method in as
say parameter z and have it just call the function right away, passing
one of the SaveMe methods a parameter which is determined by the
WhichToSave method?
Thanks.
On Nov 20, 3:57=A0pm, soni2926 <soni2...@yahoo.com> wrote:
> hi,
> is it possible to pass ...

**Function pointer array as parameter to a function**Hi all,
I have a specific problem passing a function pointer array as a
parameter to a function. I am trying to use a function which takes a
function pointer array as an argument. I am too sure about the syntax
of calling the same.
#include <stdio.h>
void fp1()
{ printf("In fp1\n"); }
void fp2()
{ printf("In fp2\n");}
void fp3()
{ printf("In fp3\n");}
void call_fpn(void (*fp[3])())
{
(*fp[0])();
(*fp[1])();
(*fp[2])();
}
void main()
{
void (*pfn[3])()={NULL};
pfn[0]=&fp1;
pfn[1]=&fp2;
pfn[2]=&fp3;
call_fpn(.....);
}
Can som...

**Multiple parameter packs in function parameters**Is this valid code, or should it even compile?
template<typename... Pack1, typename... Pack2>
void func(Pack1... pack1, Pack2... pack2) {}
Currently the behavior of that seems quite erratic in different compilers.
In gcc you can t call that with zero arguments, but you can call it with
at least one argument (such as "func(5);") All the parameters are passed
as 'pack2'.
With clang if you try to call it directly with "func()" or "func(5)" you
get strange and conflicting error messages (in the first case it tells
that 'func&...

**Anonymous function as parameter to Inherited member function?**Hi!
For self-educational purposes I created an abstract class:
class Integrator {
public: virtual double Integrate( double f( double ), const double
a, const double b ) = 0;
};
Its purpose is to act as a common base class to classes implementing
different numerical integration algorithms, e.g. using Simpson's
formula or Romberg interpolation. The Integrate() method shall get
passed the function to integrate and integration boundaries.
Using function pointers the construction works fine, I also tried a
functor approach, subclassing std::unary_function<double, double&g...

**help:how to create a function with function handle parameter?**hi, guys,
I want to pass a function handler into another function but matlab
keeps telling me there is a mistake. I guess it does not recognize
the parameter as a function handler rather than a ordinary variable.
Here is my code:
function result=testfunctionhandle()
result=ope(@add,3,5);
function result=ope(funfcn,x,y)
result=funfcn(x,y);
function r=add(x,y)
r=x+y;
The error message returned from matlab:
??? Index exceeds matrix dimensions.
Error in ==> testfunctionhandle.m (ope)
On line 8 ==> result=funfcn(x,y);
Error in testfunctionhandle.m
On line 4 ==> result=ope(@add,3...

**Function to call function by name given as parameter**I want to write function to call another function which name is
parameter to first function. Other parameters should be passed to
called function.
If I call it function('f1',10) it should call f1(10). If I call it
function('f2',5) it should call f2(5).
So far i tried something like
CREATE FUNCTION [dbo].[func] (@f varchar(50),@m money)
RETURNS varchar(50) AS
BEGIN
return(select 'dbo.'+@f+'('+convert(varchar(50),@m)+')')
END
When I call it select dbo.formuła('f_test',1000) it returns
'select f_test(1000)', but not value of f...