CoCoA:Cast

From ApCoCoAWiki
Revision as of 10:02, 24 October 2007 by XMLBot (talk | contribs) (pushing XML rev. 1.46, again)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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>