Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typos #4

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Parameterize! (compile time meta-programming)
# [🔥 With blocks: with my_struct(1) as v](tutorials/with-blocks-for-struct-parametric-minimal-raise.md)
with blocks from struct (parametric/minimal/raise)

# [🏃 (SPEED) Parametric struct through CPU registers](tutorials/parametric-struct-trough-cpu-registers.md)
# [🏃 (SPEED) Parametric struct through CPU registers](tutorials/parametric-struct-through-cpu-registers.md)
the @register_passable decorator

# [🏞️ getattr: dynamic and static struct members](tutorials/getattr-dynamic-and-static-struct-members.md)
Expand All @@ -47,7 +47,7 @@ example: wrap python functions
mojo build program.mojo -D...

# [🕯️ reader.read\[Int32,"swap"\](3) in 45 lines](tutorials/reader-in-few-lines-with-endian-ness.md)
v0.4.0: powerfull magic
v0.4.0: powerful magic

# [🔮 Autotune: optimization made easy](tutorials/autotune-optimize-by-search-and-benchmark.md)
Easy to use
Expand All @@ -62,7 +62,7 @@ when do del get called on instance
# [🏗️ moveinit 💿💿 copyinit 🐿️ takeinit](tutorials/moveinit-copyinit-takeinit.md)
implement in struct: copy of instance, move, taking move

# 🤙 [callbacks trough parameters](tutorials/callbacks-trough-parameters.md)
# 🤙 [callbacks through parameters](tutorials/callbacks-through-parameters.md)
toy markdown generator as an example

# [🌊 256Hz: simd cosine and plot it](tutorials/vectorise-simd-cosine.md)
Expand Down
4 changes: 2 additions & 2 deletions introduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn main() raises:
mylib.print_from_mylib(time.monotonic_ns())
```
### object with small footprint
Object comparable to thoses of Python, Javascript, Ruby, Lua, out of the box.
Object comparable to those of Python, Javascript, Ruby, Lua, out of the box.
```python
#Around 38kb
fn take_object(o: object):
Expand Down Expand Up @@ -87,7 +87,7 @@ fn main():

It can of great help to peoples that need to react to changes in their industry quickly.

It is usefull to be able to explore new ideas without using a lot of time.
It is useful to be able to explore new ideas without using a lot of time.

Before:
```python
Expand Down
6 changes: 3 additions & 3 deletions tutorials/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Parameterize! (compile time meta-programming)
# [🔥 With blocks: with my_struct(1) as v ](with-blocks-for-struct-parametric-minimal-raise.md)
with blocks from struct (parametric/minimal/raise)

# [🏃 (SPEED) Parametric struct through CPU registers](parametric-struct-trough-cpu-registers.md)
# [🏃 (SPEED) Parametric struct through CPU registers](parametric-struct-through-cpu-registers.md)
the @register_passable decorator

# [🏞️ getattr: dynamic and static struct members](getattr-dynamic-and-static-struct-members.md)
Expand All @@ -50,7 +50,7 @@ example: wrap python functions
mojo build program.mojo -D...

# [🕯️ reader.read\[Int32,"swap"\](3) in 45 lines](reader-in-few-lines-with-endian-ness.md)
v0.4.0: powerfull magic
v0.4.0: powerful magic

# [🔮 Autotune: optimization made easy](autotune-optimize-by-search-and-benchmark.md)
Easy to use
Expand All @@ -64,7 +64,7 @@ when do del get called on instance
# [🏗️ moveinit 💿💿 copyinit 🐿️ takeinit](moveinit-copyinit-takeinit.md)
implement in struct: copy of instance, move, taking move

# 🤙 [callbacks trough parameters](callbacks-trough-parameters.md)
# 🤙 [callbacks through parameters](callbacks-through-parameters.md)
toy markdown generator as an example

# [🌊 256Hz: simd cosine and plot it](vectorise-simd-cosine.md)
Expand Down
2 changes: 1 addition & 1 deletion tutorials/autotune-optimize-by-search-and-benchmark.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ In that example, we are optimizing for speed, and will measure it using ```now()
```python
from autotune import autotune, search

#let's grab it to demonstate the autotune
#let's grab it to demonstrate the autotune
from algorithm import vectorize

#to determine the maximum value of an integer
Expand Down
52 changes: 52 additions & 0 deletions tutorials/callbacks-through-parameters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 🤙 callbacks trough parameters
```python
@value
struct markdown:
var content: String

fn __init__(inout self):
self.content = ""

def render_page[f: def()->object](self,file="none"):
self.content = ""
f()

