Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
44 views

I'm investigating the method reduce_bit_count() from Mojo's SIMD API. According to the documentation: Returns the total number of bits set in the SIMD vector. I expected the following behavior: 3 ...
Daniel's user avatar
  • 8,775
0 votes
0 answers
47 views

sort() can be used on lists of integers without further ado. But if I define my own type, which trait shall I implement on it so that lists made of it can be sorted? @value struct MyStruct(...
Thomas Hügel's user avatar
2 votes
1 answer
96 views

I cannot use the Mojo dependency called lightbug_http in a fresh Mojo project. magic init hello_web --format mojoproject cd hello_web magic shell Printing «Hello world» works fine. Then I add https://...
Thomas Hügel's user avatar
0 votes
1 answer
103 views

I am new to Mojo and just started learning the language. I am practicing some code on my Jupyter notebook in my Mac mini. My Mojo version is 24.4.0 CASE1: The below simple code for ListLiterals gives ...
dig_123's user avatar
  • 2,398
1 vote
1 answer
527 views

How can I implement asynchroneous code in mojo (using async etc.)? In the Changelog, I find the following example (slightly adjusted): async fn add_three(a: Int, b: Int, c: Int) -> Int: return ...
Samufi's user avatar
  • 2,740
3 votes
0 answers
595 views

I am setting up a test environment to try the MOJO language in my Windows 11 Pro laptop (V 10.0.22631 Build 22631). Since MOJO doesn't have a Windows SDK available (yet), I installed WSL2 using ...
diagonjope's user avatar
1 vote
0 answers
31 views

I'm trying to write a solution to a problem I found online using Mojo. The problem is a graph theory related so I wanted to implement the data structure by hand to get more familiar with the language. ...
Ethan Harness's user avatar
1 vote
1 answer
131 views

The code below fails. fn greet(n: Bool) -> String: return "Hello, 2!" fn greet(name: String) -> String: return "Hello, " + name + "!" fn main(): ...
Alex Craft's user avatar
  • 15.8k
0 votes
1 answer
75 views

I have this code : trait State: fn to_string(self) -> String: ... struct StateTtt(State): fn __init__(inout self): pass fn to_string(self) -> String: ...
danilo_lr's user avatar
0 votes
1 answer
143 views

I would like to use eval() for validation of short function synthesis. The search space may be fairly large, e.g. more than a million different functions. Functions will be synthesized as a string ...
Paul Jurczak's user avatar
  • 8,630
0 votes
1 answer
498 views

I've just started learning Mojo, following the documentation to get started. I've run into a problem with importing the Python module numpy. Below is the code I am using which is taken from the ...
awscy's user avatar
  • 27
0 votes
2 answers
129 views

I want to implement a class with a property whose type I can change globally at compile time. For example, let ID_TYPE = Int @value struct MyStruct: var a: ID_TYPE However, let seems not to be ...
Samufi's user avatar
  • 2,740
0 votes
1 answer
182 views

I have a python module : myScript.py. Normally, I run it like this python3 myScript.py -i example.jpg I want to pass this argument to this python modules's main function from python import Python fn ...
Justin's user avatar
  • 67
0 votes
1 answer
225 views

I've installed mojo on my compute : and went to ran the code 'nano__.zprofile' previously when downloading modular/mojo I ve got network issue, couple of times so I've done it multiple times Now when ...
SRINIVASA-ABHIRAM's user avatar
1 vote
1 answer
211 views

As most Mac users, I have two separate versions of python on my machine: The one installed by Apple (version 3.9 in /usr/bin) and one installed via Homebrew (version 3.11 in /opt/homebrew/bin). I've ...
volkerschulz's user avatar
  • 2,212
1 vote
2 answers
492 views

I have a Mojo struct with the following initialiser: fn __init__(inout self, value: String): """Constructor.""" self.value = value.lower() If I have ...
Jason Coulls's user avatar
2 votes
1 answer
352 views

I'm trying to run mojo in VScode, however pressing the run button does absolutely nothing. No errors, no nothing. I can run the file from terminal and it works fine but I would love to use running and ...
Paternostro's user avatar
2 votes
3 answers
362 views

why can't i import python code in mojo from python import Python let np = Python.import_module("numpy") this gives me error /home/kali/hello.mojo:2:30: error: cannot call function that may ...
mehul gautam's user avatar
1 vote
1 answer
1k views

I have some sample Mojo code: fn main(): print("Hello, world!") for i in range(10000): print_no_newline(i) print_no_newline(' ') And I run mojo build test.🔥 And it ...
Tsunami014's user avatar
5 votes
4 answers
2k views

I couldn't find how to do string formatting in Mojo in the docs. I have tried the common Python methods (str.format(), f-strings, % placeholder), but nothing worked out so far. I know Mojo is still a ...
alec_djinn's user avatar
  • 10.9k
0 votes
1 answer
84 views

I tried the below in Jupiter, and it is working fine, But one I tried to use at at file.mojo as: from python import Python # The Python way: `import requests as http` let http = Python.import_module(...
Hasan A Yousef's user avatar
0 votes
1 answer
954 views

I just started to play around with Mojo. I am having a hard time importing modules from the Python standard library even though, according to the examples reported in the quick start guide, importing ...
alec_djinn's user avatar
  • 10.9k
0 votes
2 answers
508 views

How can we run https://huggingface.co/tiiuae/falcon-180B the one of the current best models on mojo lang which is faster than python 35k? When we just copy this: `from transformers import ...
Bitdom8's user avatar
  • 1,482
-1 votes
1 answer
2k views

I am trying to download mojolang from the website https://developer.modular.com/download It says "Install Ubuntu 22.04 for WSL and open it." I tried installing Ubuntu 22.04.2 LTS from the ...
Talha Tayyab's user avatar
  • 30.7k
7 votes
1 answer
423 views

I started exploring the mojo programming language and now I am trying to figure out how to properly use the Tensor module. I can't find how to statically declare the values inside a tensor. For the ...
Blue_Mecha's user avatar
0 votes
1 answer
1k views

from sys import argv fn fibonacci(n: Int) -> Int: if n == 0: return 0 elif n == 1: return 1 return n + fibonacci(n-1) fn main(): var vls: StringRef = argv()[0] ...
Quakumei's user avatar
  • 101
1 vote
1 answer
253 views

A total newbie question. struct Item: var name: StringLiteral fn __init__(inout self): self.name = "Unnamed" fn main(): var dv = DynamicVector[Item]() var it = Item(...
user529327's user avatar
0 votes
2 answers
559 views

I am trying out Mojo by Modular and more specifically having a look at the Mandelbrot.ipynb available here. When running the line np = Python.import_module("numpy") I get the rather odd ...
Ivar Eriksson's user avatar
5 votes
0 answers
459 views

I am trying to create a function that takes in any object and prints it if it is _Printable, and prints "object" otherwise. To do this I am trying to use @paramter if to check the type at ...
Elan-R's user avatar
  • 576
2 votes
1 answer
1k views

mojo version: mojo 0.2.1 (64d14e85) the code: struct MyPair: var first: Int var second: Int # We use 'fn' instead of 'def' here - we'll explain that soon fn __init__(inout self, first:...
raman shariati's user avatar
16 votes
1 answer
11k views

Mojo, a programming language, claims to be 65000x faster than python. I am eager to understand if is there any concrete benchmark data that supports this claim? Also, how does it differ in real world ...
Muneeb's user avatar
  • 1,700
1 vote
1 answer
68 views

Using Mojo's online JupyterLab instance to run Mojo code, I am unable to decode a base64 value which I encoded using mojo itself. Here is my code from base64 print(base64.b64encode("This is a &...
Jesse Sealand's user avatar
0 votes
1 answer
2k views

I am trying to declare a Pandas DataFrame in mojo using a list of data. I have followed the examples seen for importing and using Numpy but declaring a DataFrame is only giving errors. How do I fix ...
Jesse Sealand's user avatar
-2 votes
1 answer
709 views

I'm using WSL. the install command: root@ALL:~# curl https://get.modular.com | MODULAR_AUTH=mut_c38ba851f1854399b827e0293451c24a sh - download process: % Total % Received % Xferd Average ...
raman shariati's user avatar
0 votes
0 answers
162 views

when I switched to WSL(from windows) and ran: curl https://get.modular.com | \ MODULAR_AUTH=###################### \ sh - multiple times the download process stopped within seconds: % Total % ...
raman shariati's user avatar
4 votes
1 answer
1k views

The question is how to pass Mojo function to Python in Python interop? For example, # This is main.mojo from python.python import Python def callback(): return 5 def main(): Python.add_to_path(...
HKTonyLee's user avatar
  • 3,330
3 votes
2 answers
2k views

According to the docs: vectorize vectorize[simd_width: Int, func: fn[Int](Int) capturing -> None](size: Int) Maps a function which is parametrized over a simd_width over a range from 0 to size in ...
George Ogden's user avatar
0 votes
2 answers
157 views

I'm a student. I am currently doing research about how fast Mojo Lang is. I want to run the recursion code, and compare it to python. I decided to write a simple recursion code, and an error occurred. ...
김현준's user avatar
2 votes
1 answer
81 views

The following program tries to store a Thing in a Holder: struct Holder: var thing: Thing fn __init__(inout self, owned thing: Thing): self.thing = thing pass struct Thing: ...
Max Heiber's user avatar
  • 15.7k
5 votes
2 answers
463 views

I am running a piece of code that calculates the factorial in Mojo: fn fact(x:Int): var mul:Int=1 for i in range(1,x+1): mul = mul*i return mul print(fact(7)) But when I run this, ...
Pramey Dongre's user avatar
1 vote
1 answer
284 views

I run the following in the Mojo Plyaground (https://playground.modular.com/) and get an error, what am I doing wrong? struct MyPair[type:AnyType]: var first: type var second: type # We ...
qpit3a's user avatar
  • 13
2 votes
1 answer
3k views

From the available information and docs, Mojo claims to be fully compatible with Python syntax and modules. However, from the Playground notebook, I can't seem to be able to load any module from ...
Raf's user avatar
  • 1,789