On Wed, Oct 19, 2022 at 12:55:54PM -0700, Sid Andal wrote:
> 
> The library function ALGSC assigns the algebra to a particular name/tag:
> 
> Alg := ALGSC(-, -, -, -)
> 
> Is it possible to construct the name dynamically instead of a fixed name,
> like Alg, above?
> 
> In particular, when defining many algebras over the same vec-space,
> I'd like to pick the names in a loop indexing thru an array of names.

It is not clear what you really want.  Above "name" is
'AlgebraGivenByStructuralConstants(...)' with arguments instead of
dots.  The instruction you gave assigns algebra (a type) to a
variable.  This variable is holding a type, which may look
somewhat unusual if you are used to different programming
languages, but otherwise is usual programming language variable.
If you do not want to write instructions with many different
variable names, then you can use usual programming language
solutions: use arrays or lists.  Simple example (using
simpler types than ALGSC) for using array is:

(3) -> a_tab := new(10, Void)$PrimitiveArray(Type)

 LISP output:
UNPRINTABLE
                                                   Type: PrimitiveArray(Type)
(4) -> a_tab(1) := DoubleFloat

   (4)  DoubleFloat
                                                                   Type: Type
(5) -> 1::a_tab(1)

   (5)  1.0
                                                            Type: DoubleFloat

So, you can assign types to array entries, and you can reference
array entries where you need types.  Of course, instend of 1 you
can use different indices, which in case of PrimitiveArray is from
0 up to upper value which in our case is 9 (since we requested
array having 10 elements).

Similar example using a list:

(8) -> l : List(Type) := []

 LISP output:
NIL
                                                             Type: List(Type)
(9) -> l := cons(DoubleFloat, l)

 LISP output:
(UNPRINTABLE)
                                                             Type: List(Type)
(10) -> 1.0::first(l)

   (10)  1.0
                                                            Type: DoubleFloat

Both fit well to use in a loop.

Note: there are significant limitations to what can be done with
types in similar computations.  In particular, you may be forced
to write your code in Spad.

-- 
                              Waldek Hebisch

-- 
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/20221020191810.GA12197%40fricas.math.uni.wroc.pl.

Reply via email to