On 07/04/2016 11:31 AM, oldk1331 wrote:
>> With your suggestion of last: (SomeAggregate X, NNI) -> X, then
>> with last([1,2,3,4,5,6],2) would I expect 5 or 4?
> 
> We can define last(a,n) == first tail(a, n)

I think it would make sense that "tail" and "last" and # and ... are
only implemented if % has finiteAggregate.

Oh, but wait. "tail" is not what one would think.

   tail : % -> %
      ++ tail(u) returns the last node of u.
      ++ Note: if u is \spad{shallowlyMutable},
      ++ \spad{setrest(tail(u), v) = concat(u, v)}.

That looks like a technical definition meaning that (since internally
even lists with a loop are stored with finitely many objects) one gets a
link to the last object. However, if u is a structure of 2 elements that
loop, i.e., the first element points to the second and the second back
to the first, then the note is definitely wrong.


>> Ooops... I just looked into UnaryRecursiveAggregate. Such a structure
>> can have loops. What would be the last element of a looped list that is
>> [1,2,1,2,1,2,1,2,1,2,...].
> 
> Currently # for a cyclic list will hang.  Do you can that a problem?

Since I didn't have need, I don't even know how to (officially) create a
List that has a cycle. And if this is possible by the exported
interface, then I don't understand what finiteAggregate
(http://fricas.github.io/api/finiteAggregate) actually means.
Is it meant to mean finite in the sense of finitely many stored objects
or finite as a mathematical structure.
A list that repeats 1,2,1,2,... is not finite for my taste even if it
can be stored a list with one cycle, so it should not be a List(X).

Ralf

-- 
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.

Reply via email to