user_operator

Messages in english

Modérateur : xcasadmin

belanger
Messages : 46
Inscription : jeu. juil. 27, 2017 3:26 pm

user_operator

Message par belanger » mar. sept. 15, 2020 3:33 am

For the user_operator command, what are Binary and Delete for?
From playing with it, it looks as if the Binary option means define
the operator, but why would you use the command if you aren't
defining an operator? And Delete seems to mean don't define the
operator and ignore the whole user_operator command, but why
use the command if you aren't defining the operator? It doesn't
seem to undefine an already defined user operator.
I seem to be missing their use.

Jay

parisse
Messages : 5090
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: user_operator

Message par parisse » mar. sept. 15, 2020 5:45 am

It's like storing and purging a variable, with Binary or Unary option you are storing, with Delete option you are purging.

belanger
Messages : 46
Inscription : jeu. juil. 27, 2017 3:26 pm

Re: user_operator

Message par belanger » mar. sept. 15, 2020 5:16 pm

Either it's not working, or perhaps my brain not's working. Sorry if
I'm being dense.
Delete doesn't seem to do anything; if an operator was previously
defined, it stays defined, and if the symbol was a variable given
a value, it keeps that value and no new operator is defined.
See the session below.

Also, what does Unary do? What is a unary infixed operator?

Jay

>> user_operator("A",(x,y)->x+2*y,Binary)
1
>> 2 A 4
10
>> user_operator("A",(x,y)->x+2*y,Delete)
1
>> 2 A 4
10
>> B := 4
4
>> user_operator("B",(x,y)->x+2*y,Binary)
1
>> 2 B 4
10
>> B
undef
>> C := 4
4
>> user_operator("C",(x,y)->x+2*y,Delete)
0
>> 2 C 4
undef
>> C
4
>>

parisse
Messages : 5090
Inscription : mar. déc. 20, 2005 4:02 pm
Contact :

Re: user_operator

Message par parisse » mer. sept. 16, 2020 8:09 am

You have spotted a lot of bugs!
Delete did not work, it will be fixed in the next release, and it will work with a more natural syntax: user_operator("A",Delete)
Unary is inexistant, but Prefix and Postfix are working, I will alias Unary to Prefix.

Répondre