Skip to content

Instantly share code, notes, and snippets.

View Moosems's full-sized avatar
👨‍💻
Still programming!

Moosems Moosems

👨‍💻
Still programming!
  • United States
  • 02:58 (UTC -04:00)
View GitHub Profile
@thatstoasty
thatstoasty / stdin.mojo
Created August 14, 2024 20:30
Reading from stdin using mojo and recreating the Python input function
from builtin.io import _dup
from memory import UnsafePointer, memcpy
from sys import os_is_windows, external_call
@value
struct stdin:
"""A read only file handle to the stdin stream."""
alias file_descriptor = 0
@Moosems
Moosems / calculator.mojo
Last active September 29, 2023 21:14
Cool Mojo Calculator
# Cool Mojo Calculator
from types.input.input import input
def is_float(given_string: String) -> Bool:
# Given a string, go through each character and check if it is a digit or a dot.
for i in range(len(given_string)):
# If the character is a dot, check if it is the last character in the string.
if given_string[i] == "." and i == len(given_string) - 1:
return False
# Normal case, check if the character is a digit or a dot.