Serge D. Mechveliani wrote:
> 
> 1. How to construct a record?

(1) -> construct(2, true)$Product(Integer, Boolean)

   (1)  [2,true]
                                               Type: Product(Integer,Boolean)
(2) -> [2, true]$Product(Integer, Boolean)

   (2)  [2,true]
                                               Type: Product(Integer,Boolean)
(3) -> construct(2, "abc")$Record(no: Integer, b: String)

   (3)  [no= 2,b= "abc"]
                                          Type: Record(no: Integer,b: String)
(4) -> [2, "abc"]$Record(no: Integer, b: String)

   (4)  [no= 2,b= "abc"]
                                          Type: Record(no: Integer,b: String)
(5) -> [1, 2, 3, 4]

   (5)  [1,2,3,4]
                                                  Type: List(PositiveInteger)
(6) -> construct([1, 2, 3, 4])$PrimitiveArray(Integer)

   (6)  [1,2,3,4]
                                                Type: PrimitiveArray(Integer)
(7) -> [[1, 2, 3, 4]]$PrimitiveArray(Integer)

   (7)  [1,2,3,4]
                                                Type: PrimitiveArray(Integer)
(8) -> construct(2, "abc")@Record(no: Integer, b: String)

   (8)  [no= 2,b= "abc"]
                                          Type: Record(no: Integer,b: String)

Using 'construct' you normally need to specify type which should
be constructed (by default you get a list).  So use $ notation
or @ notation for this (I find $ varinat clearer and more reliable,
I wrote about @ just for complesteness).  You can abbreviate
'construct' just to square brackets.

> "Browse" on  Record  "Constructors"  shows: 
>   "=", coerce, elt, setelt,
>   and shows the denotation  `r.a' 
>   (for selecting a record field, I guess),
>   but it does not show how to initiate a record.
> 
> Then I try
>   makeR(n: Integer) : Record(no: Integer, b: String) ==
>                                          construct(no := n, b := "abc"),
> just by guess.
> Now,            (..) -> makeR 2
> produces
>    (15)  [no= 2,b= "abc"]          Type: Record(no: Integer,b: String)
> 
> -- looks as needed.
> 
> 2. Is   construct(<field-name> := <value>,  ...)
> 
>    an appropriate way to initiate a record?

No.  'no := n' is an assignment and it produces a value (that is
value of n).  In this contex return type of 'construct' is
known (it must be the same as return type of 'makeR') so
this works the same as an example of 'construct' with '@'.
But assignments to field names may fail and are useless
anyway.

> I was lucky to guess of `construct' and of the `:=' syntax for this. 
> But I could not find this by "Browse".
> Where it is written that there exists the instance of `consruct' for 
> Record ?

Oops, this is a bug.  Record is very special and its documentation
is constructed differently than documentation for normal
domains.  I will fix this.

> Generally, it is natural for the documentation to list for each type 
> (domain) _constructor_ which _category instances_ it is provided by 
> the Axiom library
> (may be, doc describes this, I am sorry if I missed it).

Sorry, I do not understand what you wanted to say above.
In browser when you look at domain and click at 'Parents'
you will get categories to which this domain belongs.  If
you look at a category and click on 'Domains' you will get
domains which belong to the category.

Record, Union, Mapping and Enumaration are special -- they
have their own categories which you can not normally see
and info about those categories is not shown in the browser.

-- 
                              Waldek Hebisch
[email protected] 

-- 
You received this message because you are subscribed to the Google Groups 
"FriCAS - computer algebra system" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/fricas-devel?hl=en.

Reply via email to