[RPL/2] idea new data type for RPL

BERTRAND Joël joel.bertrand at systella.fr
Mon Jul 3 14:30:17 CEST 2017


Jaime Fernando Meza Meza a écrit :
> Hello Joel
>
> The object must be simple not recursive,
>
> I think should also have a prefix to differentiate it from a list or a
> vector
>
> set{} or set[]
>
> Another very important object that is frequently used in mathematics are
> the univariate polynomials on the operations (^,+,-,*,/ )
>
> poly1[ 1, 2, 3 ]  2 ^ returns poly1[ 1, 4, 10, 12, 9]
>
> poly1[ 1,-2 ]  pl[ 1, 2, 4 ] * returns poly1[ 1, 0, 0, -8 ]
>
> poly1[1,2] poly1[3,4,5] + returns poly1[3,5,7]
>
> poly1[1,2] poly1[3,4,5] - returns poly1[-3,-3,-3]
>
> (3*x^2+4*x+5)/(x+2) ->
>
> poly1[3,4,5] poly1[1,2]  / returns { poly1[3,-2], poly1[9] } @
> {quotient, remain}
>
> Thanks Jaime

	Hello,

	As you required, I have modified RPL/2 core to be able to manage new 
types in RPL/SO objects.

	On CVS tree (and in next daily snapshot), you will find a new module in 
modules/sets.

	When you build and install RPL/2, this module will be installed in 
$(install_dir)/lib. This module shall be loaded by USE (with or without 
complete path). If module name does not begin with '/', RPL/2 will try 
to open module in current directory and, if it doesn't find any modules, 
in $(install_dir)/lib. A RPL/CO object can be removed by REMOVE intrinsic.

RPL/2> "sets.rplso" use

Sets library V1R1 for RPL/2(C) 2017 BERTRAND Joel
Sets library loaded.


1: Library $ 00005594A6A5D200 [/usr/local/lib/sets.rplso]
RPL/2> ([ 1 2 3 4 5 6 7 8 9 ]) ([ 3 6 8 ]) complement

2: Library $ 00005594A6A5D200 [/usr/local/lib/sets.rplso]
1: ([ 1 2 4 5 7 9 ])
RPL/2> ([ 1 2 8 9 ]) ([ 3 6 8 ]) union

3: Library $ 00005594A6A5D200 [/usr/local/lib/sets.rplso]
2: ([ 1 2 4 5 7 9 ])
1: ([ 1 2 3 6 8 9 ])
RPL/2> ([ 1 2 8 9 ]) ([ 3 6 8 ]) intersection

4: Library $ 00005594A6A5D200 [/usr/local/lib/sets.rplso]
3: ([ 1 2 4 5 7 9 ])
2: ([ 1 2 3 6 8 9 ])
1: ([ 8 ])
RPL/2> ([ 1 2 8 9 ]) ([ 3 6 ]) intersection

5: Library $ 00005594A6A5D200 [/usr/local/lib/sets.rplso]
4: ([ 1 2 4 5 7 9 ])
3: ([ 1 2 3 6 8 9 ])
2: ([ 8 ])
1: ([ ])
RPL/2>

	All instructions loaded by USE intrinsic can be called by name (UNION) 
or by library/name (SETS$UNION) to avoid conflict.

	Please not that it is impossible to write a program that contains these 
new types. Of course, a program can use these types but I have to add a 
flag in RPL/2 invocation to load RPL/SO objects _before_ half 
compilation stage.

	Best regards,

	JKB


More information about the RPL2 mailing list