Skip to content

How to create a generic list display function in Mojo? #3318

Locked Answered by Lucifer-02
Lucifer-02 asked this question in Q&A
Discussion options

You must be logged in to vote

Another way:

from collections import List

fn printList[type: DType](list: List[Scalar[type]]):
  for e in list:
    print(e[])

def main():
 list = List[Int64](1,4,5,6)
 printList(list)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Lucifer-02
Comment options

Answer selected by Lucifer-02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant