program, reserved word

Messages in english

Modérateur : xcasadmin

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

program, reserved word

Message par compsystems » mer. juil. 12, 2017 1:04 pm

Hello Bernard, I can not find information about the PROGRAM reserved word

For a function of a single variable the definition of a function with program(...) works well, for the n variables, which is the syntax?, see line #17

Code : Tout sélectionner

1: 
F1(X):=X^2=9
(X)->X^2=9

2: 
F1(3)
9=9

3: 
part(F1,0)
"program"

4: 
part(F1,1)
X (copy -> paste)
seq[X]

5: 
part(F1,2)
0 (copy -> paste)
seq[0]

6: 
part(F1,3)
X^2=9

7: 
F11:=program(seq[X],seq[0],X^2=9)
(X)->X^2=9
 
8: 
F11(3)
9=9
 
9: 
F11:=program(X,0,X^2=9)
(X)->X^2=9
 
10: 
F11(3)
9=9

11: 
V1(X,Y):=2*X^2-Y^2=7
(X,Y)->2*X^2-Y^2=7

12: 
V1(2,1)
7=7

13: 
part(V1,0)
program (copy -> paste)
"program" 

14: 
part(V1,1)
(X,Y) (copy -> paste)
X,Y

15: 
part(V1,2)
(0,0) (copy -> paste)
0,0

16: part(V1,3)
2*X^2-Y^2=7

17: 
V11:=program((X,Y), (0,0), 2*X^2-Y^2=7)
V11:=program(seq[X,Y], seq[0,0], 2*X^2-Y^2=7)

 (X)->2*X^2-Y^2=7  // does not define the variable Y

18:
V11(2,1) 
error


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

Re: program, reserved word

Message par parisse » jeu. juil. 13, 2017 6:02 am

program should not be used directly by the user, it's much safer and simpler to use the normal syntax to build a program. There are 3 arguments, the variables (in a list), the values (in a list) and the list of instructions,

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: program, reserved word

Message par compsystems » jeu. juil. 13, 2017 12:22 pm

ok, The use of lists as arguments works well,

Code : Tout sélectionner

17
V1:=program(list[X,Y],list[0,0],2*X^2-Y^2=7)
 (list[X,Y])->2*X^2-Y^2=7 

18
V1(2,1)
7=7

or
17
V1:=program([X,Y],[0,0],2*X^2-Y^2=7)
([X,Y])->2*X^2-Y^2=7 

18
V1(2,1)
7=7
BP, can please improve the following results that PART cmd performs (Output between parentheses to output in square brackets), so that the reverse process is correct

(X,Y) => [X,Y] => (copy -> paste) list[X,Y]

part(V1,1) => [X,Y]

Code : Tout sélectionner

1: 
V1(X,Y):=2*X^2-Y^2=7
(X,Y)->2*X^2-Y^2=7

2: 
part(V1, 0)
program (copy -> paste)
"program" 

3: 
part(V1, 1)
(X,Y)   => [X,Y] (copy -> paste)
list[X,Y]

4: 
part(V1, 2)
[0,0] (copy -> paste)
list[0,0]

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

Re: program, reserved word

Message par parisse » jeu. juil. 13, 2017 4:37 pm

I don't understand what do you want to do.
By the way, there is nothing special about list[ vs [

compsystems
Messages : 562
Inscription : sam. févr. 04, 2017 11:34 pm
Localisation : Colombia
Contact :

Re: program, reserved word

Message par compsystems » lun. juil. 17, 2017 5:01 pm

The output of the PART command for the following case, must return a list [x,y] and not (x,y), so that the reverse process can be rebuilt.

Code : Tout sélectionner

1:
V9(X,Y):=2*X^2-Y^2=7
[X,Y]->2*X^2-Y^2=7

2:
[ part(V9,1), part(V9,2), part(V9,3) )
[X,Y,0,0,2*X^2-Y^2=7]  =( 5 args

[ [X,Y],[0,0],2*X^2-Y^2=7]  =) 3 args OK

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

Re: program, reserved word

Message par parisse » lun. juil. 17, 2017 6:39 pm

It's because sequences are concatenated during evaluation. But you can convert yourself sequences to lists by adding [], like for example [part(V9,1)]

Répondre