Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
KajizukaTaichi committed Sep 7, 2024
1 parent 1da8a92 commit bd72bc8
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 18 deletions.
5 changes: 3 additions & 2 deletions docs/lambda.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,12 @@ <h1 class="menu-title">The Document of Pravda Programming Language</h1>
<div id="content" class="content">
<main>
<h1 id="lambda-expression"><a class="header" href="#lambda-expression">Lambda expression</a></h1>
<p>It starts with <code>lambda</code> and surround by parentheses.
<p>It starts with <code>lambda</code> or <code>\</code> and surround by parentheses.
Inside parentheses is split by <code>-&gt;</code>, after is same to function.</p>
<pre><code>lambda(n -&gt; * n 2)
\(n -&gt; * n 2)
</code></pre>
<p>Lambda expression is usually used in function <code>map</code></p>
<p>Lambda expression is usually used in function <code>map</code> etc in iterator.</p>
<pre><code>map (range 10) lambda(n -&gt; * n 2)
</code></pre>

Expand Down
13 changes: 9 additions & 4 deletions docs/lazy.html
Original file line number Diff line number Diff line change
Expand Up @@ -174,14 +174,19 @@ <h1 class="menu-title">The Document of Pravda Programming Language</h1>
<div id="content" class="content">
<main>
<h1 id="lazy-evaluation"><a class="header" href="#lazy-evaluation">Lazy evaluation</a></h1>
<p>If you want to do lazy evaluation, prefix <code>@</code> to the expression.
function <code>eval</code> to evaluate it.</p>
<p>If you want to do lazy evaluation, prefix <code>lazy</code> or <code>@</code> to the expression.</p>
<pre><code>x = @{
+ 1 (input)
};
eval x
y = lazy{
+ 1 (input)
}
</code></pre>
<p>function <code>eval</code> to evaluate it.</p>
<pre><code>eval x
</code></pre>
<p>It's usually used in function <code>if</code> to conditional branches.</p>
<p>It's usually used in function <code>if</code> to conditional branches.
Because, function <code>if</code> needs block as arguments.</p>
<pre><code>for (range 100) lambda(i -&gt; {
i = + i 1;
if (equal 0 (% i 15)) @{
Expand Down
18 changes: 12 additions & 6 deletions docs/print.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,19 @@ <h1 id="foreword"><a class="header" href="#foreword">Foreword</a></h1>
</code></pre>
<p>In this code, the block returns 3. variable "b" defined in the block is not allowed to access in outside.</p>
<div style="break-before: page; page-break-before: always;"></div><h1 id="lazy-evaluation"><a class="header" href="#lazy-evaluation">Lazy evaluation</a></h1>
<p>If you want to do lazy evaluation, prefix <code>@</code> to the expression.
function <code>eval</code> to evaluate it.</p>
<p>If you want to do lazy evaluation, prefix <code>lazy</code> or <code>@</code> to the expression.</p>
<pre><code>x = @{
+ 1 (input)
};
eval x
y = lazy{
+ 1 (input)
}
</code></pre>
<p>function <code>eval</code> to evaluate it.</p>
<pre><code>eval x
</code></pre>
<p>It's usually used in function <code>if</code> to conditional branches.</p>
<p>It's usually used in function <code>if</code> to conditional branches.
Because, function <code>if</code> needs block as arguments.</p>
<pre><code>for (range 100) lambda(i -&gt; {
i = + i 1;
if (equal 0 (% i 15)) @{
Expand Down Expand Up @@ -268,11 +273,12 @@ <h1 id="foreword"><a class="header" href="#foreword">Foreword</a></h1>
</code></pre>
<p>This code returns function that partial applicated by argument <code>a</code> in number 1.</p>
<div style="break-before: page; page-break-before: always;"></div><h1 id="lambda-expression"><a class="header" href="#lambda-expression">Lambda expression</a></h1>
<p>It starts with <code>lambda</code> and surround by parentheses.
<p>It starts with <code>lambda</code> or <code>\</code> and surround by parentheses.
Inside parentheses is split by <code>-&gt;</code>, after is same to function.</p>
<pre><code>lambda(n -&gt; * n 2)
\(n -&gt; * n 2)
</code></pre>
<p>Lambda expression is usually used in function <code>map</code></p>
<p>Lambda expression is usually used in function <code>map</code> etc in iterator.</p>
<pre><code>map (range 10) lambda(n -&gt; * n 2)
</code></pre>

Expand Down
2 changes: 1 addition & 1 deletion docs/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/searchindex.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions src/lambda.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# Lambda expression
It starts with `lambda` and surround by parentheses.
It starts with `lambda` or `\` and surround by parentheses.
Inside parentheses is split by `->`, after is same to function.

```
lambda(n -> * n 2)
\(n -> * n 2)
```

Lambda expression is usually used in function `map`
Lambda expression is usually used in function `map` etc in iterator.

```
map (range 10) lambda(n -> * n 2)
Expand Down
12 changes: 10 additions & 2 deletions src/lazy.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
# Lazy evaluation
If you want to do lazy evaluation, prefix `@` to the expression.
function `eval` to evaluate it.
If you want to do lazy evaluation, prefix `lazy` or `@` to the expression.
```
x = @{
+ 1 (input)
};
y = lazy{
+ 1 (input)
}
```

function `eval` to evaluate it.
```
eval x
```

It's usually used in function `if` to conditional branches.
Because, function `if` needs block as arguments.
```
for (range 100) lambda(i -> {
i = + i 1;
Expand Down

0 comments on commit bd72bc8

Please sign in to comment.