On 12/23/23 21:53, 'Nasser M. Abbasi' via FriCAS - computer algebra system wrote:
What I meant to say, the lists in Fricas have to be same type, else it will
not work with concat. Here is an example

20) -> L1:=[1,2,3]
(23) -> L2:=["D","E","F"]
(24) -> concat(L1,L2)
     gives error.

Yes. And it should give an error. Elements of a list must be of the same type.

However...

You can create a Union type.

%%% (1) -> l1:=[1,2,3]

   (1)  [1, 2, 3]
                                Type: List(PositiveInteger)
%%% (2) -> l2:=["D","E","F"]

   (2)  ["D", "E", "F"]
                                Type: List(String)
%%% (3) -> U ==> Union(Integer, String)
                                Type: Void
%%% (4) -> LU ==> List U
                                Type: Void
%%% (5) -> l1::LU

   (5)  [1, 2, 3]
                                Type: List(Union(Integer,String))
%%% (6) -> l2::LU

   (6)  ["D", "E", "F"]
                                Type: List(Union(Integer,String))
%%% (7) -> concat(l1::LU, l2::LU)

   (7)  [1, 2, 3, "D", "E", "F"]
                                Type: List(Union(Integer,String))

FriCAS also has a type "Any". So you could do

%%% (8) -> concat(l1::List(Any), l2::List(Any))

   (8)  [1, 2, 3, "D", "E", "F"]
                                Type: List(Any)


'Any', however, is a weird thing. It can somehow be considered as the all-type, but on the other hand, an element of it is actually a pair, consisting of the value and the type for that value. So it is NOT the same as forgetting about types.

Anyway, I am not sure that you really want to use Any in your program.

But in Maple using op()

L1:=[1,2,3];
L2:=["E","F","G"];
L3:=[ op(L1) , op(L2) ];

           L3 := [1, 2, 3, "E", "F", "G"]

op() also work on any expression,

op(sin(x)+cos(x)+exp(y))
gives
                         sin(x), cos(x), exp(y)

Does Fricas have op()?  whe I did ?op it said no. How does one then extract
all the operands of expression in Fricas?

The sad answer is "no". FriCAS does not have op() that is like in Maple, but that is due to the fact that FriCAS works fundamentally differently.

First, you should know, what the type your "expression" actually is.
Say

  )type on

and the type of your expression will be shown (similar to above).
If it is 'Expression(Integer)' then look at

https://fricas.github.io/api/Expression.html

and check which function could apply. In particular for Expression(Integer) you should understand that it actually is a rational function an many "variables". These variables are called "kernels" (FriCAS type 'Kernel').

You can list all the kernels of your expression by calling

  kernels(expr)

Let us take

%%% (1) -> expr := sin(x)^2 + tan(x)*x^3

         3               2
   (1)  x tan(x) + sin(x)
                       Type: Expression(Integer)
%%% (2) -> kernels expr

   (2)  [tan(x), sin(x), x]
                       Type: List(Kernel(Expression(Integer)))

%%% (3) -> isPlus expr

          3              2
   (3)  [x tan(x), sin(x) ]
                       Type: Union(List(Expression(Integer)),...)

I hope, from here you can get a bit further.

Ralf

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/2e1ecf1b-5ae6-4fc9-915d-9bc0a27ef91e%40hemmecke.org.

Reply via email to