I cannot compile the attached code. Neither foo1! nor foo2!.

How would I have to write it?

Eventually, I would like to pass

  foo1!(t, n)

as a parameter to another function.

Ralf

(1) -> )co /home/hemmecke/scratch/foo.spad
   Compiling FriCAS source code from file
      /home/hemmecke/scratch/foo.spad using old system compiler.
   FOO abbreviates package Foo
------------------------------------------------------------------------
   initializing NRLIB FOO for Foo
   compiling into NRLIB FOO
   compiling local foo : (Matrix
Integer,NonNegativeInteger,Integer,Integer,Integer) -> Matrix Integer
Time: 0.01 SEC.

   compiling local foo1!(: t (Matrix (Integer)))(: n
(NonNegativeInteger)) : (Matrix
Integer,NonNegativeInteger,Integer,Integer,Integer) -> Matrix Integer
****** comp fails at level 3 with expression: ******
error in function (foo1! (: t (Matrix (Integer))) (: n
(NonNegativeInteger)))

(SEQ
 (REPEAT (IN |i| (SEGMENT 1 | << n >> |))
         (LET (|t| |k| |i|)
           (- (|t| |k| |i|) (* |q| (|t| |j| |i|)))))
 (|exit| 1 (|update!| |bm| N |k| |j| |q|)))
****** level 3  ******
$x:= n
$m:= (Integer)
$f:=
((((|q| # #) (|j| # #) (|k| # #) (N # #) ...)
  ((|foo| #) (|#| #) (* #) (+ #) ...)))

   >> Apparent user error:
   final value of index:
   n
    must be an integer

-- 
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 fricas-devel+unsubscr...@googlegroups.com.
To post to this group, send email to fricas-devel@googlegroups.com.
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.
)abbrev package FOO Foo
Foo() : Exports == Implementation where
  Z ==> Integer
  MI ==> Matrix(Integer)
  NNI ==> NonNegativeInteger

  Exports ==> with
      foo1!: (MI, NNI) -> (MI, NNI, Z, Z, Z) -> MI
      foo2!: (MI, NNI) -> (MI, NNI, Z, Z, Z) -> MI
  Implementation ==> add
      foo(bm : MI, N : NNI, k : Z, j : Z, q : Z) : MI ==
          for i in 1..N repeat
              bm(k, i) := bm(k, i) - q*bm(j, i)
          bm

      foo1!(t : MI, n : NNI)(
              bm : MI, N : NNI, k : Z, j : Z, q : Z) : MI ==
          for i in 1..n repeat
              t(k, i) := t(k, i) - q*t(j, i)
          update!(bm, N, k, j, q)

      foo2!(t : MI, n : NNI) : (MI, NNI, k : Z, j : Z, q : Z) -> MI ==
          for i in 1..n repeat
              t(k, i) := t(k, i) - q*t(j, i)
          foo

Reply via email to