Hi Ralf, thanks.
Perhaps I should have mentioned the origin: even with quoting and type
hints it's quite error-prone.
I'm wondering if there is a possibility to limit (time) the process?
BTW the function name doesn't matter (foo instead of display etc.)
)abbrev domain IDXOBJ IndexedObject
IndexedObject() : Exports == Implementation where
OF ==> OutputForm
LOF ==> List OF
INT ==> Integer
SYM ==> Symbol
CTOF ==> CoercibleTo OutputForm
CTEX ==> ConvertibleTo TexFormat
Exports == Join(CTOF, CTEX) with
construct : List Integer -> %
display : (%, Symbol, List Symbol) -> OutputForm
coerce : List Integer -> %
Implementation == add
-- [n1,n2,...]; nj=+-1 ; +1:upper, -1:lower
Rep := List Integer
construct(x:List Integer):% ==
empty? x => x
x1:List Integer:=[abs n for n in x]
x1 = [1 for m in 1..#x1] => x@%
error "Expecting [+- 1, +- 1, +- 1, +- 1,...]"
coerce(x:List Integer):% ==
empty? x => x
x1:List Integer:=[abs n for n in x]
--x1 = expand(1..#x1) => x@%
x1 = [m for m in 1..#x1] => [sign n for n in x]@%
error "Expecting [+- 1, +- 2, +- 3, +- 4,...]"
label(x:%):List Integer == [n*x.n for n in 1..#x]
display(x:%,b:Symbol,il:List Symbol):OF ==
#x ~= #il => error "err ..."
U:(INT,SYM)->OF:= (m,s)+->if m>0 then outputForm(s)$OF else
hspace(1)$OF
L:(INT,SYM)->OF:= (m,s)+->if m<0 then outputForm(s)$OF else
hspace(1)$OF
UX:OF:=hconcat [U(n,il.(abs n)) for n in label x]
LX:OF:=hconcat [L(n,il.(abs n)) for n in label x]
bas:OF:=outputForm(b)$OF
scripts(bas, [LX,UX])$OF
coerce(x:%):OF ==
S:List Symbol:=[string(n)$String::Symbol for n in 1..#x]
display(x,'X,S)
---
IndexedObject is now explicitly exposed in frame initial
IndexedObject will be automatically loaded when needed from
/Users/kfp/Desktop/work/spad/IDXOBJ.NRLIB/IDXOBJ
(2) -> display(J,'Q,['a,'b,'c,'d,'e,'f])
There are 1 exposed and 0 unexposed library operations named display
having 3 argument(s) but none was determined to be applicable.
Use HyperDoc Browse, or issue
)display op display
to learn more about the available operations. Perhaps
package-calling the operation or using coercions on the arguments
will allow you to apply the operation.
Cannot find a definition or applicable library operation named
display with argument type(s)
Variable(J)
Variable(Q)
List(OrderedVariableList([a,b,c,d,e,f]))
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.
(2) -> J:=[1,2,-3,4,-5,-6]::IDXOBJ
12 4
(2) X
3 56
Type:
IndexedObject
(3) -> display(J,'Q,['a,'b,'c,'d,'e,'f])
ab d
(3) Q
c ef
Type:
OutputForm
(4) -> display(K,Q::Symbol,['a,'b,'c,'d,'e,'f]@List Symbol)
There are 1 exposed and 0 unexposed library operations named display
having 3 argument(s) but none was determined to be applicable.
Use HyperDoc Browse, or issue
)display op display
to learn more about the available operations. Perhaps
package-calling the operation or using coercions on the arguments
will allow you to apply the operation.
Cannot find a definition or applicable library operation named
display with argument type(s)
Variable(K)
Symbol
List(Symbol)
Perhaps you should use "@" to indicate the required return type,
or "$" to specify which version of the function you need.
(4) -> -- takes 50s :(
On Monday, 6 January 2020 11:20:48 UTC+1, Ralf Hemmecke wrote:
>
> Indeed it's a problem with conversion. The following returns quickly
>
> dsp(x, ['a,'b,'c,'d,'5,'5,'t,'s,'r,'s,'s,'s,'s])
>
> The problem seems to be that you have the number 5 in your list.
> If you evaluate [a,b,c,d,5,5,t,s,r,s,s,s,s] in a session, you get
>
> (18) -> [a,b,c,d,5,5,t,s,r,s,s,s,s]
>
> (18) [a, b, c, d, 5, 5, t, s, r, s, s, s, s]
> Type: List(Polynomial(Integer))
>
> You give FriCAS the task to figure out how to convert from Polynomial
> Integer to Symbol.
>
> (19) -> p := (a::Polynomial(Integer))
>
> (19) a
> Type: Polynomial(Integer)
> (20) -> p::Symbol
>
> (20) a
> Type: Symbol
> (21) -> q := (5::Polynomial(Integer))
>
> (21) 5
> Type: Polynomial(Integer)
> (22) -> 5::Symbol
>
> Cannot convert the value from type PositiveInteger to Symbol .
>
> Ralf
>
>
> > foo.spad
> > )abbrev domain FOO foo
> > foo() : Exports == Implementation where
> > Exports == with
> > mkfoo : Integer -> %
> > dsp: (%,List Symbol) -> OutputForm
> > Implementation == Integer add
> > Rep := Integer
> > mkfoo(x:Integer) == x@%
> > dsp(x:%,il:List Symbol):OutputForm ==
> > l:List OutputForm := [outputForm(s)$OutputForm for s in il]
> > first l
> >
> > Example: dsp(5,[a,b,c,d,s,r])
> >
> > foo.input:
> > dsp(x:Integer,il:List Symbol):OutputForm ==
> > l:List OutputForm := [outputForm(s)$OutputForm for s in il]
> > first l
> >
> > Example: dsp(5,[a,b,c,d,5,5,t,s,r,s,s,s,s]) (killed after 1h)
> >
> > Thanks
> > Kurt
> >
>
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/fricas-devel/978ead03-f9cf-441d-a907-8201d7e9f270%40googlegroups.com.