From 396e294919362bc633d5f733154c25b2b997ccb7 Mon Sep 17 00:00:00 2001 From: Feihong Hsu Date: Wed, 9 Oct 2024 20:02:12 -0500 Subject: [PATCH] Add ocaml syntax versions of snippets in tables (wip) --- docs/overview.md | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/overview.md b/docs/overview.md index 905f74dd8..2fa82da96 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -10,9 +10,9 @@ _Details: [Let Bindings](/let-bindings)_ Feature | Example --------------------------------|---------- -String value | `let hi = "Hello World";` -Int value | `let count = 42;` -Type annotation on binding | `let count: int = 42;` +String value | let hi = "Hello World"let hi = "Hello World"; +Int value | let count = 42let count = 42; +Type annotation on binding | let count: int = 42let count: int = 42; - Note: Let bindings are immutable and cannot change once created. @@ -22,17 +22,17 @@ _Details: [Primitives](primitives)_ Feature | Example --------------------------------|---------- -Int | `let x: int = 10;` -Float | `let x: float = 10.0;` -Boolean | `let x: bool = false;` -String | `let x: string = "ten";` -Char | `let x: char = 'c';` -Unit | `let x: unit = ();` -Option | `let x: option(int) = Some(10);` -Tuple | `let x: (int, string) = (10, "ten");` -List | `let x: list(int) = [1, 2, 3];` -Array | let x: array(int) = [|1, 2, 3|]; -Functions | `let x: (int, int) => int = (a, b) => a + b;` +Int | let x: int = 10let x: int = 10; +Float | let x: float = 10.0let x: float = 10.0; +Boolean | let x: bool = falselet x: bool = false; +String | let x: string = "ten"let x: string = "ten"; +Char | let x: char = 'c'let x: char = 'c'; +Unit | let x: unit = ()let x: unit = (); +Option | let x: int option = Some 10let x: option(int) = Some(10); +Tuple | let x: (int, string) = (10, "ten")let x: (int, string) = (10, "ten"); +List | let x: int list = [1; 2; 3];let x: list(int) = [1, 2, 3]; +Array | let x: int array = [|1; 2; 3|]let x: array(int) = [|1, 2, 3|]; +Functions | let x : int -> int -> int = fun a b -> a + blet x: (int, int) => int = (a, b) => a + b; ## Strings @@ -41,11 +41,11 @@ _Details: [Strings](primitives#strings)_ Feature | Example --------------------------------|---------- String | `"Hello"` -String concatenation | `"Hello " ++ "World"` +String concatenation | "Hello " ^ "World""Hello " ++ "World" Character | `'x'` -Character at index | `let x = "Hello"; x.[2];` +Character at index | let x = "Hello" in x.[2]let x = "Hello"; x.[2]; -- String Functions: [`module String`](https://reasonml.github.io/api/String.html) +- String Functions: module Stringmodule String ## Numbers @@ -69,19 +69,19 @@ Feature | Example --------------------------------|---------- Boolean Values | `true`, `false` Comparison | `>`, `<`, `>=`, `<=` -Boolean operations | `!`, `&&`, || -Reference equality | `===`, `!==` -Structural equality | `==`, `!=` +Boolean operations | not!, `&&`, || +Reference equality | =====, !=!== +Structural equality | ===, <>!= ## If-Else Expressions Feature | Example --------------------------------|---------- -If-Else expressions | `if (condition) { a; } else { b; }` -Ternary expressions | `condition ? a : b;` +If-Else expressions | if condition then a else bif (condition) { a; } else { b; } +Ternary expressions | not applicablecondition ? a : b; - Note: These are expressions and can be assigned to a variable: -`let x = if (condition) { a; } else { b; };` +let x = if condition then a else blet x = if (condition) { a; } else { b; }; ## Functions