x = average(myArray, column=3)If we wanted to get the average from a rectangular section of an array, we may have something like:
x = average(myArray, columns=3:8, rows=2:5)The "traditional" way to do this would resemble:
sum = 0 count = 0 for column = 3 to 8 ...for row = 2 to 5 ......sum = sum + myArray[row, column] ......count = count + 1 ...end for end for average = sum / count(Dots added to prevent TabMunging) An optimizer would know that it could take an array-oriented language version and assign different rows or columns to multiple processors to divide up the workload. With the "traditional" approach, the optimizer may have a harder time because it does not know whether the order of the calculation makes a difference or not without complex analysis. Our "average" function knows this by definition. Typical features found in CollectionOrientedProgramming languages or APIs:
A <- A + A[2,3]In PliLanguage, the equivalent statement would be executed one element at a time, with the rightmost dimension cycling the. APL broke new ground (and simplified things considerably) by treating arrays as single objects. -- PaulMorrison
-----Well for a start is this a new concept or a novel and relatively unknown name for an old concept? Also arrays and vectors are homogeneous do you claim that CollectionOrientedProgramming is a generalization of this concept to cells of arbitrary complexity? What does it mean to process implicitly over a tree of trees of type < real , int, string>? How do you handle the case of <int, real, string> ,< real,int, string> < null, null,real> for example? Do you intend to constrain the collection types at all. If so how, if not how do you plan to define correct semantics? Vectors and Arrays answer to the linear algebra -- do you or anyone else have a programing model in mind. I have no issue with implicit looping and lang based on them. Awk is a good thing. And APL does a very good job at being APL. I like functional languages as well, But I do not see how this can be generalized to the extent this comment seems to imply. -ANNON
x <- c(1,2,3)What does x contain?
1 2 3And what do we need to do to multiply each item by 2? (Note: the lack of a for loop)
x <- x * 2What does x contain now?
2 4 6-- Mike Judge This is the part where the Lisper pops in and shows an EssExpression implementation of such... EuphoriaLanguage has similar collection effects:
x = {1,2,3} x = x * 2 -- x is now {2,4,6}and treats strings in the same way:
puts( 1, "LOWERCASE" + 32 ) -- displays the word "lowercase"Operators can be applied to nested hierarchical collections containing a mixed set of scalars and sequences, in which case it could also be seen as implicit recursion/traversal of the hierarchy tree. The list monad (OnMonads) in HaskellLanguage works along similar lines, although it must be explicitly invoked:
f = do x <- [1, 2, 3] return (x * 2) f == [2, 4, 6]In general, this monad is more useful when multiple lists are to be used, in which case the CartesianProduct is produced:
g = do x <- [1, 2, 3] y <- [4, 5, 6] return (x * y) g == [4,5,6,8,10,12,12,15,18]