On Tue, Feb 14, 2012 at 09:19:05AM -0500, Bill Page wrote:
> Record does not need SetCategory.  Could you give specific reference from 
> docs?

Click  "Browse -- Record -- Constructor"   in on-line docs:

-------------------------------------------------------
  Domain  Record(a: A, ... b: B)

  a  a selector ...,
  A  a domain of SetCategory
  ...
  b  a selector ...,
  B  a domain of SetCategory.
  ...
-------------------------------------------------------

And I naively presumed that  Any  is not of  SetCategory.
But now, again  Browse -- Any -- domains  reports that it is of 
SetCategory.

> [..] 
> You could try eliminating the 'dom' component of the Record.  The Any
> type already includes it anyway. Perhaps there is also a conflict of
> function names versus tags.
> 
> -----------------------------------------
> ANY1          ==> AnyFunctions1
> SetAnyLexList ==> Record( val : Any, remList : List String)
> 
> )abbrev package FOO Foo
> Foo() : with    p : List String -> SetAnyLexList  ==
>  add
>    p(lexs : List String) : SetAnyLexList ==
>                               [coerce(1) $ANY1(Integer), rest lexs]
> -----------------------------------------
> 
> 
> (2) -> x:=p["a"]
> 
>    (2)  [val= 1,remList= []]
>                                  Type: Record(val: Any,remList: List(String))
> (3) -> x.val
> 
>    (3)  1
>                                                                 Type: Integer
> (4) -> dom(x.val)
> 
>    (4)  (Integer)
>                                                             Type: SExpression


Thank you.
I have missed that `dom' is reserved by the standard library.
I do not know whether this is the reason.

The aim is to parse from  strings  the elements of various domains,
and each such domain is defined only after parsing. For example,

  "(" "Fr" <nInput> <dInput> ")"
  is parsed as  (n/d) : Fraction R,   R : Integral domain,
  R  always occurs concrete, for example, Integer, UPOL(_, Integer) ...,
  R  is found by parsing things to the bottom;

  "(" "UP" "x1" <monsInput> ")"
  is parsed as  f : UnivariatePolynomial("x1" :: Symbol, R) 
  R : CommutativeRing,  R concrete,

  and so on, for several important domain constructors.

1. Now, parsing  "(" "Fr" <nInput> <dInput> ")"  
:
<nInput> is parsed recursively to some  n : R.
<dInput> is parsed recursively to some  d : R.
To form  fr := n/m  the program needs to coerce it to  Fraction R,
where a concrete  R  must by found from the input.
So, I defined that  dParse  returns the target domain as the first 
component of the result:  record  SetAnyLexList.
Thus  dParse(.. <nInput>)  yields some  R  and  n: R,  
and  R pretend IntegralDomain.
Then  dParse (.. <dInput>)  uses this R, because (I thought that) 
knowing a concrete domain helps to parse faster.
And then,  Fraction R  is used to coerce  n/d  to  Fraction D
(otherwise, how to create a fraction from n and d?).
I know too few of Spad.
Is this a reasonable approach? 
At least, it works in the version withe  List Any,  with coercing
SetCategory to Any, etc.
Now, with Record, it must be simpler.

2. Now, you suggest to remove the first in the Record 

and to use the library  dom:  
parse  <nInput>  to  n,  put  R := dom n,  and then use R if needed. 
Right? Is this a reasonable approach? 

Which way is better?  Will  dom(n)  work as needed?
Anyway, I have to try and find out. But an advice makes it faster.

Thanks,

------
Sergei
[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