From d26c423db2fa1b58a187507aaee50e524162fed7 Mon Sep 17 00:00:00 2001 From: puffer Date: Thu, 19 Oct 2023 11:36:15 +0000 Subject: [PATCH] Added new things --- src/examples.html | 100 +++++++++++++++++++++++++++++++++++++++ src/functions.html | 12 +++++ src/getting-started.html | 10 ++++ src/index.html | 10 ++++ src/variables.html | 12 ++++- 5 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 src/examples.html diff --git a/src/examples.html b/src/examples.html new file mode 100644 index 0000000..bb80599 --- /dev/null +++ b/src/examples.html @@ -0,0 +1,100 @@ + + + + + + Plang Documents - Function + + + + + + + +
+ +
+

Examples

+

Some simple examples

+

Fizz Buzz

+
+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)
+    }
+}
+
+

Simple HTTP Server

+
+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)
+
+

Simple HTTP Request

+
+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())
+
+
+ + \ No newline at end of file diff --git a/src/functions.html b/src/functions.html index 11dc772..f77894b 100644 --- a/src/functions.html +++ b/src/functions.html @@ -33,11 +33,23 @@
  • Using Variables
  • Function
  • + +
  • Examples
  • +

    Functions

    Simple introduction to understanding how functions work and how you define them and how you use them

    +

    Defining Functions

    +

    Using Functions

    diff --git a/src/getting-started.html b/src/getting-started.html index 190d533..3b7b8bd 100644 --- a/src/getting-started.html +++ b/src/getting-started.html @@ -33,6 +33,16 @@
  • Using Variables
  • Function
  • + +
  • Examples
  • +
    diff --git a/src/index.html b/src/index.html index a4e2bac..f2335bb 100644 --- a/src/index.html +++ b/src/index.html @@ -45,6 +45,16 @@
  • Using Variables
  • Function
  • + +
  • Examples
  • +
    diff --git a/src/variables.html b/src/variables.html index 600030a..f3a5f38 100644 --- a/src/variables.html +++ b/src/variables.html @@ -33,6 +33,15 @@
  • Using Variables
  • Function
  • + +
    @@ -62,8 +71,7 @@

    Using Variables

    mut age = 18 writeln("I am %{age}") ++age -writeln("I am %{age}") - +writeln("I am %{age}")
    Output: I am 18