On Tue, May 24, 2022 at 12:26:03PM +0200, Ralf Hemmecke wrote:
> I guess
> 1) the "by 2" should not be ignored.
> 2) "2.. by 2" should be counted as a correct expression for a
> UniversalSegment.
> 
> ```
> (12) -> l := [a,b,c,d,e,f,g,h,i,j]
> 
>    (12)  [a, b, c, d, e, f, g, h, i, j]
>                        Type:
> List(OrderedVariableList([a,b,c,d,e,f,g,h,i,j]))
> (15) -> l(2..7)
> 
>    (15)  [b, c, d, e, f, g]
>                        Type:
> List(OrderedVariableList([a,b,c,d,e,f,g,h,i,j]))
> (16) -> l(2..7 by 2)
> 
>    (16)  [b, c, d, e, f, g]
>                        Type:
> List(OrderedVariableList([a,b,c,d,e,f,g,h,i,j]))
> (17) -> l(2.. by 2)
>    There are no library operations named BY having 1 argument(s) though
>       there are 1 exposed operation(s) and 0 unexposed operation(s)
>       having a different number of arguments.

This is parsing issue.

> (17) -> l((2..) by 2)
> 
>    (17)  [b, c, d, e, f, g, h, i, j]
>                        Type:
> List(OrderedVariableList([a,b,c,d,e,f,g,h,i,j]))
> ```
> 
> Clearly, the problem lies here
> https://github.com/fricas/fricas/blob/master/src/algebra/aggcat.spad#L1658
> ```
>    elt(x : %, i : UniversalSegment(Integer)) ==
>        l := low(i) - minIndex x
>        l < 0 => error "index out of range"
>        not hasHi i => copy(rest(x, l::NonNegativeInteger))
>        (h := high(i) - minIndex x) < l => empty()
>        first(rest(x, l::NonNegativeInteger), (h - l +
> 1)::NonNegativeInteger)
> ```
> However, it is not so clear how the stepsize can be taken into account,
> given that a generic implementation should work for finite (List) and
> infinite (Stream) structures.
> 
> The same applies for the delete function.
> 
> Should we rather move that function into the respective domains and
> implement it properly there? Or explicitly forbid (in the ++ docstrng the
> "by n" in the UniversalSegment?

Well there are two possibilities:

1) In generic implementation signal error when 'by' is present
2) add apropriate primitive operation(s) to category and implement
   them in specific domains domains

Signaling error has disadvantage thaty putting restrictions in
documentation adds bulk and distract users ("do this restriction
affects my use case?").  OTOH if users hit undocumented restriction,
they will be dissatisfied.

I am not sure how important is 'elt' with 'by'.  Admitedly, I make
little use of 'elt' with segments, but I consider it an important
feature.  If 'elt' with 'by' is important enough to explicitely
spell out restricition in documentation, then I think it is important
enough to implement properly (without restriction).

-- 
                              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/20220528021928.GA8121%40fricas.math.uni.wroc.pl.

Reply via email to