fn __ior__(inout self,t:String):
self.content+=t

var md = markdown()

def readme():
md |= '''
# hello mojo
this is markdown
```python
fn main():
print("ok")
```
'''
footer()

def footer():
md |= '''
> Page generated
'''

def main():
md = markdown()
md.render_page[readme](file="README.md")
print(md.content)
```

output:


# hello mojo
this is markdown
```python
fn main():
print("ok")
```

> Page generated

52 changes: 1 addition & 51 deletions tutorials/callbacks-trough-parameters.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,2 @@
# 🤙 callbacks trough parameters
```python
@value
struct markdown:
var content: String

fn __init__(inout self):
self.content = ""

def render_page[f: def()->object](self,file="none"):
self.content = ""
f()

fn __ior__(inout self,t:String):
self.content+=t

var md = markdown()

def readme():
md |= '''
# hello mojo
this is markdown
```python
fn main():
print("ok")
```
'''
footer()

def footer():
md |= '''
> Page generated
'''

def main():
md = markdown()
md.render_page[readme](file="README.md")
print(md.content)
```

output:


# hello mojo
this is markdown
```python
fn main():
print("ok")
```

> Page generated

The new location is [callbacks through parameters](callbacks-through-parameters.md)
2 changes: 1 addition & 1 deletion tutorials/calling-mojo-functions-in-python.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@



Building a wrapper with all thoses features:
Building a wrapper with all those features:
- [VariadicList](https://docs.modular.com/mojo/stdlib/utils/list.html#variadiclist) for the arguments types
- [@noncapturing](https://docs.modular.com/mojo/changelog.html#week-of-2023-04-10) to keep the global scope clean
- [import_module](https://docs.modular.com/mojo/stdlib/python/python.html#import_module)
Expand Down
2 changes: 1 addition & 1 deletion tutorials/env-argv-param_env-for-parameters.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
```param_env```: for alias, available at compile time

## param_env
They are retreived when mojo build the program.
They are retrieved when mojo build the program.

So they can be used to do compile-time logic.

Expand Down
4 changes: 2 additions & 2 deletions tutorials/getattr-dynamic-and-static-struct-members.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ struct PackageHelper:
def __getattr__(inout self,name:StringLiteral) ->PythonObject:
return self.my_package.__getattr__(name)
```
The ```__getattr__()``` implementation is quite small, but is powerfull:
The ```__getattr__()``` implementation is quite small, but is powerful:

If a struct do not define a requested attribute, it will call that function and pass the name of it.

Expand Down Expand Up @@ -103,7 +103,7 @@ def main():
- temp_value = PythonObject(1.0)
- temp_value is of PythonObject type
- temp_value = 1.5
- instanciated by PythonObject again
- instantiated by PythonObject again


