octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Infix form


From: Jaroslav Hajek
Subject: Re: Infix form
Date: Mon, 9 Jun 2008 07:47:18 +0200

On Sun, Jun 8, 2008 at 10:25 PM, address@hidden
<address@hidden> wrote:
> Hello
>  I am searching for a way to define n-variable functions as n-ary operators,
> most frequently n=1,2 of course. That is I want to define infix forms of
> functions in the case of two variables.
> The reason for needing this is that I want to replace expressions of the form
>
>  booleanOp(Mtx,Arg).*Mtx
>
>  ... with the syntax ..
>
>  Mtx(booleanOp(Arg(s)))
>
>  e.g
>
>  (A<2).*A =: A(<2).
>

I guess we should think not twice, but three or more times before
adding new syntax like this. This is really a syntactic sugar that
will save you 3 letters. And most people aren't used to it, so they
probably won't use it, unless it provides a good advantage.

If what you have in mind are the time & memory savings (the temporary
A<2 doesn't need to be constructed), then you can consider adding
"compound operator" that will pick these expressions in the parse tree
and evaluate them specially.
Note, however, that this is a "level-1" expression (i.e., one or
several passes through an array) and these are seldom a bottleneck -
if they are, you should consider creating a C++ function anyway. It
would be cool to have them optimized, but note that you can easily
come up with hundreds of such expressions, so we would need something
more complicated to handle these - perhaps some kind of "lazy
evaluation".

> Perhaps I should use a functional language as front-end for this kind of
> applications but I ask this forum, perhaps improperly: How can I do this best?
> Is it recommendable to overload octave source with this functionality or
> should I script from a functional language? Is this syntax already implemented
> and what number of operations is actually carried out in the example above? It
> should really simplify if I could operate directly on the elements by "giving
> the matrix" an operator, preumably boolean ( E.g. M( < 2 && > 3 || divisibleBy
> 2) and so on. ) but perhaps even continous and perhaps even working on
> surrounding elements. I yet have no insight in the sources but ask for an 
> early
> advice.
>
>   Have been looking for an easy way to donate, smaller amounts, to the octave
> project. Is there a lower limit at the webform to administer?
>
> Thank you for your time and a lovely programming environment.
>
> /Anders
>



-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


reply via email to

[Prev in Thread] Current Thread [Next in Thread]