On 28.05.2018 21:31, Riccardo GUIDA wrote:
> Hi, I have a couple of questions.
>
> 1)
> are dependent types supported by the interpreter (input files)?
Yes, e.g. Matrix(Integer) is a DT.
>
> I feel like n in the image type of defFun below is really understood ...
>
> (1) -> )read dep-types
>
> defFun(n:PositiveInteger):SquareMatrix(n, Integer) == sample$SquareMatrix(n,
> Integer)
>
>
> Cannot convert the value from type Symbol to NonNegativeInteger .
>
a) There is a typo: use sample() instead of sample
b) You can't use local variables in type expressions
c) You may use global variables in .input files - so you can run it with
different parameter values, or alternatively use "macros".
Ex.
PI ==> PositiveInteger
MI ==> Matrix Integer
SQM ==> SquareMatrix
INT ==> Integer
m:NNI:=10 -- global var
f(n:PI):SQM(m,INT) == n*sample()$SQM(m,INT)
-- gives m x m matrix
OTOH, using macros:
foo(n:PI):Matrix(INT) == zero(n,n)$MI
M(k) ==> squareMatrix foo(k)
(1) -> M(5)
Compiling function foo with type PositiveInteger -> Matrix(Integer)
+0 0 0 0 0+
| |
|0 0 0 0 0|
| |
(1) |0 0 0 0 0|
| |
|0 0 0 0 0|
| |
+0 0 0 0 0+
Type: SquareMatrix(5,Integer)
(1) -> )show SquareMatrix
SquareMatrix(ndim: NonNegativeInteger,R: Join(SemiRng,AbelianMonoid)) is a
domain constructor
Abbreviation for SquareMatrix is SQMATRIX
This constructor is not exposed in this frame.
...
>
>
> 2)
> Is there an assign function such that
>
> assign(x,z)
>
> would be equivalent to the statement x:= z ?
>
>
> thanks for any hint, ric
>
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.