On Sun, May 29, 2022 at 05:18:54PM +0200, Ralf Hemmecke wrote:
> Something weird happens.
> When I compile
>
> aggcat.spad from my "fix/elt-universalsegment" branch.
>
> https://github.com/hemmecke/fricas/commits/fix/elt-universalsegment
>
> https://github.com/hemmecke/fricas/blob/fix/elt-universalsegment/src/algebra/aggcat.spad#L2363
>
> It start like this...
>
> elt(x : %, seg : UniversalSegment(Integer)) ==
> dbgPrint("seg", seg)
> lo := low(seg) - minIndex x
> dbgPrint("low seg", low(seg))
> dbgPrint("hig seg", high(seg))
> dbgPrint("inc seg", incr(seg))
>
> then I get the following output
>
> (80) -> elt(l, (5..) by 5)
> [:> , seg, 5 .. by 5]
> [:> , low seg, 5]
> [:> , inc seg, 5]
>
> (80) [5, 10, 15, 20]
> Type: List(Integer)
>
> which is OK.
>
> But look at the stepsize here. Why is it 1 and not 5?
>
> (81) -> elt(l, (5..14) by 5)
> [:> , seg, 5 .. 14]
> [:> , low seg, 5]
> [:> , hig seg, 14]
> [:> , inc seg, 1]
>
>
> (82) -> u
>
> (82) 4..18 by 3
> Type: Segment(PositiveInteger)
> (83) -> incr u
>
> (83) 3
> Type: PositiveInteger
> (84) -> l(u)
> [:> , seg, 4 .. 18]
> [:> , low seg, 4]
> [:> , hig seg, 18]
> [:> , inc seg, 1]
>
Using your code and doing:
s := ((5..14) by 5)@UniversalSegment(Integer)
elt(l, s)
I get expected result. So your code seem to be working OK.
AFAICS 'coerce' between Segment and UniversalSegment
drops increment:
coerce(sg : Segment S) : % == segment(low(sg), high(sg))
Probably should just write:
coerce(sg : Segment S) : % == sg
--
Waldek Hebisch
--
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/20220529170721.GA22458%40fricas.math.uni.wroc.pl.