Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Added new things
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinAlavik authored Oct 19, 2023
1 parent 801fadd commit d26c423
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 2 deletions.
100 changes: 100 additions & 0 deletions src/examples.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Plang Documents - Function</title>
<meta name="description" content="More in depth info about using functions and defining them">
<link rel="stylesheet" href="css/colors.css">
<link rel="stylesheet" href="css/main.css">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
</head>
<body>
<div class="body">
<div class="side-bar">
<a href="index.html">
<img
class="icon"
src="https://avatars.githubusercontent.com/u/146694713?s=400&u=4e01b5afefbf7e40641702e5cbdf785ff183fe35&v=4"
alt="P Icon"
/></a>
<ul>
<li><a href="index.html">Introduction</a></li>
<li><a href="getting-started.html">Getting Started</a></li>
<ul>
<li><a href="getting-started.html#installing">Installing</a></li>
<li><a href="getting-started.html#pint-first-time">Running pint for the first time</a></li>
<li><a href="getting-started.html#first-program">Your very first P program!</a></li>
</ul>
<li><a href="variables.html">Variables</a></li>
<ul>
<li><a href="variables.html#defining-variables">Defining Variables</a></li>
<li><a href="variables.html#using-variables">Using Variables</a></li>
</ul>
<li><a href="functions.html">Function</a></li>
<ul>
<li><a href="functions.html#defining-functions">Defining Functions</a></li>
<li><a href="functions.html#using-functions">Using Functions</a></li>
</ul>
<li><a class="current" href="examples.html">Examples</a></li>
<ul>
<li><a href="examples.html#fizz-buzz">Fizz Buzz</a></li>
<li><a href="examples.html#http-server">Simple HTTP Server</a></li>
<li><a href="examples.html#http-request">Simple HTTP Request</a></li>
</ul>
</ul>
</div>
<div class="page-content">
<h1 class="page-title">Examples</h1>
<p>Some simple examples</p>
<h2 id="fizz-buzz">Fizz Buzz</h2>
<pre class="multiCode">
use * from @std.io

Range range = 1..100

every int n in range {
if n % 3 == 0 and n % 5 == 0 {
writeln("FizzBuzz")
} else if n % 3 == 0 {
writeln("Fizz")
} else if n % 5 == 0 {
writeln("Buzz")
} else {
writeln(n)
}
}</pre>
<br>
<h2 id="http-server">Simple HTTP Server</h2>
<pre class="multiCode">
use Server from @http
use * from @std.io

any server = new Server
void fn handle(any req, any res) {
res.send('&lt;h1&gt;Made with love in PLang&lt;/h1&gt;')
}

int port = 8080
writeln("Listening on http://localhost:%{port}")
server.start(port, handle)</pre>
<br>
<h2 id="http-request">Simple HTTP Request</h2>
<pre class="multiCode">
use writeln from @std/io
use request from @http

interface Response {
  () :: any json
}

Response res = request("https://api.sampleapis.com/coffee/hot", {
  method: "GET"
})

writeln(res.json())</pre>
</div>
</div>
</body>
</html>
12 changes: 12 additions & 0 deletions src/functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,23 @@
<li><a href="variables.html#using-variables">Using Variables</a></li>
</ul>
<li><a class="current" href="functions.html">Function</a></li>
<ul>
<li><a href="functions.html#defining-functions">Defining Functions</a></li>
<li><a href="functions.html#using-functions">Using Functions</a></li>
</ul>
<li><a href="examples.html">Examples</a></li>
<ul>
<li><a href="examples.html#fizz-buzz">Fizz Buzz</a></li>
<li><a href="examples.html#http-server">Simple HTTP Server</a></li>
<li><a href="examples.html#http-request">Simple HTTP Request</a></li>
</ul>
</ul>
</div>
<div class="page-content">
<h1 class="page-title">Functions</h1>
<p>Simple introduction to understanding how functions work and how you define them and how you use them</p>
<h2 id="defining-functions">Defining Functions</h2>
<h2 id="using-functions">Using Functions</h2>
</div>
</div>
</body>
Expand Down
10 changes: 10 additions & 0 deletions src/getting-started.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,16 @@
<li><a href="variables.html#using-variables">Using Variables</a></li>
</ul>
<li><a href="functions.html">Function</a></li>
<ul>
<li><a href="functions.html#defining-functions">Defining Functions</a></li>
<li><a href="functions.html#using-functions">Using Functions</a></li>
</ul>
<li><a href="examples.html">Examples</a></li>
<ul>
<li><a href="examples.html#fizz-buzz">Fizz Buzz</a></li>
<li><a href="examples.html#http-server">Simple HTTP Server</a></li>
<li><a href="examples.html#http-request">Simple HTTP Request</a></li>
</ul>
</ul>
</div>
<div class="page-content">
Expand Down
10 changes: 10 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@
<li><a href="variables.html#using-variables">Using Variables</a></li>
</ul>
<li><a href="functions.html">Function</a></li>
<ul>
<li><a href="functions.html#defining-functions">Defining Functions</a></li>
<li><a href="functions.html#using-functions">Using Functions</a></li>
</ul>
<li><a href="examples.html">Examples</a></li>
<ul>
<li><a href="examples.html#fizz-buzz">Fizz Buzz</a></li>
<li><a href="examples.html#http-server">Simple HTTP Server</a></li>
<li><a href="examples.html#http-request">Simple HTTP Request</a></li>
</ul>
</ul>
</div>
<div class="page-content">
Expand Down
12 changes: 10 additions & 2 deletions src/variables.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@
<li><a href="variables.html#using-variables">Using Variables</a></li>
</ul>
<li><a href="functions.html">Function</a></li>
<ul>
<li><a href="functions.html#defining-functions">Defining Functions</a></li>
<li><a href="functions.html#using-functions">Using Functions</a></li>
</ul>
<ul>
<li><a href="examples.html#fizz-buzz">Fizz Buzz</a></li>
<li><a href="examples.html#http-server">Simple HTTP Server</a></li>
<li><a href="examples.html#http-request">Simple HTTP Request</a></li>
</ul>
</ul>
</div>
<div class="page-content">
Expand Down Expand Up @@ -62,8 +71,7 @@ <h2 id="using-variables">Using Variables</h2>
mut age = 18
writeln("I am %{age}")
++age
writeln("I am %{age}")
</pre>
writeln("I am %{age}")</pre>
<br>
Output:
<samp>I am 18
Expand Down

0 comments on commit d26c423

Please sign in to comment.