update readme, docs, site, and version to 0.2.0.

This commit is contained in:
mark
2023-06-04 21:59:38 +02:00
parent db0be51fa4
commit 8c6f8c17f1
6 changed files with 28 additions and 15 deletions

View File

@@ -9,7 +9,7 @@
<section class="container">
<section class="container_left2 code-border">
<pre><code class="mers-code-snippet">
fn get_number_input(question string) {<br> println(question)<br> input := read_line()<br> // try to parse to an int, then a float.<br> in := match {<br> input.parse_int() n n<br> input.parse_float() n n<br> }<br> // 'in' has type int/float/[] because of the match statement<br> switch! in {<br> int/float in in<br> // replace [] with an appropriate error before returning<br> [] [] Err: "input was not a number."<br> }<br> // return type is int/float/Err(string)<br>}<br><br>answer := get_number_input("What is your favorite number?")<br><br>answer.debug() // type: int/float/Err(string)<br>// switch can be used to branch based on a variables type.<br>// switch! indicates that every possible type must be handled.<br>switch! answer {<br> int num {<br> println("Entered an integer")<br> num.debug() // type: int<br> }<br> float num {<br> println("Entered a decimal number")<br> num.debug() // type: float<br> }<br> Err(string) [] println("Input was not a number!")<br>}<br><br>// wait one second<br>sleep(1)<br><br><br>// function that returns an anonymous function (function object).<br>// anonymous functions can be used as iterators in for-loops.<br>fn square_numbers() {<br> i := 0<br> () {<br> &amp;i = i + 1<br> i * i<br> }<br>}<br><br>for num square_numbers() {<br> println(num.to_string())<br> // once num is greater than 60, the loop stops.<br> num.gt(50)<br>}<br></code></pre>
fn get_number_input(question string) {<br> println(question)<br> input := read_line()<br> // try to parse to an int, then a float.<br> in := match {<br> input.parse_int() n n<br> input.parse_float() n n<br> }<br> // 'in' has type int/float/[] because of the match statement<br> switch! in {<br> int/float in in<br> // replace [] with an appropriate error before returning<br> [] [] Err: "input was not a number."<br> }<br> // return type is int/float/Err(string)<br>}<br><br>answer := get_number_input("What is your favorite number?")<br><br>answer.debug() // type: int/float/Err(string)<br>// switch can be used to branch based on a variables type.<br>// switch! indicates that every possible type must be handled.<br>switch! answer {<br> int num {<br> println("Entered an integer")<br> num.debug() // type: int<br> }<br> float num {<br> println("Entered a decimal number")<br> num.debug() // type: float<br> }<br> Err(string) [] println("Input was not a number!")<br>}<br><br>// wait one second<br>sleep(1)<br><br>// function that returns an anonymous function (function object).<br>// anonymous functions can be used as iterators in for-loops.<br>fn square_numbers() {<br> i := 0<br> () {<br> &amp;i = i + 1<br> i * i<br> }<br>}<br><br>for num square_numbers() {<br> println(num.to_string())<br> // once num is greater than 60, the loop stops.<br> num.gt(50)<br>}<br></code></pre>
</section>
<section class="container_right">
<image