Post Reply 
Programming puzzles: processing lists!
01-28-2019, 08:16 PM (This post was last modified: 01-28-2019 08:17 PM by John Keith.)
Post: #256
RE: Programming puzzles: processing lists!
(01-28-2019 07:37 PM)pier4r Wrote:  List transpose? Could you elaborate more with a couple of use cases and/or examples?

Matrix transpose basically swaps rows for columns.

Code:

[[ 1 2 3 ]
 [ 4 5 6 ]
 [ 7 8 9 ]]

becomes

[[ 1 4 7 ]
 [ 2 5 8 ]
 [ 3 6 9 ]]

By "list transpose" I mean the analogous operation for a list of lists:

Code:

{{ 1 2 3 {} 4 5 6 }{ 7 8 9 }}

becomes

{{ 1 4 7 }{ 2 5 8 }{ 3 6 9 }}

You can see that
Code:

\<< AXL DUP LXIL SWAP SIZE LDIST AXL
\>>

does the same thing as the built-in command TRAN.

Though as David pointed out my code in the earlier post was unnecessarily long, I think the ability to transpose lists like one would matrices is generally useful.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Programming puzzles: processing lists! - John Keith - 01-28-2019 08:16 PM



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