structure and restructure

Let your imagination run wild

structure and restructure

PostPosted by drab » Tue Oct 21, 2014 9:59 am

This is a little far out, but I would be interested to hear any opinions or feedback about it ...

There could be 2 new primitive functions:

monadic structure, analogous to shape
dyadic restructure, analogous to reshape

While character rho does functions shape and reshape, character rho underscore could do the new functions structure and restructure.

The new functions handle general nested arrays.

Structure takes any argument, and returns a possibly nested array of integers, which might be used to rebuild the original array.

If the argument is not nested, then structure and restructure do the same thing as shape and reshape. But it's different if the argument is nested. Shape and reshape only work on the top level. Structure and restructure work on all levels.

It is always true that:

a ≡ (structure a) restructure ∊a

The key point here is that all of the original structure of an array is lost when you string it out by using ∊ on it. But you might have to do that in order to process it efficiently.

Among many other things, these new functions could be used to efficiently process individual elements of an arbitrarily nested array in a particular order, like we have been discussing in the "much faster sequences of primes" forum.

I have written a couple of defined functions that implement structure and restructure.
drab
 
Posts: 295
Joined: Thu Oct 09, 2014 6:23 am

Re: structure and restructure

PostPosted by drab » Tue Oct 21, 2014 10:21 am

I meant to open this discussion in New Primitive Functions instead of in New Primitive Operators.

But I was thinking of using the new functions in a new operator.
drab
 
Posts: 295
Joined: Thu Oct 09, 2014 6:23 am


Return to New Primitive Operators

Who is online

Users browsing this forum: No registered users and 1 guest

cron