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


Groups > comp.soft-sys.math.maple > #350 > unrolled thread

Prefix and Suffix Notation in Maple?

Started by"Dr. Giggleson" <hahaha@com.yahoo>
First post2012-02-06 22:51 -0600
Last post2012-02-06 22:49 -0800
Articles 3 — 2 participants

Back to article view | Back to comp.soft-sys.math.maple


Contents

  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

#350 — Prefix and Suffix Notation in Maple?

From"Dr. Giggleson" <hahaha@com.yahoo>
Date2012-02-06 22:51 -0600
SubjectPrefix and Suffix Notation in Maple?
Message-ID<4f30adeb$0$4049$4d5ecec7@news.xsusenet.com>
Hello friends,

I'm a regular Mathematica user, but I find that Maple does some things more intuitively and use it occasionally. However, it gets tedious typing function(arg) all the time. Mathematica solves this by using the prefix notation function@arg and suffix notation arg//function. Does Maple have comparable shortcuts?

Thank you.


--------------=  Posted using GrabIt  =----------------
------=  Binary Usenet downloading made easy =---------
-=  Get GrabIt for free from http://www.shemes.com/  =-

[toc] | [next] | [standalone]


#351

Fromacer <maple@rogers.com>
Date2012-02-06 22:27 -0800
Message-ID<8339104.3663.1328596078039.JavaMail.geo-discussion-forums@vbuf18>
In reply to#350
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

[toc] | [prev] | [next] | [standalone]


#352

Fromacer <maple@rogers.com>
Date2012-02-06 22:49 -0800
Message-ID<28641422.1263.1328597399647.JavaMail.geo-discussion-forums@yqkc2>
In reply to#351
Following up, the left-associativity of the &-operators makes using them to mimick postfix functional application appears to work OK. But it messes up for prefix functional application.

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

g:=t->R(t):

g&>f&>4; # not useful
                            R(f)(4)

4&<f&<g; # ok
                         R(sin(4) + 64)


So, without right associativity this is not such a nice way to get the prefix functionality. Putting in brackets, as delimiters, ruins it as a "shortcut".


g&>(f&>4); # result is ok
                         R(sin(4) + 64)



I don't have any better suggestion, for the prefix shortcut. Maple's `not` is right associative and a module could export it (rebind it for interactive use). But alas, it is unary.

acer



[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.maple


csiph-web