```try:``` and ```except:``` blocks can be placed in both ```def()``` and ```fn()``` functions
Expand Down
4 changes: 2 additions & 2 deletions tutorials/lists-of-structs-magic-operators-pre-lifetimes.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ More about it can be read on the website of mojo aswell.
- documentation in [Roadmap: shap edges](https://docs.modular.com/mojo/roadmap.html#sharp-edges)
- ```__get_address_as_lvalue(address) = other_instance ```
- will call ``` __del__()``` on existing value at the address (cannot contains nothing)
- get an copy instance trough ```__copyinit__```:
- get an copy instance through ```__copyinit__```:
- ```var x = __get_address_as_lvalue(address)```


Expand Down Expand Up @@ -142,4 +142,4 @@ see the [ASAP](https://docs.modular.com/mojo/programming-manual.html#behavior-of

> one revision on Nov 6 2023

[contribute corrections](/contribute.md)
[contribute corrections](/contribute.md)
2 changes: 1 addition & 1 deletion tutorials/make-test-builds-using-a-custom-flag.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# 🏳️ make test builds using a custom flag
In mojo, it is possible to do it trough programming!
In mojo, it is possible to do it through programming!

For serious testing, the assert functions provided mojo standard library should be used instead.

Expand Down
2 changes: 1 addition & 1 deletion tutorials/memory-asap-and-destructor-behaviours.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

##### *this page is a community effort and may contains errors. please contribute any corrections if needed.*

It's wonderfull because mojo free memory as soon as possible.
It's wonderful because mojo free memory as soon as possible.

Lifetimes is on the roadmap: [Ownership and Lifetimes](https://docs.modular.com/mojo/roadmap.html#ownership-and-lifetimes).

Expand Down
12 changes: 6 additions & 6 deletions tutorials/moveinit-copyinit-takeinit.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 🏗️ moveinit 💿💿 copyinit 🐿️ takeinit
> using v0.4.0

Let's have a look at theses features trough an example,
Let's have a look at theses features through an example,

they looks like this :

Expand All @@ -13,11 +13,11 @@ they looks like this :
- original is owned, ```__del__``` will never be called on it
- original can't be used in the program anymore
- **^ transfer suffix** is used to call moveinit
- usefull for making sure an instance don't have copies thus is unique
- useful for making sure an instance don't have copies thus is unique
- ```fn __takeinit__(inout self, inout original: Self)```
- original can be modified
- ```__del()__``` will get called on original on last use
- usefull to affect a conditional in ```__del__()```
- useful to affect a conditional in ```__del__()```
- example: don't free pointer if self.dontfree == true

### The illustration:
Expand Down Expand Up @@ -102,7 +102,7 @@ we moved original to still_original and took original as ```owned```:

 

## why moveinit is important and usefull
## why moveinit is important and useful
We can make sure that an instance have no copies in the program,

when we to pass it to a function, the function could return it:
Expand Down Expand Up @@ -145,7 +145,7 @@ fn __takeinit__(inout self, inout original: Self)
```
- original can be modified
- ```__del()__``` will get called on original on last use
- usefull to affect a conditional in ```__del__()```
- useful to affect a conditional in ```__del__()```
- example: don't free pointer if self.dontfree == true

### Example
Expand Down Expand Up @@ -207,4 +207,4 @@ But with ```__takeinit()__```,original can be modified:

 

> Need further work and help for \_\_takeinit\_\_(), the page will get updated
> Need further work and help for \_\_takeinit\_\_(), the page will get updated
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn main():

# simd instructions:

# a. fill them whith numbers from 0 to 7
# a. fill them with numbers from 0 to 7
numbers = math.iota[DType.uint8,8](0)

# b. x*x for each numbers
Expand All @@ -47,7 +47,7 @@ fn main():

# 🚍 🚍 🛣️ simd in parallel

it is like 4 autobus advancing on 4 seperate highway lanes toward a destination.
it is like 4 autobus advancing on 4 separate highway lanes toward a destination.

they reach destination more or less at the same time and in the same amount of time it would have taken with only one autobus in a single highway lane. (single core, non multi-core)

Expand Down
4 changes: 2 additions & 2 deletions tutorials/parameters-alias-struct-parameter-deduction.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Let's learn how to parametrize!

That example also covers "Struct parameters deduction".

It is very usefull, try to practice playing with it in order to remember and understand it.
It is very useful, try to practice playing with it in order to remember and understand it.

Notice how the deduction "works its way" up the struct and fill the blanks.

Expand Down Expand Up @@ -253,7 +253,7 @@ fn main():

---
#### Parameter default value and keyword
Parameters can have default values and be refered by keyword.
Parameters can have default values and be referred by keyword.

The ones that have default values need to be defined after the ones that don't (order).
- ```example[no_default:Int, got_default:Int=1]```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct naive_register_tuple[T_FIRST:AnyType,T_SECOND:AnyType]:
var first:T_FIRST
var second:T_SECOND

#need to return Self type, wich is naive_register_tuple
#need to return Self type, which is naive_register_tuple
fn __init__(arg_one:T_FIRST,arg_two:T_SECOND) -> Self:

var tmp = Self{
Expand All @@ -49,7 +49,7 @@ struct naive_register_tuple[T_FIRST:AnyType,T_SECOND:AnyType]:

fn main():

#explicitely specify the types:
#explicitly specify the types:
var tmp = naive_register_tuple[Bool,Bool](True,True)

#with struct parameter deduction:
Expand Down Expand Up @@ -90,7 +90,7 @@ Examples:

### register_passable

> Thoses values will be passed trough CPU registers
> Those values will be passed trough CPU registers

The ```__init__()``` function looks different than usual, it returns ```Self```.

Expand All @@ -102,11 +102,11 @@ register_passable is slightly different in that aspect.
### trivial
It means that we can get a copy of a value and that we can move it.

There is no need to implement thoses methods. (```copyinit```, ```moveinit```, ```takeinit```, ```del```)
There is no need to implement those methods. (```copyinit```, ```moveinit```, ```takeinit```, ```del```)

Think about it, theses are just "sequences of bytes" that can be copied as they are from one register to another.

A way to think about thoses is in term of "bags of bits" (see mojo documentation).
A way to think about those is in term of "bags of bits" (see mojo documentation).



Expand Down
Loading