next | previous | forward | backward | up | top | index | toc | Macaulay2 website
ForeignFunctions :: ForeignStructType VisibleList

ForeignStructType VisibleList -- cast a hash table to a foreign struct

Synopsis

Description

To cast a Macaulay2 hash table to a foreign object with a struct type, give the type followed by the hash table, or a list that could be passed to hashTable to create one. The keys should correspond to the keys of the hash table passed to foreignStructType when constructing T.

i1 : mystruct = foreignStructType("mystruct", {"foo" => int, "bar" => double})

o1 = mystruct

o1 : ForeignStructType
i2 : x = mystruct {"foo" => 5, "bar" => pi}

o2 = HashTable{bar => 3.14159}
               foo => 5

o2 : ForeignObject of type mystruct

Use _ to return a single member of a foreign struct.

i3 : x_"foo"

o3 = 5

o3 : ForeignObject of type int32
i4 : x_"bar"

o4 = 3.14159265358979

o4 : ForeignObject of type double

Ways to use this method: