Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.maple > #351

Re: Prefix and Suffix Notation in Maple?

From acer <maple@rogers.com>
Newsgroups comp.soft-sys.math.maple
Subject Re: Prefix and Suffix Notation in Maple?
Date 2012-02-06 22:27 -0800
Organization http://groups.google.com
Message-ID <8339104.3663.1328596078039.JavaMail.geo-discussion-forums@vbuf18> (permalink)
References <4f30adeb$0$4049$4d5ecec7@news.xsusenet.com>

Show all headers | View raw


I'm not sure that I fully understand why arg//function is a "shortcut", since it's the same number of characters as function(arg). Is it because using it doesn't entail hitting the shift-key, so two key presses are saved?

You can customize your own infix operators, to get those two effects as (you've described them).

Perhaps the nicer ones for this would be those which don't need to be called with name-quotes. Eg, &~ would get called as func&~arg instead of func`&~`arg

For example, they could be done as,

restart:

`&>`:=proc(a,b) a(b); end proc:
`&<`:=proc(a,b) b(a); end proc:

f:=t->sin(t)+t^3:

f&>4;
                          sin(4) + 64

13&<f;
                         sin(13) + 2197


Another choice might be to use symbols which don't both require the shift-key (apart from being used for the ampersand). For example, &. and &,

One way in which using infix operators to mimick these two functionalities could be different than what Mathematica's scheme offers is in the operator precedence. I don't know how Mathematica's @ and // appear in the systems precedence order, or what their relative binding strenghts are.

See,
  http://www.maplesoft.com/support/help/Maple/view.aspx?path=operators/precedence
for the run-down on Maple's precedence order for operators. (This might affect which inert &-operators might make a better choice for your task, come to think of it.)

If you really, really want to, you might be able to create a small package whose two exports would rebind < and > to do these infix actions when used interactively. You'd have to also remember to use the global prefix operators :-`>` and :-`<` whenever you need them in thei usual sense as inequality tests. But Maple's own Library routines would continue to work as usual. So, making like easier and harder at the same time:

restart:

pref_post:=module() option package; export `<`, `>`;
  `>`:=proc(a,b) a(b); end proc:
  `<`:=proc(a,b) b(a); end proc:
end module:

with(pref_post);
                             [<, >]

f:=t->sin(t)+t^3:

f>3;
                          sin(3) + 27

7<f;
                          sin(7) + 343

if 5>4 then true else false end if;
Error, invalid boolean expression: 5

if :-`>`(5,4) then true else false end if;
                              true


acer

Back to comp.soft-sys.math.maple | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Prefix and Suffix Notation in Maple? "Dr. Giggleson" <hahaha@com.yahoo> - 2012-02-06 22:51 -0600
  Re: Prefix and Suffix Notation in Maple? acer <maple@rogers.com> - 2012-02-06 22:27 -0800
    Re: Prefix and Suffix Notation in Maple? acer <maple@rogers.com> - 2012-02-06 22:49 -0800

csiph-web