Array Sum

Problem: sum the elements of an array (empty array returns a "zero" appropriate to the data type of an array element)

Context: show off collection support in your language of choice

Who can play: languages in which arrays know their own bounds (apparently)

Bonus points:

Add your program listing to ArraySumInManyProgrammingLanguages.


Maybe this would be a better gauge than HelloWorld of diversity in languages.

How so? Both are arbitrarily chosen algorithms expressed in your LanguageOfChoice. The diversity of the expression can come from different languages or different implementations in the same language. This example will definitely show more of the chosen language because (in most cases) summing an array will require flow-control. This does not mean that writing a web browser is a better gauge than HelloWorld simply because it exposes more features of the chosen language. HelloWorld is simple: it interacts with the user in the most basic way possible. Adding complexity to the program only increases apparent diversity.

Quick check to keep the implementations equivalent:

See also: TpkAlgorithm, DotProductInManyProgrammingLanguages, HelloWorldInManyProgrammingLanguages


EditText of this page (last edited November 29, 2004) or FindPage with title or text search