CoCoA:Cast

From ApCoCoAWiki

Cast

type conversion

Description

This function returns the value of the expression E after converting

it to type T. If S and T are types with S < T, then casting from S to

T is usually possible.

Example

  L := [[1,2],[3,4]];
  Type(L);
LIST
-------------------------------
  Cast(L,MAT);
Mat([
  [1, 2],
  [3, 4]
])
-------------------------------
  L;  -- L is unchanged; it is still a list.
[[1, 2], [3, 4]]
-------------------------------
  Use Z/(5)[t];
  A := 8;
  A;  -- A has type INT
8
-------------------------------
  Cast(A,POLY);  -- cast as a polynomial, A = -2 since the coefficient
                 -- ring is Z/5Z
-2
-------------------------------

Syntax

Cast(E:OBJECT,T:TYPE):TYPE

Data Types

Shape

Type

Types

   <type>type</type>