This repository has been archived by the owner on Nov 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
801fadd
commit d26c423
Showing
5 changed files
with
142 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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('<h1>Made with love in PLang</h1>') | ||
} | ||
|
||
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters