Opened 14 years ago

Closed 14 years ago

#394 closed enhancement (duplicate)

flatten command for nested lists

Reported by: mhampton Owned by: mhampton
Priority: minor Milestone:
Component: basic arithmetic Keywords: lists, flatten
Cc: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges


The attached file has a candidate function for a flatten command. The default types to flatten are lists and tuples, but more can be added. Here are the examples from my EXAMPLES section:

        sage: flatten([[1,1],[1],2])
        [1, 1, 1, 2]
        sage: flatten((['Hi',2,vector(QQ,[1,2,3])],(4,5,6)))
        ['Hi', 2, (1, 2, 3), 4, 5, 6]
        sage: flatten((['Hi',2,vector(QQ,[1,2,3])],(4,5,6)),ltypes=(list, tuple, sage.modules.vector_rational_dense.Vector_rational_dense))
        ['Hi', 2, 1, 2, 3, 4, 5, 6]

Change History (1)

comment:1 Changed 14 years ago by mhampton

  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.