Post Reply 
Programming puzzles: processing lists!
01-27-2019, 11:49 AM (This post was last modified: 01-27-2019 12:03 PM by pier4r.)
Post: #247
RE: Programming puzzles: processing lists!
Stumbled on an expected behavior

In userRPL having
{ { 1 2 } { 2 3 } { 3 4 } } \GSLIST (sigma list) returns
{ 1 2 2 3 3 4 }

Noticed while I wast trying options to sum sublists of a list.

At the end something like this should be ok.
Code:

  listSumSubList
  \<<
    \<< ADD \>>
    STREAM
  \>>

I'll add it here when the wiki4hp will work for me. http://www.hpmuseum.org/forum/thread-10271.html

Another point is that one has a list of sublists of the same dimension and one would like to know the average value of a particular position across the sublists. Say
{ { 1 2 3 } { 2 3 4 } { 3 4 5} } what is the average value in the 3rd position of the sublists?
So far I thought that having the sum of the sublists and then dividing for the number of lists, then picking the wanted element is the fastest (also in terms of code readability) way to reach the solution. Picking only the k-th element from every sublist and keeping a local sum and then computing the average should be more costly at runtime and in terms of readability.

Wikis are great, Contribute :)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming puzzles: processing lists! - pier4r - 01-27-2019 11:49 AM



User(s) browsing this thread: 1 Guest(s)