ct
MModular
•Created by ct on 9/28/2023 in #questions
How can I create a Python list to add and remove structs?
I am trying mojo and would like to define a few structs and use a Python like dynamic list. I would like to be able to add and remove structs, iterate over items etc.
9 replies
MModular
•Created by ct on 9/13/2023 in #questions
newbie needs help with error messages
the code:
gives error
what should I do?
20 replies
MModular
•Created by ct on 9/13/2023 in #questions
What kind of list should I use to add struct instances
Example struct:
DynamicVector cannot contain this struct instance because it is no register storable. What other type of list should I use? What would be a sample code for that?
4 replies
MModular
•Created by ct on 9/12/2023 in #questions
How to add an instance of a struct to a DynamicVector
A total newbie question. Example:
struct Item:
var name: StringLiteral
fn init(inout self):
self.name = "Unnamed"
fn main():
var dv = DynamicVectorItem
var it = Item()
dv.push_back(it)
Generates error: invalid call to 'push_back': method argument #0 cannot bind generic !mlirtype to memory-only type 'Item'
I don't understand the error message.
I cannot find in https://docs.modular.com/mojo/programming-manual.html the syntax for this.
Is there an equivalent to c++ vector::emplace(...)?
1 replies