|
| 1 | +{ |
| 2 | + "language": "code_jule", |
| 3 | + "groups": [ |
| 4 | + [0, 100], |
| 5 | + [101, 300], |
| 6 | + [301, 600], |
| 7 | + [601, 9999] |
| 8 | + ], |
| 9 | + "quotes": [ |
| 10 | + { |
| 11 | + "text": "fn main() {\n\tprintln(\"Hello, Jule!\")\n}", |
| 12 | + "source": "Basic Hello World Example", |
| 13 | + "length": 38, |
| 14 | + "id": 1 |
| 15 | + }, |
| 16 | + { |
| 17 | + "text": "let a: int = 0\na := 0\nlet mut a: int = 0\nmut a := 0\nlet a: int", |
| 18 | + "source": "Basic Variable Declaration Example", |
| 19 | + "length": 62, |
| 20 | + "id": 2 |
| 21 | + }, |
| 22 | + { |
| 23 | + "text": "struct Employee {\n\tname: str\n\tage: u8\n\ttitle: str\n\tsalary: u32\n}", |
| 24 | + "source": "Common Concepts - Structures | manual.jule.dev", |
| 25 | + "length": 64, |
| 26 | + "id": 3 |
| 27 | + }, |
| 28 | + { |
| 29 | + "text": "fn ok(a: int, mut b: int, c: ...str): (int, int) {\n\tfor _, v in c {\n\t\tprint(v)\n\t}\n\n\tb++\n\tret a, b\n}", |
| 30 | + "source": "Basic Function Declaration Example", |
| 31 | + "length": 99, |
| 32 | + "id": 4 |
| 33 | + }, |
| 34 | + { |
| 35 | + "text": "fn anon() {\n\tx, y := 10, 20\n\tmut f := fn(a: int, b: int): int {\n\t\tret a + b\n\t}\n\tprintln(f(x, y)) // 30\n\tf = fn(a: int, b: int): int {\n\t\tret a * b\n\t}\n\tprintln(f(x, y)) // 200\n}", |
| 36 | + "source": "Common Concepts - Anonymous Functions | manual.jule.dev", |
| 37 | + "length": 175, |
| 38 | + "id": 5 |
| 39 | + }, |
| 40 | + { |
| 41 | + "text": "let x: [2]int = [1, 2]\nlet x: [...]int = [1, 2, 3, 4, 5] // [5]int\nx := [5]int([1, 2, 3, 4, 5])\nlet x: [1000]int = [100, ...] // [1000]int = [100, 100, 100, ...]", |
| 42 | + "source": "Common Concepts - Arrays | manual.jule.dev", |
| 43 | + "length": 161, |
| 44 | + "id": 6 |
| 45 | + }, |
| 46 | + { |
| 47 | + "text": "fn arr() {\n\tlet mut myArray: [3]str = [\"Hello\", \"arrays\", \"indexes\"]\n\tprintln(myArray[0])\n\tmyArray[0] = \"Hi\"\n\tprintln(myArray)\n}", |
| 48 | + "source": "Common Concepts - Arrays | manual.jule.dev", |
| 49 | + "length": 128, |
| 50 | + "id": 7 |
| 51 | + }, |
| 52 | + { |
| 53 | + "text": "let myArray: [2][2]str = [\n\t[\"Apple\", \"Banana\"],\n\t[\"Bred\", \"Cheese\"],\n]\nprintln(myArray)\n// Outputs: [[Apple Banana] [Bred Cheese]]", |
| 54 | + "source": "Common Concepts - Arrays | manual.jule.dev", |
| 55 | + "length": 131, |
| 56 | + "id": 8 |
| 57 | + }, |
| 58 | + { |
| 59 | + "text": "let mut mySlice: []str = nil\nmySlice = [\"Hello\", \"Jule\", \"slices!\"]\nprintln(mySlice)\n// Outputs: [Hello Jule slices!]", |
| 60 | + "source": "Common Concepts - Slices | manual.jule.dev", |
| 61 | + "length": 117, |
| 62 | + "id": 9 |
| 63 | + }, |
| 64 | + { |
| 65 | + "text": "enum FileMode {\n\tRead: 35,\n\tWrite: 89\n\tBoth,\n}", |
| 66 | + "source": "Common Concepts - Enums | manual.jule.dev", |
| 67 | + "length": 46, |
| 68 | + "id": 10 |
| 69 | + }, |
| 70 | + { |
| 71 | + "text": "match {\n| false:\n\tprintln(\"Case1\")\n| true:\n\tprintln(\"Case2\")\n\tfall\n| false:\n\tprintln(\"Case3\")\n\tfall\n|:\n\tprintln(\"Default\")\n}", |
| 72 | + "source": "Common Concepts - Match Statements | manual.jule.dev", |
| 73 | + "length": 124, |
| 74 | + "id": 11 |
| 75 | + }, |
| 76 | + { |
| 77 | + "text": "fn example[T: int | uint]() {\n\tmatch type T {\n\t| int:\n\t\tprintln(\"int\")\n\t| uint:\n\t\tprintln(\"uint\")\n\t}\n}", |
| 78 | + "source": "Types - Constraints | manual.jule.dev", |
| 79 | + "length": 102, |
| 80 | + "id": 12 |
| 81 | + }, |
| 82 | + { |
| 83 | + "text": "let x: int = 10\nlet y: *int = &x\nprintln(y) // Prints stored address\nunsafe { println(*y) } // Prints value at address (so 10)", |
| 84 | + "source": "Memory - Pointers | manual.jule.dev", |
| 85 | + "length": 126, |
| 86 | + "id": 13 |
| 87 | + }, |
| 88 | + { |
| 89 | + "text": "let mut a = 20\nlet (mut &x, mut y) = a, 20\nx += y\nprintln(a) // 40", |
| 90 | + "source": "Memory - References | manual.jule.dev", |
| 91 | + "length": 66, |
| 92 | + "id": 14 |
| 93 | + }, |
| 94 | + { |
| 95 | + "text": "fn myExceptional()!: int {\n\terror(\"my error\")\n}", |
| 96 | + "source": "Error Handling - Exceptions | manual.jule.dev", |
| 97 | + "length": 47, |
| 98 | + "id": 15 |
| 99 | + }, |
| 100 | + { |
| 101 | + "text": "use \"snapbox\"\nuse \"snapbox/header\"\nuse \"snapbox/status\"\n\nfn main() {\n\tlet headerMap: header::HeaderMap = {\n\t\theader::ACCEPT: \"application/json\",\n\t}\n\n\trequest := snapbox::GET(\"https://httpbin.org/get\").Headers(headerMap)\n\tresponse := request.Send()\n\n\tif !status::IsSuccess(response.status) {\n\t\tprintln(\"Error: \")\n\t\tprintln(response.status)\n\t}\n\n\tprint(response.body)\n}", |
| 102 | + "source": "Usage Examples | snapbox.adamperkowski.dev", |
| 103 | + "length": 366, |
| 104 | + "id": 16 |
| 105 | + }, |
| 106 | + { |
| 107 | + "text": "fn cond(x: int)! {\n\tif x > 1000 {\n\t\tprintln(\"greater than thousand\")\n\t} else if x < 100 {\n\t\tprintln(\"less than hundred\")\n\t} else if x == 100 {\n\t\tprintln(\"equals to hundred\")\n\t} else {\n\t\terror(\"huh?\")\n\t}\n}", |
| 108 | + "source": "Common Concepts - Conditional | manual.jule.dev", |
| 109 | + "length": 204, |
| 110 | + "id": 17 |
| 111 | + }, |
| 112 | + { |
| 113 | + "text": "struct Dog {\n\tname: str\n\twords: str = \"woof woof\"\n}\n\nimpl Dog {\n static fn spawn(name: str): Dog {\n\t\tret Dog { name: name }\n }\n\n\tfn voice(self) {\n\t\tprintln(self.name + \" - \" + self.words)\n\t}\n}\n\nfn main() {\n\tdog0 := Dog.spawn(\"Rex\")\n\tdog1 := Dog.spawn(\"Buddy\")\n\n\tprintln(dog0.name)\n\n\tdog0.voice()\n\tdog1.voice()\n}", |
| 114 | + "source": "Common Concepts - Structures | manual.jule.dev", |
| 115 | + "length": 317, |
| 116 | + "id": 18 |
| 117 | + }, |
| 118 | + { |
| 119 | + "text": "let (x, y) = 20, false\nif x == 10 ||\n\ty == false {\n}", |
| 120 | + "source": "Introduction - Syntax | manual.jule.dev", |
| 121 | + "length": 52, |
| 122 | + "id": 19 |
| 123 | + }, |
| 124 | + { |
| 125 | + "text": "let mut counter = 0\nfor counter <= 5 {\n\tprintln(counter)\n\tcounter += 10\n}", |
| 126 | + "source": "Common Concepts - Interations | manual.jule.dev", |
| 127 | + "length": 73, |
| 128 | + "id": 20 |
| 129 | + }, |
| 130 | + { |
| 131 | + "text": "let mut i = 1\nfor i <= 5; i++ {\n\tprintln(i)\n}", |
| 132 | + "source": "Common Concepts - Interations | manual.jule.dev", |
| 133 | + "length": 45, |
| 134 | + "id": 21 |
| 135 | + }, |
| 136 | + { |
| 137 | + "text": "type Int: int\n\nimpl Int {\n\tfn IsEven(self): bool { ret self%2 == 0 }\n\tfn IsOdd(self): bool { ret self%2 == 1 }\n}\n\nfn main() {\n\tx := Int(20)\n\tprintln(x.IsEven())\n\tprintln(x.IsOdd())\n}", |
| 138 | + "source": "Types - Aliasing | manual.jule.dev", |
| 139 | + "length": 182, |
| 140 | + "id": 22 |
| 141 | + }, |
| 142 | + { |
| 143 | + "text": "fn sum[T](a: T, b: T) T {\n\tlet x: T = a + b\n\tret x\n}", |
| 144 | + "source": "Types - Generics | manual.jule.dev", |
| 145 | + "length": 52, |
| 146 | + "id": 23 |
| 147 | + }, |
| 148 | + { |
| 149 | + "text": "trait Foo {\n fn foo(self)\n}\n\ntrait Bar {\n fn bar(self)\n}\n\ntrait FooBar {\n Foo\n Bar\n}\n\nstruct Baz {}\n\nimpl FooBar for Baz {\n fn foo(self) { println(\"foo\") }\n fn bar(self) { println(\"bar\") }\n}\n\nfn main() {\n let a: FooBar = Baz{}\n a.foo()\n a.bar()\n let b: Foo = a\n b.foo()\n let c: Bar = a\n c.bar()\n}", |
| 150 | + "source": "Dynamic Types - Traits | manual.jule.dev", |
| 151 | + "length": 335, |
| 152 | + "id": 24 |
| 153 | + }, |
| 154 | + { |
| 155 | + "text": "for {\n\tmatch {\n\t| true:\n\t\tbreak\n\t}\n}", |
| 156 | + "source": "Common Concepts - Labels | manual.jule.dev", |
| 157 | + "length": 36, |
| 158 | + "id": 25 |
| 159 | + }, |
| 160 | + { |
| 161 | + "text": "fn label() {\nfoo:\n\tfor {\n\t\tmatch {\n\t\t| true:\n\t\t\tbreak foo\n\t\t}\n\t}\n}", |
| 162 | + "source": "Common Concepts - Labels | manual.jule.dev", |
| 163 | + "length": 66, |
| 164 | + "id": 26 |
| 165 | + }, |
| 166 | + { |
| 167 | + "text": "use \"std/os\"\nuse \"std/strings\"\n\nfn main() {\n\tcontent := str(os::ReadFile(\"data.txt\")!)\n\tos::WriteFile(\"data.txt\", strings::ToLower(content))\n}", |
| 168 | + "source": "Basic File I/O Example", |
| 169 | + "length": 142, |
| 170 | + "id": 27 |
| 171 | + }, |
| 172 | + { |
| 173 | + "text": "use \"std/os\"\n\nfn main() {\n\ttext := os::Stdin().ReadLine()!\n\n\tprintln(\"You said: \" + text)\n}", |
| 174 | + "source": "Basic Standard Input Example", |
| 175 | + "length": 91, |
| 176 | + "id": 28 |
| 177 | + } |
| 178 | + ] |
| 179 | +} |
0 commit comments