How to read args from environment
Hi, I am trying to write a simple program where I would read args from terminal and print them. I found this function in the documentation but well...there is no documentation https://docs.modular.com/mojo/stdlib/sys/arg/argv
I am wondering how is people learning to code in mojo considering documentation is at this level
argv | Modular Docs
argv() -> VariadicList[StringRef]
2 Replies
Good question! here is an example of how to use it https://github.com/modularml/devrel-extras/blob/456c320da398cde08800911586fcf61f2d261551/blogs/2405-max-graph-api-tutorial/mnist.mojo#L84-L88
GitHub
devrel-extras/blogs/2405-max-graph-api-tutorial/mnist.mojo at 456c3...
Contains supporting materials for developer relations blog posts, videos, and workshops - modularml/devrel-extras
Here is an example using it. The gist is that
argv()
returns a VariadicList
so you can index into it, iterate over it, or get the length to work with the arguments. The docs on VariadicList are here.GitHub
llama2.mojo/llama2.mojo at master · tairov/llama2.mojo
Inference Llama 2 in one file of pure 🔥. Contribute to tairov/llama2.mojo development by creating an account on GitHub.